1. Run the setup rotpen student.m script. The SRV02 and pendulum model parameters are automaticaly loaded loaded using the config srv02.m and config sp.m functions. It then calls the ROPTEN ABCD eqns student.m script to load the model in the Matlab worspace.
% State Representation A = eye(4,4); B = [0;0;0;1]; C = eye(2,4); D = zeros(2,1);
Space
% A act!ator yna"ics B = #$ &t B ' R"; A(,) = A(,) #$*2&t&"'R"B(); A(4,) = A(4,4) #$*2&t&"'R"B(4); syste" = ss(A,B,C,D); The representati!e C and D matrices ha!e already been included. "ou need to enter the state#space matrices A and B that you found in Section 2.2. The actuator dynamics ha!e been added to con!ert your state#space matrices to be in terms of !oltage. Recall that the input of the state#space model you found in Section 2.2 is the tor$ue acting at the ser!o load gear %i.e.& the pi!ot of the pendulum'. (owe!er& we do not contro torque direct! " we contro t#e servo input vot$ge. vot$ge . The abo!e abo!e code uses the !oltage#tor$ue relationship gi!en in )$uation 2.* in Section 2.1.2 to tranform tor$ue to !oltage.
+s gi!en in the R,T-) +/ e$ns.m script& the state#space model is entered as
% State Space Representation +t = +r+p -p(.p'2)*2+r +p-p.r*2; A = [0 0 1 0; 0 0 0 1; 0 -p*2(.p'2) -p*2(.p'2)*2.r$'+t *2.r$'+t Dr(+p-p(.p'2 Dr(+p-p(.p'2)*2)'+t )*2)'+t -p(.p'2).rDp'+t; 0 -p$(.p'2)( -p$(.p'2)(+r-p.r*2)'+t +r-p.r*2)'+t -p(.p'2).rDr'+t Dp(+r-p.r*2)'+t]; B = [0; 0; (+p-p(.p'2 (+p-p(.p'2)*2)'+t; )*2)'+t; -p(.p'2).r'+t]; C = eye(2,4); D = zeros(2,1); % A act!ator yna"ics B = #$ &t B ' R"; A(,) = A(,) #$*2&t&n'RaB(); A(4,) = A(4,4) #$*2&t&n'RaB(4);
The model shown below should ha!e been loaded if they used the cor# rect model parameters %e.g.& correct synta3' and ran the script properly. In Matlab& the model parameters are denoted as Mp& 4p& 4r& 5r& r& 5p& p& and g. If the model was de!eloped and entered properly& they should appear as
A= 0 1/0000 0 0 0 0 0 1/40 10/2 0 122/04 10/20
0 1/000 0/313 1/32
B= 0 0 /43 0/12
C= 1 0
0 1
0 0
0 0
D= 0 0 These matrices indicate that the model of the rotary pendulum has been successfully loaded.
6sing the M+T4+/ command eig%A&& we find that the open#loop poles of the system are #17.1& 8.9*& #2.87& and 0 .
:ill out Table 2 with your answers from your modeling lab results # both simulation and implementation. Description
Symbol
Value
Units 0 1 −0.930 −1.40
State#Space Matri3
+
0 0 1 0 0 0 0 80.3 −10.2 0 122 −10.3
0 0 83.2 80.1
State#Space Matri3
/
[
State#Space Matri3
]
1 0
0 1
0 0
[
State#Space Matri3
,pen#loop poles
,4
0 0
]
0 0
{ #17.1& 8.9*& #2.87& 0 }
Table 2 Results
1.
/ased on your analysis in Section 2.9& is the system stable& marginally stable& or unstable; id you e3pect the stability of the in!erted pendulum to be as what was determined;
The open#loop poles determined in Section 2.9 are #17.1& 8.9*& #2.87& and 0. /ecause one pole is in the right#hand plane& the system is un# stable. This maes sense& as an in!erted pendulum does not stay in!erted by itself # it falls down. 2.
6sing the open#loop poles& find the characteristic e$uation of A.
+s gi!en in Section 9.2.1& the roots of the characteristic e$uation are the open#loop poles.
9.
+
17.1)( s − 8.34)( s
2.87)
+
=
s4 + 11.6 s3 − 117.3 s2 − 408.3 s %+ns.9.1'
.
The open#loop characteristic e$uation has the form s4 + a4 s3 + a3 s2 + a2 s + a1 . :itting the coefficients into the general companion matri3 format gi!en in )$uation 9.2 and )$uation 9.9 0 1 0 0 0 %+ns.9.2' 0 1 0 = A˜ 0 0 0 1 0 408.3 117.3 −11.6 and 0 0 B˜ = 0 1
%+ns.9.9'
*. :ind the location of the two dominant poles& p1 and p2 & based on the specifications gi!en in Section 9.1. -lace the other poles at p3 = −30 and p4 = −40. :inally& gi!e the desired characteristic e$uation.
6sing the pole locations in )$uation 9.= and )$uation 9.10 and the damping ratio and natural fre$uency gi!en in Section 9.1. The components in e$uations 9.= and 9.10 are σ
=
ωd
ζ ωn
=
√
2.80
1 − ζ 2
= ωn
=
2.86
The desired location of the closed#loop poles is −2.80 #*0. The characteristic polynomial is ( s
+
± j 2.86& #90&
2.80 − j 2.86)( s + 2.80 + j 2.86)( s + 30)( s
+
and
40)
=
s4
>.
+
?hen applying the control u
75.6 s3
=
+
1608 s2
+
7840 s
+
%+ns.9.*'
19200
− K ˜ x to the companion form& it changes ( A˜ , B ˜ ) to ( A˜ − B˜
K ˜ , B ˜ ). :ind the gain K ˜ that assigns the poles to their new desired location.
+pplying the control the companion matri3 becomes 0 1 0 0 0 1 0 0 . A˜ − B˜ K ˜ = 0 0 0 1 −k 1 408.3 − k 2 117.3 − k 3 −11.6 − k 4 The characteristic e$uation for this system is s
4
+
(11.6
+
k 4 ) s
3
+
(k 3 − 117.3) s
2
+
(k 2 − 408.3) s
+
k 1 .
)$uating these coefficents of this characteristic polynomial with the de# sired in )$uation +ns.9.* gi!es 11.6 + k 4 = 75.6 k 3 − 117.3 = 1608 k 2 − 408.3 = 7840 k 1
=
19200
Sol!ing for the gains k i
K ˜
=
[19200 8286 1725 64]
%+ns.9.>'
1. Run the setup rotpen student.m script to load the rotary pendulum the model you found in per!ious modeling lab. 2.
6sing Matlab commands& determine if the system is controllable. )3plain why. Answer 3.6 Outcome
Solution :ind the controllability matri3 using the ctr' command and use r$n( to find the ran of that matri3. The resuling command are
5 = ctr6(A,B); ran&(5) The system is controllable because the ran of its controllability matri3 e$uals the number of states& i.e.& rank (T ) = 4 = n. ,pen the d poe p$cement student.m script. +s shown below& the companion matrices A˜ and
9. B˜
for the model are automatically found %denoted as +c and /c in Matlab'.
% C7aracteristic e8!ation9 s*4 a:4s* a:s*2 a:2s a:1 a = poy(A); % % Co"panion "atrices (Ac, Bc) Ac = [ 0 1 0 0; 0 0 1 0; 0 0 0 1; a() a(4) a() a(2)]; % Bc = [0; 0; 0; 1]; % Controa6iity 5 = 0; % Controa6iity o< co"panion "atrices 5c = 0; % 5rans
If the e3perimental procedure is followed correctly& the following results should ha!e been obtained. This code can be used to find transformation matri3 ?
% Controa6iity 5 = ctr6(A,B); % Controa6iity o< co"panion "atrices 5c = ctr6(Ac,Bc); % 5rans(5c);
W
=
0
−3649
See the d pole placement.m script for the full solution. The resulting matrices are −930.7 0 83.5 16989 0 −974.6 80.3 20780 T = 83.5 −930.7 16989 −272898 80.3 −974.6 20780 −323519 0 0 0 1 −11.7 0 0 1 T ˜ = 0 −11.7 253.1 1 1 −11.7 253.1 −3906 −410.4 −117.4 11.7 1 −117.4 11.7 1 0 −1 = T ˜ 11.65 1 0 0 1 0 0 0 −3649 41.8 83.5 0 0 −38.8 0 80.3 41.8 83.5 −38.8 80.3 0 0
*. )nter the companion gain& K ˜ & you found in the pre#lab as )c in d poe p$cement student.m and modify it to find gain K using the transformation detailed in Section 9. Run the script again to calculate the feedbac gain K and record its !alue in Table 9. +s gi!en in the pole#placement procedure in Section 9.2.*& the control gain is found using the e$ua# tion K = K ˜ W −1 . Recall that gain K ˜ was found in )$uation +ns.9.> in Section 9.9. 6sing this& we can find gain K in Matlab using the commands
#c = [ 13200 2 12 4 ]; # = #cin>() This generates the balance control gain K
>.
=
[−5.26 30 .0 − 2.65 3 .55].
%+ns.9.@'
)!aluate the closed#loop poles of the system& i.e.& the eigen!alues of A − B K . Record the closed# loop poles of the system when using the gain K calculated abo!e. (a!e the poles been placed to their desired locations; If not& then go bac and re#in!estigate your control design until you find a gain that positions the poles to the re$uired location.
6sing the Matlab command eig%A"B*)& to find the poles of the closed# loop system we ha!e
?? ei$(AB#) ans = 40/0000 0/0000 2/000 2/i 2/000 2/i The closed#loop poles are at −2.8 the location of the desired poles. @.
± j 2.86& #90&
and #*0& e$ui!alent to
In the pre!ious e3ercises& gain K was found manually through matri3 operations. +ll that wor can instead be done using a pre#defined Compens$tor Design Matlab command. :ind gain K using a Matlab pole#placement command and !erify that the gain is the same as generated before.
The gain can be found using the AacerA or AplaceA commands as follows
% Contro Speci@cations zeta = 0/; n = 4; % .ocation o< o"inant poes aon$ reaais si$"a = zetan; % .ocation o< o"inant poes aon$ i"$ ais (a"pe nat!ra en) D = [si$"a, si$"a, 0, 40]; % Ein contro $ain !sin$ -ata6 poepace"ent co""an # = ac&er(A,B,D); Students may also enter the desired poles directly. See d balance.m for the full code. The gain generated is K
=
[−5.28 30 .14 − 2.65 3.55]
which is the same as found manually in )$uation +ns.9.@.
6se the Matlab AplotA command& you can generate a figure similarly as shown in :igure +ns.9.9. Run the Aplot rotpen bal.mA script after running the A$ rotpen bal.mdlA with the gain found in )$uation +ns.9.@ to plot this response. +lternati!ely& this plot can be generated using the data stored in the d$t$ rotpen '$ t#et$.m$t & d$t$ rotpen '$ $p#$.m$t & and d$t$ rotpen '$ +m.m$t files.
R
EFERENCES B1C /ruce :rancis. )ce1@1= linear systems course notes %uni!ersity of toronto'& 2001. B2C Duanser Inc. ,-ARC -ser $nu$ . B9C Duanser Inc. /R+02 ,-ARC ntegr$tion& 2008. B*C Duanser Inc. /R+02 -ser $nu$ & 200=. B>C Duanser Inc. ,-ARC Comp$ti'iit! T$'e& 2010. B@C Duanser Inc. /R+02 Rot$r! Penduum -ser $nu$ & 2010. B7C Duanser Inc. +otPA, -ser 1uide& 2010. B8C Duanser Inc. SRV02 lab manual using $uarc. 2011. B=C orman S. ise. Contro /!stems Engineering . 5ohn ?iley E Sons& Inc.& 2008.
˚
B10C F. 5. +stro¨m and F. :uruta. Swinging up a pendulum by energy control. 3t# 4AC 5ord Congress& 1==@.
R,T-) ?orboo # Instructor Version
@0