LCS Project
LCS Project
LCS Project
Submitted By:
Participant-I: TALHA RIAZ
Reg # 327885
Email ID: [email protected]
Participant-II: Capt. Shazma
Reg # 359287
Participant-III: Sohail Ahmad
Reg # 330019
Submitted to: Dr. Muwahida Liaqaut
H variables
The angular momentum J z numerical
and their J values used are
J moment of inertia 0.01 Kg-m 2
The gyroscope is assumed to be spinning about z axis with a constant angular speed . The
angular positions of gyroscope around x and y axis are represented as the states x1 and x2 in
the state-space model. The spin frequency about x and y axis corresponds to the derivatives of
first and second states respectively. The requirement is to secure the position of x and y axis
to a r 0.3 0.2 . The initial conditions of the gyroscope are x[0] 0.01 0.02 0.01 0.01 .
T T
To resolve this problem the time varying system (1) is transformed into an LTI system using
sinusoidal transformation given by
cos t sin t
P (t )
sin t cos t
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.
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)
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
w=
628.3185
J=
0.0100
J_z =
0.0170
K_i =
0.0100
K_o =
0.1000
H=
4.3982
t=
1
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.0000 0.0100
-0.0100 0
C_z =
62.8319 0 0 -0.1000
ans =
4
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.0024 0.0019
-0.0019 0.0014
-1.7944 -0.6158
1.0556 -1.8864
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.0000 0.0100
-0.0100 0
0 0
0 0
W=
1.0e+11 *
0 0 -0.0000 0.0000 -0.0000 0 0.0000 -0.0000 0.0000 0 -0.0000
0.0107
0 0 -0.0000 0 0.0000 -0.0000 0.0000 0 -0.0000 0.0000 -0.0107
0
-0.0000 0.0000 0.0000 0 0.0000 -0.0000 -0.0000 0 -0.0000 0.0037
1.6458 0
-0.0000 0 -0.0000 0.0000 0.0000 0 0.0000 -0.0000 -0.0037 0
-0.0000 1.6458
0 0 0 0 0.0000 -0.0000 0.0000 0 -0.0000 0.0000 -0.0000
0
0 0 0 0 0.0000 0 -0.0000 0.0000 -0.0000 0 0.0000
-0.0000
ans =
4
K_i =
1.0e+07 *
0.5154 3.9154 0.0019 -0.0008 0.0119 0.1027
-3.9442 0.5023 0.0008 0.0019 -0.1091 -0.0101
K_f =
1.0e+07 *
0.5154 3.9154 0.0019 -0.0008
-3.9442 0.5023 0.0008 0.0019
K_ig =
1.0e+06 *
0.1191 1.0272
-1.0912 -0.1014
Simulink Block for Constant Tracking
Sin wave Tracking Simulink Block
Constant Tracking with State Feedback Controller
Combined plot with Error
Combined Sin wave tracking Plot with State, Output & Integral Control
Separate Sin wave tracking Plot with State, Output & Integral Control