Control 2
Control 2
Control 2
% State Space
Representation
A = eye(4,4);
B = [0;0;0;1];
C = eye(2,4);
D = zeros(2,1);
% Add actuator
dynamics
B = Kg * kt * B / Rm;
A(3,3) = A(3,3) - Kg^2*kt*km/Rm*B(3);
A(4,3) = A(4,4) - Kg^2*kt*km/Rm*B(4);
system = ss(A,B,C,D);
The representative C and D matrices have already been included. You need to enter the state-space
matrices A and B that you found in Section 2.2. The actuator dynamics have been added to convert your
state-space matrices to be in terms of voltage. Recall that the input of the state-space model you found in
Section 2.2 is the torque acting at the servo load gear (i.e., the pivot of the pendulum). However, we do not
control torque directly - we control the servo input voltage. The above code uses the voltage-torque
relationship given in Equation 2.4 in Section 2.1.2 to tranform torque to voltage.
0 0 1.0000 0
0 0 0 1.000
0 81.4033 -10.2536 0
-0.9319
0 122.054 -10.3320 -1.3972
5
B=
0
0
83.4659
-80.3162
C=
1 0 0 0
0 1 0 0
D=
0
0
These matrices indicate that the model of the rotary pendulum has
been successfully loaded.
Using the MATLAB command eig(A), we find that the open-loop poles
of the system are -17.1, 8.34, -2.87, and 0.
Fill out Table 2 with your answers from your modeling lab results - both simulation and implementation.
0 0 1 0
0 0 0 1
State-Space Matrix A
0 80.3 10.2 0.930
0 122 10.3 1.40
0
0
State-Space Matrix B
83.2
80.1
[ ]
1 0 0 0
State-Space Matrix C
0 1 0 0
[ ]
0
State-Space Matrix D
0
Table 2: Results
1. Based on your analysis in Section 2.3, is the system stable, marginally stable, or unstable? Did
you expect the stability of the inverted pendulum to be as what was determined?
The open-loop poles determined in Section 2.3 are -17.1, 8.34, -2.87,
and 0. Because one pole is in the right-hand plane, the system is un-
stable.
This makes sense, as an inverted pendulum does not stay inverted by
itself - it falls down.
(Ans.3.3)
0
0
B =
0
1
4. Find the location of the two dominant poles, p1 and p2 , based on the specifications given in
Section
3.1. Place the other poles at p3 = 30 and p4 = 40. Finally, give the desired characteristic equation.
Using the pole locations in Equation 3.9 and Equation 3.10 and the
damping ratio and natural frequency given in Section 3.1.
The components in equations 3.9 and 3.10 are
= n
= 2.80
d = n 1 2 = 2.86
The desired location of the closed-loop poles is 2.80 j2.86, -30, and
-40. The characteristic polynomial is
Answer 3.6
Outcome Solution
Find the controllability matrix using the ctrb command and use rank to
find the rank of that matrix. The resuling command are:
T = ctrb(A,B);
rank(T)
3. Open the d pole placement student.m script. As shown below, the companion matrices A and
B
for the model are automatically found (denoted as Ac and Bc in Matlab).
In order to find the gain K , we need to find the transformation matrix W = T T 1 (note: T is denoted as Tc
in Matlab). Modify the d pole placement student.m script to calculate the controllability matrix T , the
companion controllabilty matrix T c, the inverse of T c, and W . Show your completed script and the resulting
T , T c, T c1 , and W matrices.
If the experimental procedure is followed correctly, the following results
should have been obtained.
This code can be used to find transformation matrix W:
% Controllability
T = ctrb(A,B);
% Controllability of companion matrices
Tc = ctrb(Ac,Bc);
% Transformation matrices
W = T*inv(Tc);
See the d pole placement.m script for the full solution. The resulting
matrices are:
0 83.5 930.7 16989
0
80.3 974.6 20780
T =
83.5 930.7 16989 272898
80.3 974.6 20780 323519
0 0 0 1
T = 0 0 1 11.7
0 1 11.7 253.1
1 11.7 253.1 3906
410.4 117.4 11.7 1
117.4 11.7 1 0
T1 =
11.65 1 0 0
1 0 0 0
3649 41.8 83.5 0
0 38.8 80.3 0
W 0= 3649 41.8 83.5
0 0 38.8 80.3
4. Enter the companion gain, K , you found in the pre-lab as Kc in d pole placement student.m and modify it
to find gain K using the transformation detailed in Section 3. Run the script again to calculate the feedback
gain K and record its value in Table 3.
As given in the pole-placement procedure in Section 3.2.4, the control gain is found using the
equa- tion K = K W 1 . Recall that gain K was found in Equation Ans.3.5 in Section 3.3.
Using this, we can find gain K in Matlab using the commands:
Kc = [ 19200 8286 1725 64
]; K = Kc*inv(W)
This generates the balance control gain
5. Evaluate the closed-loop poles of the system, i.e., the eigenvalues of A BK . Record the
closed- loop poles of the system when using the gain K calculated above. Have the poles been placed to
their desired locations? If not, then go back and re-investigate your control design until you find a gain that
positions the poles to the required location.
Using the Matlab command eig(A-B*K) to find the poles of the closed-
loop system we have:
>> eig(A-B*K)
ans =
-40.0000
-30.0000
-2.8000 + 2.8566i
-2.8000 - 2.8566i
The closed-loop poles are at 2.8 j2.86, -30, and -40, equivalent to
the location of the desired poles.
6. In the previous exercises, gain K was found manually through matrix operations. All that work can
instead be done using a pre-defined Compensator Design Matlab command. Find gain K using a Matlab
pole-placement command and verify that the gain is the same as generated before.
The gain can be found using the 'acker' or 'place' commands as follows:
% Control Specifications
zeta = 0.7;
wn = 4;
% Location of dominant poles along real-axis
sigma = zeta*wn;
% Location of dominant poles along img axis (damped natural freqency)
wd = wn*sqrt(1-zeta^2);
% Desired poles (-30 and -40 are given)
DP = [-sigma+j*wd, -sigma-j*wd, -30, -40];
% Find control gain using Matlab pole-placement command
K = acker(A,B,DP);
Students may also enter the desired poles directly. See d balance.m
for the full code. The gain generated is
EFERENCES
[1] Bruce Francis. Ece1619 linear systems course notes (university of toronto), 2001.
[2] Quanser Inc. QUARC User Manual.
[10] K. J. Astro m and K. Furuta. Swinging up a pendulum by energy control. 13th IFAC World Congress,
1996.
ROTPEN Workbook - Instructor Version 60