Linear Control System Project

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 15

Linear Control System

Project

Submitted by
TALHA RIAZ Capt. Shazma Sohail Ahmad
Reg # 327885 Reg # 359287 Reg # 330019
Pre-requisite: Converting given LTV system into LTI system
First of all the given LTV sys was converted to LTI sys through given sinusoidal transformation
matrix using following Matlab code:
clear all, close all, clc

w=200*pi;
J=0.01;
J_z=0.017;
K_i=0.01;
K_o=0.1;
H=(J_z-J)*w;
t=1;
PT = [cos(w*t) -sin(w*t) 0 0; sin(w*t) cos(w*t) 0 0; 0 0 cos(w*t) -sin(w*t); 0
0 sin(w*t) cos(w*t)]
PT_I = inv(PT)
A = [0 w 1 0;-w 0 0 1; 0 0 0 -H/J; 0 0 H/J 0]
B = K_i*[0 0;0 0;sin(w*t) cos(w*t);-cos(w*t) sin(w*t)]
C = K_o*[w*cos(w*t) w*sin(w*t) sin(w*t) -cos(w*t)]
C_out = [1 0 0 0;0 1 0 0]

B_z = PT_I*B
C_z = C*PT

Matrix A was already LTI so it was not converted.


Req 1: State Feedback Controller
For state Feedback Controller values are gain K={K1 K2 K3 K4] are calculated for placing the
poles at desired location using the fol matlab code:
K = place(A,B_z,[-3 -4 -5 -7])

Block diagram for state feedback controller in Simulink is as follows:

Req 2: Output Feedback controller


For output Feedback Controller Gain H was calculated using fol Matlab code:
H = (place(A',C_out',[-30 -40 -50 -70]))'
Then Observer was designed using Subsystem in Simulink, Block diagram is as:

Req 3: Integral controller to State output feedback Controller


In order to remove constant Steady state error integral controller was designed, Gain K_ig was
found for integral Controller using following code:
A_bar = [A zeros(4,2);-1*C_out zeros(2,2)]
B_bar = [B_z;zeros(2,2)]
W = ctrb(A_bar,B_bar)
rank (W)

K_i = place(A_bar, B_bar,[-12 -14 -15 -16 -50 -55])


K_f = [K_i(1) K_i(3) K_i(5) K_i(7); K_i(2) K_i(4) K_i(6) K_i(8)]
K_ig = [K_i(9) K_i(11); K_i(10) K_i(12)]

Where A_bar & B_bar are the augmented matrices. Integral Controller to state output Feedback
Controller Block Diagram:

For sinusoidal Tracking:


Integral Control to Output Feedback Controller:

Complete Code
clear all,
close all,
clc
w=200*pi;
J=0.01;
J_z=0.017;
K_i=0.01;
K_o=0.1;
H=(J_z-J)*w;
t=1;
PT = [cos(w*t) -sin(w*t) 0 0; sin(w*t) cos(w*t) 0 0; 0 0 cos(w*t) -sin(w*t); 0 0 sin(w*t)
cos(w*t)]
PT_I = inv(PT)
A = [0 w 1 0;-w 0 0 1; 0 0 0 -H/J; 0 0 H/J 0]
B = K_i*[0 0;0 0;sin(w*t) cos(w*t);-cos(w*t) sin(w*t)]
C = K_o*[w*cos(w*t) w*sin(w*t) sin(w*t) -cos(w*t)]
C_out = [1 0 0 0;0 1 0 0]

B_z = PT_I*B
C_z = C*PT

rank(ctrb(A,B_z))

K = place(A,B_z,[-3 -4 -5 -7])
H = (place(A',C_out',[-60 -80 -100 -140]))'

N = -inv(C_out*inv(A-B_z*K)*B_z)

A_bar = [A zeros(4,2);-1*C_out zeros(2,2)]


B_bar = [B_z;zeros(2,2)]
W = ctrb(A_bar,B_bar)
rank (W)

%C_bar = [C_z 0]
K_i = place(A_bar, B_bar,[-12 -14 -15 -16 -50 -55])
K_f = [K_i(1) K_i(3) K_i(5) K_i(7); K_i(2) K_i(4) K_i(6) K_i(8)]
K_ig = [K_i(9) K_i(11); K_i(10) K_i(12)]

Results
PT =

1.0000 -0.0000 0 0
0.0000 1.0000 0 0
0 0 1.0000 -0.0000
0 0 0.0000 1.0000
PT_I =

1.0000 0.0000 0 0
-0.0000 1.0000 0 0
0 0 1.0000 0.0000
0 0 -0.0000 1.0000

A=

0 628.3185 1.0000 0
-628.3185 0 0 1.0000
0 0 0 -439.8230
0 0 439.8230 0

B=

0 0
0 0
0.0000 0.0100
-0.0100 0.0000

C=

62.8319 0.0000 0.0000 -0.1000

C_out =

1 0 0 0
0 1 0 0

B_z =

0 0
0 0
0 0.0100
-0.0100 0

C_z =

62.8319 0 0 -0.1000

ans =

K=

1.0e+07 *

0.0604 3.9381 0.0019 -0.0001


-3.9569 0.0589 0.0001 0.0019

H=

1.0e+05 *
0.0012 0.0019
-0.0019 0.0007
-1.8994 -0.3079
0.5278 -1.9224

N=

1.0e+03 *

-0.6622 -2.2044
2.0957 0.6339

A_bar =

0 628.3185 1.0000 0 0 0
-628.3185 0 0 1.0000 0 0
0 0 0 -439.8230 0 0
0 0 439.8230 0 0 0
-1.0000 0 0 0 0 0
0 -1.0000 0 0 0 0

B_bar =

0 0
0 0
0 0.0100
-0.0100 0
0 0
0 0
W=

1.0e+11 *

0 0 0 0.0000 -0.0000 0 0 -0.0000 0.0000 0 0 0.0107


0 0 -0.0000 0 0 -0.0000 0.0000 0 0 0.0000 -0.0107 0
0 0.0000 0.0000 0 0 -0.0000 -0.0000 0 0 0.0037 1.6458
0
-0.0000 0 0 0.0000 0.0000 0 0 -0.0000 -0.0037 0 0
1.6458
0 0 0 0 0 -0.0000 0.0000 0 0 0.0000 -0.0000 0
0 0 0 0 0.0000 0 0 0.0000 -0.0000 0 0 -0.0000

ans =

K_i =

1.0e+07 *

0.5165 3.9175 0.0019 -0.0008 0.0113 0.1031


-3.9421 0.5012 0.0008 0.0019 -0.1086 -0.0096

K_f =

1.0e+07 *

0.5165 3.9175 0.0019 -0.0008


-3.9421 0.5012 0.0008 0.0019

K_ig =

1.0e+06 *

0.1126 1.0308
-1.0861 -0.0957
Simulink design
Constant input tracking
Results

Figure-1 output of scope 1

Figure-2 output of scope 1


Figure-3 output of scope

Figure-4 output of scope 1


Figure-5 output of scope 1

Sine wave input


Results

Figure-6 output of scope 6

Figure-7 output of scope 7

You might also like