Professional Documents
Culture Documents
RAMIN SHAMSHIRI
UFID#: 9021-3353
Ramin Shamshiri
Due 30/04/09
Page 2 of 33
I.
Problem overview:
Design a PID and LQR controller for an Osprey UAQ as shown in the image below.
II.
Dynamic Model:
The dynamics associated with the Osprey under standard aircraft assumptions have been decoupled into both lateral and longitudinal directions. For the sake of this control design, we will
only be analyzing the longitudinal dynamics. The dynamics have been linearized for the Osprey
aircraft flying at 25 m/s at an altitude of 60 m in [1]. In standard state-space form they are as
follows.
0.1470
0.0316
=
0
0
11.0767
7.1712
37.3527
0
where =
0.0841
0.8281
9.9628
1
9.8065
0
0
0
3.103
5
= 10
0.98
0
0.06
104
0
0
1 0 0 0
0 0 1 0
Ramin Shamshiri
Due 30/04/09
Page 3 of 33
III.
Control objective:
Design a single controller that yields the following desired criteria over the widest possible initial
conditions.
1. Stabilize the system with a velocity step input of 10m/s.
2. Minimize rise time, % overshoot, and steady state error.
3. Actuator limits and sensor noise:
The maximum is 200 and 200 /
The maximum is 30 and 300 /
The noise for the velocity sensor is 0.4 /
The noise for the pitch rate sensor is 1.7/
IV.
Expectations:
Ramin Shamshiri
Due 30/04/09
Page 4 of 33
Solution:
Creating model in MATLAB:
% Dynamic Model
A=[-0.1470 11.0767 0.0841 -9.8065;-0.0316 -7.1712 0.8281 0;0 -37.3527 -9.9628
0;0 0 1 0];
B=[3.1^-3 0.06;10^-5 10^-4;0.98 0;0 0];
C=[1 0 0 0;0 0 1 0];
D=[0 0;0 0];
states = {'Velocity' 'Angle of attack' 'Pitch rate' 'Pitch Angle'};
inputs = {'d_{elev}' 'd_{thrust}'};
outputs = {'velocity' 'pitch rate'};
% State Spapce representation
sys_ss_osprey = ss(A,B,C,D,'statename',states,...
'inputname',inputs,...
'outputname',outputs)
The model has two inputs and two outputs. The two inputs are elevator and thrust and the two
outputs are velocity and pitch rate.
a =
Velocity
Angle of att
Pitch rate
Pitch Angle
Velocity
-0.147
-0.0316
0
0
Angle of att
11.08
-7.171
-37.35
0
Pitch rate
0.0841
0.8281
-9.963
1
Pitch Angle
-9.806
0
0
0
b =
Velocity
Angle of att
Pitch rate
Pitch Angle
d_elev
0.03357
1e-005
0.98
0
d_thrust
0.06
0.0001
0
0
c =
velocity
pitch rate
Velocity
1
0
Angle of att
0
0
Pitch rate
0
1
Pitch Angle
0
0
d =
velocity
pitch rate
d_elev
0
0
d_thrust
0
0
Continuous-time model.
Ramin Shamshiri
Due 30/04/09
Page 5 of 33
For a better understanding of the problem, transfer function and ZPK representation of the system
are determined in MATLAB and shown below:
%Transfer function represenation
sys_tf_osprey=tf(sys_ss_osprey)
% ZPK representation
sys_zpk_osprey=zpk(sys_ss_osprey)
Ramin Shamshiri
-0.0037353 s (s-18.81)
------------------------------------------------(s^2 + 0.1612s + 0.1131) (s^2 + 17.12s + 102.4)
Due 30/04/09
Page 6 of 33
System Poles:
Computing the open-loop eigenvalues and plot them in the s-plane:
%Compute the open-loop eigenvalues and plot them in the s-plane.
Damp(sys_ss_osprey)
figure
pzmap(sys_ss_osprey)
Eigenvalue
-8.06e-002
-8.06e-002
-8.56e+000
-8.56e+000
3.26e-001i
3.26e-001i
5.39e+000i
5.39e+000i
Damping
Freq. (rad/s)
2.40e-001
2.40e-001
8.46e-001
8.46e-001
3.36e-001
3.36e-001
1.01e+001
1.01e+001
Figure 1
Ramin Shamshiri
Due 30/04/09
Page 7 of 33
Open-Loop Analysis
Figure 2
Ramin Shamshiri
Due 30/04/09
Page 8 of 33
Figure 3
Ramin Shamshiri
Due 30/04/09
Page 9 of 33
Selecting TF21 ,
Velocity
-0.147
-0.0316
0
0
Angle of att
11.08
-7.171
-37.35
0
Pitch rate
0.0841
0.8281
-9.963
1
Pitch Angle
-9.806
0
0
0
b =
Velocity
Angle of att
Pitch rate
Pitch Angle
d_{elev}
0.03357
1e-005
0.98
0
c =
pitch rate
Velocity
0
Angle of att
0
Pitch rate
1
Pitch Angle
0
d =
pitch rate
d_{elev}
0
Continuous-time model.
0.98 3 + 7.171 2 + 1.416
= 4
Ramin Shamshiri
Due 30/04/09
Page 10 of 33
Ramin Shamshiri
Due 30/04/09
Page 11 of 33
Root Locus Design
Ramin Shamshiri
Due 30/04/09
Page 12 of 33
Closing the SISO feedback loop and plotting the closed loop step response and compare it to the
open loop step response:
%close the SISO feedback loop.
K = 6.42;
cl21 = feedback(sys21,K);
%Plot the closed-loop step response, and compare it to the open-loop step
response.
figure
step(sys21,'b--',cl21,'r')
Ramin Shamshiri
Due 30/04/09
Page 13 of 33
%closing the loop on the full MIMO model and see response
cloop = feedback(sys_ss_osprey,K,2,1);
figure
step(sys_ss_osprey,'b--',cloop,'r')
damp(cloop)
% closed-loop poles
Eigenvalue
-2.73e-001
-2.73e-001
-8.56e+000
-8.56e+000
+
+
-
Ramin Shamshiri
2.02e-001i
2.02e-001i
5.40e+000i
5.40e+000i
Damping
Freq. (rad/s)
8.05e-001
8.05e-001
8.46e-001
8.46e-001
3.40e-001
3.40e-001
1.01e+001
1.01e+001
Due 30/04/09
Page 14 of 33
TF12 ,
Velocity
-0.147
-0.0316
0
0
Angle of att
11.08
-7.171
-37.35
0
Pitch rate
0.0841
0.8281
-9.963
1
Pitch Angle
-9.806
0
0
0
b =
Velocity
Angle of att
Pitch rate
Pitch Angle
d_{thrust}
0.06
0.0001
0
0
c =
velocity
Velocity
1
Angle of att
0
Pitch rate
0
Pitch Angle
0
d =
velocity
d_{thrust}
0
Continuous-time model.
Transfer function from input "d_{thrust}" to output "velocity":
0.06 s^3 + 1.029 s^2 + 6.153 s + 0.03663
--------------------------------------------s^4 + 17.28 s^3 + 105.2 s^2 + 18.44 s + 11.58
Ramin Shamshiri
Due 30/04/09
Page 15 of 33
Ramin Shamshiri
Due 30/04/09
Page 16 of 33
Ramin Shamshiri
Due 30/04/09
Page 17 of 33
Eigenvalue
Damping
Freq. (rad/s)
-3.35e-001
-3.47e-001
-8.56e+000 + 5.40e+000i
-8.56e+000 - 5.40e+000i
1.00e+000
1.00e+000
8.46e-001
8.46e-001
3.35e-001
3.47e-001
1.01e+001
1.01e+001
Ramin Shamshiri
Due 30/04/09
Page 18 of 33
PID control:
+ +
+ =
CL RESPONSE
Kp
KI
Kd
RISE TIME
Decrease
Decrease
Small Change
(0.0)
OVERSHOOT
Increase
Increase
Decrease
SETTLING TIME
Small Change
Increase
Decrease
S-S ERROR
Decrease
Eliminate
Small Change
Adding noise:
+
+
+
d=0
N(Velocity sensor)=0.4
N(Pitch rate sensor)=1.7
+
+
Velocity step input=10, therefore the output with noise would be:
( (0.04)
+
Pitch rate step input=1, therefore the output with noise would be:
( (1.7)
Ramin Shamshiri
Due 30/04/09
Page 19 of 33
PID control for TF21 ,
0.98 3 + 7.171 2 + 1.416
= 4
Ramin Shamshiri
Due 30/04/09
Page 20 of 33
%Close loop reponse:
%P control for TF_21
Kp_21=.5;% Proportional gain
num_Kp_21=[Kp_21];%P TF num
den_Kp_21=[1];%P TF denum
num_P_21=conv(num_Kp_21,num_sys21_tf);
den_P_21=conv(den_Kp_21,den_sys21_tf);
[num_P_Control_21,den_P_Control_21]=cloop(num_P_21,den_P_21);
sys_tf_P_21=tf(num_P_Control_21,den_P_Control_21)
%Plotting P control reponse and comparing it with open loop step response
figure
step(sys21_tf,'b--',sys_tf_P_21,'r')
%Results:
Ramin Shamshiri
Due 30/04/09
Page 21 of 33
%PD control for TF_21
Kp_21=0.5;% Proportional gain
Kd_21=0.5; % Derivative gain
num_KPD_21=[Kd_21 Kp_21];%PD TF num
den_KPD_21=[0 1];%PD TF denum
num_PD_21=conv(num_KPD_21,num_sys21_tf);
den_PD_21=conv(den_KPD_21,den_sys21_tf);
[num_PD_Control_21,den_PD_Control_21]=cloop(num_PD_21,den_PD_21);
sys_tf_PD_21=tf(num_PD_Control_21,den_PD_Control_21)
%Plotting PD control reponse and comparing it with open loop step response
figure
step(sys21_tf,'b--',sys_tf_PD_21,'r')
%Results:
Ramin Shamshiri
Due 30/04/09
Page 22 of 33
%PID control for TF_21
Kp_21=100;% Proportional gain
Kd_21=1; % Derivative gain
Ki_21=200;% Integral gain
num_KPID_21=[Kd_21 Kp_21 Ki_21];%PID TF num
den_KPID_21=[1 0];%PID TF denum
num_PID_21=conv(num_KPID_21,num_sys21_tf);
den_PID_21=conv(den_KPID_21,den_sys21_tf);
[num_PID_Control_21,den_PID_Control_21]=cloop(num_PID_21,den_PID_21);
sys_tf_PID_21=tf(num_PID_Control_21,den_PID_Control_21)
%Plotting PD control reponse:
figure
step(sys21_tf,'b--',sys_tf_PID_21,'r')
Ramin Shamshiri
Due 30/04/09
Page 23 of 33
PID control for TF12 ,
0.06 3 + 1.029 2 + 6.153 + 0.03663
= 4
Ramin Shamshiri
Due 30/04/09
Page 24 of 33
Ramin Shamshiri
Due 30/04/09
Page 25 of 33
%PD control for TF_12
Kp_12=1;% Proportional gain
Kd_12=1; % Derivative gain
num_KPD_12=[Kd_12 Kp_12];%PD TF num
den_KPD_12=[0 1];%PD TF denum
num_PD_12=conv(num_KPD_12,num_sys12_tf);
den_PD_12=conv(den_KPD_12,den_sys12_tf);
[num_PD_Control_12,den_PD_Control_12]=cloop(num_PD_12,den_PD_12);
sys_tf_PD_12=tf(num_PD_Control_12,den_PD_Control_12)
%Plotting PD control reponse and comparing it with open loop step response
figure
step(sys12_tf,'b--',sys_tf_PD_12,'r')
%Results:
Ramin Shamshiri
Due 30/04/09
Page 26 of 33
%PID control for TF_12
Kp_12=180;% Proportional gain
Kd_12=20; % Derivative gain
Ki_12=250;% Integral gain
num_KPID_12=[Kd_12 Kp_12 Ki_12];%PID TF num
den_KPID_12=[1 0];%PID TF denum
num_PID_12=conv(num_KPID_12,num_sys12_tf);
den_PID_12=conv(den_KPID_12,den_sys12_tf);
[num_PID_Control_12,den_PID_Control_12]=cloop(num_PID_12,den_PID_12);
sys_tf_PID_12=tf(num_PID_Control_12,den_PID_Control_12)
%Plotting PD control reponse:
figure
step(sys12_tf,'b--',sys_tf_PID_12,'r')
%Results:
Ramin Shamshiri
Due 30/04/09
Page 27 of 33
PID control for TF21 ,
Ramin Shamshiri
and TF12 ,
(with noise)
Due 30/04/09
Page 28 of 33
Ramin Shamshiri
Due 30/04/09
Page 29 of 33
LQR Controller
=
where S comes from ARE solution and R=I2x2
-5.6563
0.2774
0.9999
-0.0379
14.6650
-0.6654
4.5643
35.7631
-5.9284
-91.4425
-0.6223
-5.9284
1.0416
15.3398
-10.9368
-91.4425
15.3398
238.0566
S =
1.3101
4.5643
-0.6223
-10.9368
E =
-8.5808
-8.5808
-0.5425
-0.5425
+
+
-
5.3836i
5.3836i
0.6219i
0.6219i
Ramin Shamshiri
Due 30/04/09
Page 30 of 33
Ramin Shamshiri
Due 30/04/09
Page 31 of 33
LQR Controller plus observer
%LQR design with C as in dynamic model
Q=C'*C;
%Checking Controllability and Observability
rank([sqrt(Q);sqrt(Q)*A;sqrt(Q)*(A^2);sqrt(Q)*(A^3)]);
[K,S,E]=lqr(A,B,Q,R)
Ac = [(A-B*K)];
Bc = [B];
Cc = [C];
Dc = [0 0;0 0];
figure
step(Ac,Bc,Cc,Dc,1)
%Observer design
% Finding controller poles
poles = eig(Ac)
P = [-5 -6 -7 -8];
L = place(A',C',P)';
Ace = [A-B*K
B*K;
zeros(size(A)) (A-L*C)];
Bce = [
B;
zeros(size(B))];
Cce = [Cc zeros(size(Cc))];
Dce = [0 0;0 0];
t=0:0.01:12;
figure
step(Ace,Bce,Cce,Dce,1,t);
poles =
-8.5807
-8.5807
-0.5414
-0.5414
+
+
-
5.3833i
5.3833i
0.6228i
0.6228i
Ramin Shamshiri
Due 30/04/09
Page 32 of 33
Ramin Shamshiri
Due 30/04/09
Page 33 of 33
Report:
Two separate PID controllers were designed for two of the four transfer functions of this MIMO
system. The first transfer function TF21 link pitch rate to elevator and the second one, TF12 links
velocity rate to thrust. Root locus was used to pick the gains for PID and the response are shown in
the following figures. Velocity sensor noise and pitch rate sensor noise was implemented in the
simulation process. It can be seen that PID control is not an optimum solution for this MIMO
problem. To enhance the result, LQR design was used and the corresponding gain matrix was
K_1 =
-0.5658
0.0791
Ramin Shamshiri
-5.6563
0.2774
0.9999
-0.0379
14.6650
-0.6654
Due 30/04/09