Project Report Linear Systems
Project Report Linear Systems
_______________________
A reportby:
submitted
in the
Project Report on
Simulation of Inverted
pendulum Control
Table of contents
S.
NO.
Topic
INTRODUCTION
1.
2.
3.
4.
5.
6.
Page
No.
2
3
4
5
8
9
10
7.
14
8.
19
9.
20
10.
22
11.
23
12.
FULL-ORDER DESIGN
24
13.
26
14.
27
15.
29
INTRODUCTION:
1
29
x (t) + J
o
Where, F(T) is input signal and two output measurements are x and
m1
m2
lo
Jo
lc
g
0.213 kg
1.785 Kg
0.330 m
0.0246 Kg-m2
0.071 m
9.81 m/s2
Since both the above equation are of order 2 and both the equation involve
variables x and , So the system described by these equations is a 4 th
order system and hence we need 4 state variables to define the state space
model.
1.
x (t) ,
x 2(t) =
x 3 (t) =
(t),
(t)
x4 (t) =
(t) = x3(t)
x
x
= x2
=
m1 lo
m1 lo 2J 0
)[
g x 1(t )
m l
J
Jo
+ 1+ 2 c o 2 g x 3 ( t )
F (t)
2
lo
m1l m1 l o
( m1 l o )
= x4
x1(t)
Jo
1
+
m1 l o m1 l o ( m 1 l o2J o )
m1 g
2
m1 l o J o
x3(t)
{[
g
m1 l o
2
m1 l o J o
1+
m2 l c
J
1
o2 +
m1 l o m1 lo
lo
]}
+F(t)
Output Equations:
(t) = x (t)
3
x(t) = x1 (t)
By replacing the values of the constant parameter by the values from given
table
| || |
1
0
0 x1
0
0 282.35 0 x 2 82.24
+
[ F(t ) ]
0
0
1 x3
0
0 885.35 0 x 4 235
0
491.03
x =
0
1,487.95
y=
| |
(t)
x (t)
||
x1
0 0 1 0 x2
1 0 0 0 x3
x4
sys_invpend = ss (A,B,C,D);
TF(S) =
Y (S)
1
=C ( SI A ) B + D
U (S)
The transfer function of the system is in the form of transfer function matrix
because the system has two different outputs for the single input F(t).
These two transfer functions corresponding to two outputs will have the
location same but different zero locations.
pole
Tf_Theta =H(2) =
(S)
235 S 2+ 6,977
= 4
U (S) S 394.3 S 21,4610
X ( S)
82.24 S 26,459
= 4
U (S) S 394.3 S 214,610
Tf_Pos = H(1)=
|B
AB
n1
B|
Cx =
0
82
0
25970
82
0
25970
0
0
235
0
85688
235
0
85688
0
Rank = 4 = N (Controllable)
Ox =
||
C
CA
2
CA
C A n1
Ox =
0
0
1
0
1
0
0
0
0
0
0
1
0
1
0
0
1488
0
885.6
0
491
0
282.4
0
0
1488
0
885.6
0
491
0
282.4
Rank = 4 =N ( Observable)
3.c Controllable Form : In order to find the matrices for controllable canonical
form, first the coefficients of the characteristic polynomial are calculated by using
the command poly(A)
a0 = -14611
a1 = 0
6
a2 = -394
a3 = 0
a4 = 1
Ac =
0
0
0
14611
1 0
0 1
0 0
0 394
0
0
1
0
Bc =
||
0
0
0
1
And Tc = CxCxc-1,
Cxc =
|B
Ac B c
Ac
n1
Bc|
Cc = C Tc..
Cc =
3.d
6514.9 0 82.2 0
7136.8 0 235 0
Dc =D =[0;0]
Ao =
Co =
Bo =
0
1
0
0
0
0
1
0
0 14611
0
0
0 394
1
0
|0 0 0 1|
6514.9 7136.8
0
0
82.2
235
0
0
D0 = D =[0;0]
M =
.0142 .0142
0.0887 i .0887 i
0.2932 0 .2932 0.5181 0.5181
0.0461
0.0461 0.1436 i 00.1436 i
0.9548 0.9548
0.8385
0.8385
Aj =
Bj =
Cj =
Bj = inv(M)*B;
Cj = C*M;
20.7
0
0
0
0
20.7
0
0
0
0
5.84 i
0
0
0
o
5.84 i
| |
106.09
106.09
19.33
19.33
Dj = D
x and the
27
Impulse Response
x 10
To: Out(1)
1.5
1
Amplitude
0.5
27
0
x 10
0
To: Out(2)
-1
-2
-3
-4
-5
0.5
1.5
2.5
Time (seconds)
(b) Step Response: For step response , the MATLAB command used is step (sys_invpend)
Output plot 1 is for Position x and the output plot 2 is for the angle .
10
25
Step Response
x 10
To: Out(1)
6
4
Amplitude
2
26
0
x 10
0
To: Out(2)
-0.5
-1
-1.5
-2
-2.5
0
0.5
1.5
Time (seconds)
11
2.5
15
10
-5
-10
-15
-25
-20
-15
-10
-5
12
10
15
20
25
Magnitude (dB)
150
100
50
0
-50
180
Phase (deg)
135
90
45
0
-45
-1
10
10
10
10
Frequency (rad/s)
Root Locus
-1
Im aginary Ax is (s ec onds
)
6
4
2
0
-2
-4
-6
-8
-50
-40
-30
-20
-10
10
13
20
30
40
50
6. CONTROLLER
THEORY):
DESIGN
(USING
CLASSICAL
CONTROL
For designing a pid controller following table was considered while varying the
values of gains to get the desired output.
CL
RESPONSE
RISE TIME
OVERSHOO
T
SETTLING
TIME
S-S
ERROR
Kp
Decrease
Increase
Small Change
Decrease
Ki
Decrease
Increase
Increase
Eliminate
Kd
Small Change
Decrease
Decrease
No Change
looking for the best parameters to be applied to control the system, the following results were
found:
For
( S)
U (S)
Step Response
1.8
1.6
1.4
Amplitude
1.2
1
0.8
0.6
0.4
0.2
0
0.02
0.04
0.06
0.08
0.1
0.12
Time (seconds)
X (S)
U (S)
15
Step Response
1.8
1.6
1.4
1.2
Amplitude
0.8
0.6
0.4
0.2
0.02
0.04
0.06
0.08
0.1
0.12
Time (seconds)
Response for
( S)
U (S) =the closed system transfer function is:
16
SINE
WAVE
Step Response
1.8
1.6
1.4
Amplitude
1.2
1
0.8
0.6
0.4
0.2
0
0.02
0.04
0.06
0.08
Time (seconds)
17
0.1
0.12
18
4.5
x 10
4
3.5
3
2.5
2
1.5
1
0.5
0
10
4.5
x 10
18
10
Step Response:
Step Response
1.8
1.6
1.4
Amplitude
1.2
1
0.8
0.6
0.4
0.2
0
0.02
0.04
0.06
0.08
Time (seconds)
0.1
0.12
31
x 10
4.5
4
3.5
3
2.5
2
1.5
1
0.5
0
Sinusoidal response :
20
10
34
12
x 10
10
The response of the system with the designed controller is controllable for step input but is
uncontrollable for square and sinusoidal inputs.
21
1
0.9
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
10
10
(S )
Root Locus
6000
-1
Im aginary Ax is (s ec onds
)
4000
2000
-2000
-4000
-6000
-20000
-15000
-10000
-5000
23
5000
X ( S)
U (S) ;
Root Locus
3000
1000
-1
2000
-1000
-2000
-3000
-9000
-8000
-7000
-6000
-5000
-4000
-3000
-2000
-1000
-1
12
Step Response
x 10
3
2
Amplitude
1
0
-1
-2
-3
-4
0.5
1.5
2.5
Time (seconds)
24
3.5
1000
From Root Locus it is evident that the stability region is very small for these two transfer
functions ,So if the gain is varied slightly the system will go to the instable state. Also, the step
disturbance input results in unstable system . Therefore, it can be said that the system under
control is not very robust with respect to changes in its parameters or disturbance input.
S 2 +20 S +200
Poles at: -10 10i
The other poles will be placed 3-4 times farther from these conjugated poles, to force the
behavior to be as approximated as possible to a second order system. Given the fact that our
system is a fourth order system, it will have 4 poles and because of that the pole placement for
the system will be forced to be the following:
-10 10i, -30 and -40.
Poles = [-10+10i -10-10i -30 -40]; K = place (A, B, Poles);
And K= [-86.9858 -10.1242 -44.0342 -3.9260]
Given this State feedback matrix, the A matrix of the system will be changed in the
following manner: Af= A BK;
25
0
1
0
0
6663
833
3339
323
0
0
0
1
18954 2379 9463 923
Af =
11.
STEP RESPONSE, SQUARE WAVE RESPONSE, SINE
WAVE RESPONSE FOR CLOSED LOOP SYSTEM WITH STATE
FEEDBACK CONTROL
Step Response
0.1
To: Out(1)
0
-0.1
Amplitude
-0.2
-0.3
0.4
Step response for Full State feedback control
To: Out(2)
0.2
0
-0.2
-0.4
0.5
1.5
2.5
Time (seconds)
26
3.5
4.5
0.5
Position
Theta
0.4
0.3
0.2
0.1
0
-0.1
-0.2
-0.3
10
0.3
Position
Theta
0.2
0.1
0
-0.1
-0.2
-0.3
-0.4
10
12 FULL-ORDER OBSERVER
The controller was calculated to provide a systems time constant () equal to 0.1 sec. In order to
provide an acceptable estimator for the system the required time constant of the observer to be
from 2 to 5 times faster; therefore choosing 5 times faster, the following parameters are used for
the observer:
= 0.02
= 0.707
wn= 70.72
Considering the parameters, the desired 2nd order characteristic polynomial for the system
2
S +100 S+ 5000
will be:
G=
247.5
38.6
9126.5 7843.7
54.8
202.5
7323.1 9037.3
Then the full order observer state space equations are found out using the matrices:
Ae =A-G*C-B*K;
Be =G;
Ce =-K;
De=[0 0];
sys_obs_pend = ss(Ae,Be,Ce,De);
Full-Order Observer Step Response:
28
Step Response
From: In(1)
60
From: In(2)
40
Am plitude
20
-20
-40
-60
Time (seconds)
Crce = -Ke;
Drce = -K1 - (Ke*Ge);
sys_red_obs = ss(Arce,Brce,Crce,Drce);
30
Step Response
From: In(1)
350
From: In(2)
300
250
200
Amplitude
150
100
50
-50
-100
-150
0.5
1.5
2.5
3.5
4.5
5 0
0.5
1.5
2.5
Time (seconds)
3.5
4.5
X (S)
7154 S2 +561800
= 4
U (S) S 90 S3 +2800 S 2 +38000 s+ 240000
(S)
20440 S26,06900
= 4
U (S) S 90 S3 +2800 S 2 +38000 s+ 240000
Step Response for closed full observer- controller system:
The resulting Transfer function of the controller-observer adds 4 poles and 3 zeros to the plants
transfer function. If we try to obtain an equivalent controller from the classical point of view, it is
possible to say that this controller is 3 differentiators and 4 integrators.
It can be seen that the step response given by the system under control complies in a very
nice manner the original specifications proposed. The settling time is less than 1 second and the
damping ratio is around the 0.707 value.
Step Response
To: Out(1)
Amplitude
-1
-2
6
To: Out(2)
-2
-4
-6
0.5
1.5
2.5
Time (seconds)
32
3.5
4.5
It can be seen that the step response given by the system under control is responding as
per our design specifications. The settling time is less than 0.4 second and the damping ratio is
around the 0.707 value.
33
34
impulse(sys_invpend);grid
figure
step(sys_invpend);grid
%%%%%%%%%%%Var_Bode plot and root locus%%%%%%%%%%%
figure
bode(Tf_Pos);
figure
rlocus(Tf_Pos);
figure
bode(Tf_Theta);
figure
rlocus(Tf_Theta);
%%%%%%%%%%%Signal Generation%%%%%%%%%%%
[Var_Asq,tsq] = gensig('square',2,10,0.01);
[Var_Asn,tsn] = gensig('sin',2,10,0.01);
%%%%%%%%%%%Angular control%%%%%%%%%%%
Controller_Kp = -900;
Controller_Kd = -0.5;
Controller_Ki = -50;
Var_Contrl1=tf([Controller_Kd Controller_Kp Controller_Ki],[1 0]);
Var_CL_1 = Var_Contrl1* Tf_Theta;
pid_theta= feedback(Var_CL_1,1);
%%%%%%%%%%%Step response%%%%%%%%%%%
figure
step(pid_theta);grid
%%%%%%%%%%%Square wave response%%%%%%%%%%%
[y,t]=lsim(pid_theta,Var_Asq,tsq);
figure
plot(t,y); grid
legend('Square wave response for angle control')
%%%%%%%%%%%Sine wave response%%%%%%%%%%%
[y,t]=lsim(pid_theta,Var_Asn,tsn);
figure
plot(t,y); grid
legend('Sine Wave response for angle control')
%%%%%%%%%%%Position control%%%%%%%%%%%
Controller_Kd = 1.2;
Controller_Kp =3000;
Controller_Ki = 10;
Var_Contrl2=tf([Controller_Kd Controller_Kp Controller_Ki],[1 0]);
Var_CL_2= Tf_Pos * Var_Contrl2;
pid_pos= feedback(Var_CL_2,1);
%%%%%%%%%%%Step response%%%%%%%%%%%
figure
35
step(pid_pos);grid
36
plot(t,y);grid
title('Sine response for State feedback control')
legend('Pos','Theta');
%%%%%%%%%%%%%%%%%%Full order and reduced order observer%%%%%%%%%%%%%%%%%%
Pole_of_obs=[-50+50i -50-50i -150 -200];
G = place(Var_A',Var_C',Pole_of_obs)';
Var_Ae =Var_A-G*Var_C-Var_B*K;
Var_Be =G;
Var_Ce =-K;
Var_De=[0 0];
sys_obs_pend = ss(Var_Ae,Var_Be,Var_Ce,Var_De);
tf_sys_obs = tf(sys_obs_pend);
figure
step(sys_obs_pend,5);grid
Var_Ace = [Var_A-Var_B*K
Var_B*K zeros(size(Var_A)) (Var_A-G*Var_C)];
Var_Bce = [Var_B zeros(size(Var_B))];
Var_Cce = [Var_C zeros(size(Var_C))];
Var_Dce = [0;0];
sys_full_obs = ss(Var_Ace,Var_Bce,Var_Cce,Var_Dce);
tf_sys_full_obs = tf(sys_full_obs);
figure
step(sys_full_obs,5);grid
[y,t,x]=lsim(sys_full_obs,Var_Asn,tsn);
figure
plot(t,y);grid
title('Sine response for Var_Closed loop Full order Observer Var_Controller')
legend('Pos','Theta');
% Reduced order observer
Ge = [15 -5; 25 5];% reduced order estimator gain matrix
Var_A11 = [0 0;0 0];
Var_A1e = [1 0;0 1];
Var_Ae1 = [-491.03 -282.35; 1487.95 885.35];
Var_Aee = [0 0; 0 0];
Var_B1 =[0;0]; Var_Be =[82.24;-235];
K1 =[K(1) K(3)]; Ke =[K(2) K(4)];
Var_Arce = Var_Aee - (Ge*Var_A1e) - (Var_Be*Ke) + (Ge*Var_B1*Ke);
Var_Brce = Var_Ae1 - (Ge*Var_A11) + (Var_Aee*Ge) - (Ge*Var_A1e*Ge) (Var_Be*K1) + (Ge*Var_B1*K1) - (Var_Be*Ke*Ge) + (Ge*Var_B1*Ke*Ge);
Var_Crce = -Ke;
Var_Drce = -K1 - (Ke*Ge);
red_obs_pend = ss(Var_Arce,Var_Brce,Var_Crce,Var_Drce);
tf_red_obs_pend = tf(red_obs_pend);
figure
step(red_obs_pend,5);grid
37
38