Linear Control System
LCS Project
Submitted By:
Participant-I: TALHA RIAZ
Reg # 327885
Email ID: triaz.ee20ceme@[Link]
Participant-II: Capt. Shazma
Reg # 359287
Participant-III: Sohail Ahmad
Reg # 330019
Submitted to: Dr. Muwahida Liaqaut
Department of Electrical Engineering
Collage of Electrical & Mechanical Engineering
National University of Science & Technology
Design control of a gyroscope that can be represented by the given state-space model
x t Ax t B t u t
y t C (t ) x t
(1)
4 2
The states of the system are given by x R and u R is the continuous control input. The
T
y R 2 needs r = rx ry
continuous output to be regulated to follow a constant reference .
The system matrices corresponding to
0 1 0
0 0 1
A
0 0 0 H / J
0 0 H / J 0
0 0
0 0
B t Ki
sin(t ) cos(t)
cos(t ) sin(t )
C (t ) K0 cos(t ) sin(t ) sin(t ) cos(t ) .
1 0 0 0
C'
0 1 0 0
H variables
The angular momentum J z numerical
and their J values used are
J moment of inertia 0.01 Kg-m 2
J z moment of inertia about z-axis 0.017 Kg-m 2
spin frequency of gyroscope about z-axis 200 rad/sec
Ko scaling factor that depends on mechanism of generating ym (t ) 0.1
Ki torque constant 0.01
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.
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
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
Constant Tracking with Output Feedback Controller
Combined plot with Error
Constant Tracking with Integral Feedback Controller
Combined plot of State, Output & Integral feedback Controller
Separate plot of State, Output & Integral feedback Controller
Sine Wave Tracking with State Feedback Controller
Sine Wave Tracking with Output Feedback Controller
Sine Wave Tracking with Integral Feedback Controller
Sine Wave Tracking with Integral Feedback Controller also input Combined
Combined Sin wave tracking Plot with State, Output & Integral Control
Separate Sin wave tracking Plot with State, Output & Integral Control