0% found this document useful (0 votes)
23 views17 pages

Lab Gantry

gantry analysis

Uploaded by

Honza Krofta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views17 pages

Lab Gantry

gantry analysis

Uploaded by

Honza Krofta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

The control of a gantry

AAE 364L

In this experiment we will design a controller for a gantry or crane. Without a controller
the pendulum of crane will swing for a long time. The idea is to use control to stop the
swinging of the pendulum.
This experiment consists of a cart with mass M on a one dimensional track and a pendu-
lum swinging from the cart. The pendulum is in the downward position. The cart is driven
by a force from a servo motor. The position of the cart is denoted by xc (t), and the Voltage
to the servo motor is denoted by v(t). The angle between the pendulum and its resting
position is denoted by α; see Figure 1. The nonlinear equations of motion are given by
( ) ( )
(Mc + Mp )Ip + Mc Mp lp2 + Mp2 lp2 sin(α)2 ẍc + Ip + Mp lp2 Beq ẋc
( ) ( )
= Mp lp Bp cos(α)α̇ + Mp2 lp3 + Ip Mp lp sin(α)α̇2 + Ip + Mp lp2 Fc + Mp2 lp2 g cos(α) sin(α);

( )
(Mc + Mp )Ip + Mc Mp lp2 + Mp2 lp2 sin(α)2 α̈ + (Mc + Mp ) Bp α̇
= Mp lp cos(α)Beq ẋc − (Mc + Mp ) Mp glp sin(α) − Mp2 lp2 sin(α) cos(α)α̇2 − Mp lp cos(α)Fc ;

ηg Kg ηm Kt (vrmp − Kg Km ẋc )
Fc = 2
. (0.1)
Rm rmp

Here Fc is the force on the cart. The notation and values are given in the table in the
Appendix. These values are given also given in the MATLAB file “setup lab ip02 spg.m”
posted on the Web page for the course. So you will not have to calculate any of these values
for the Lab. The linearized equations of motion are given by
−(Ip + Mp lp2 )Beq ẋc + Mp lp Bp α̇ + Mp2 lp2 gα + (Ip + Mp lp2 )Fc
ẍc =
(Mc + Mp )Ip + Mc Mp lp2
Mp lp Beq ẋc − (Mc + Mp )Bp α̇ − (Mc + Mp )Mp glp α − Mp lp Fc
α̈ =
(Mc + Mp )Ip + Mc Mp lp2
ηg Kg ηm Kt (vrmp − Kg Km ẋc )
Fc = 2
. (0.2)
Rm rmp

Now let us convert the linear equations to a state space model of the form

ẋ = Ax + Bv.

Here A is a 4 × 4 matrix, B is a column vector of length 4 and the input v is the voltage to

1
Figure 1 The Gantry

the motor. To convert the system in (0.2) we used the following state variables:
   
x1 xc
 x2   α 
x=   
 x3  =  ẋc  . (0.3)
x4 α̇

By consulting the values in the table at the end of the section, we computed A and B, that
is,    
0 0 1 0 0
 0 0 0 1   0 
A= 
 0 1.5216 −11.6513 0.0049  and B =  1.5304
 .
 (0.4)
0 −26.1093 26.8458 −0.0841 −3.5261
These matrices A and B are contained in the MATLAB setup file on the Web page, so
you do not have to retype A and B in MATLAB. The eigenvalues of A are given by
{0, −11.3975, −0.1689 + 4.8040i, −0.1689 − 4.8040i}. So A only is marginally stable.
Let us compute the transfer function from the voltage v to the output xc . Since x1 = xc ,
the corresponding output matrix C is given by
[ ]
C= 1 0 0 0 . (0.5)

2
By using ss2tf in MATLAB, we see that the transfer function from the voltage v to the
output xc is given by
Xc (s) 1.53s2 + 0.1114s + 34.59
= C(sI − A)−1 B = 4 . (0.6)
V (s) s + 11.74s3 + 26.96s2 + 263.4s
Xc (s) Xc (s)
Notice that V (s)
has a pole at the origin. Moreover, the poles of V (s)
are the eigenvalues of
A. Finally, it is noted XVc(s)
(s)
is a fourth order system.
Now let us compute the transfer function from the voltage v to the angle α. Since x2 = α,
the corresponding output matrix C is given by
[ ]
C= 0 1 0 0 . (0.7)

By using ss2tf in MATLAB, we see that the transfer function from the voltage v to the
angle α is given by
α(s) −3.526s
= C(sI − A)−1 B = 3 . (0.8)
V (s) s + 11.74s2 + 26.96s + 263.4

Finally, it is noted Vα(s)


(s)
is a third order system.
Let xe denote the position of the end of the pendulum along the track. The position
of the end of the pendulum is given by xe = xc + Lp sin(α) where Lp is the length of the
pendulum; see Figure 1. (Notice that lp is the distance to the center of mass of the pendulum
and Lp is the distance to the end of the pendulum.) For small angles xe ≈ xc + Lp α. Since
x1 = xc , x2 = α and Lp = 0.6413 m, the corresponding output matrix C is given by
[ ]
C = 1 0.6413 0 0 . (0.9)

By using ss2tf in MATLAB we see that the transfer function from the voltage v to the end
of the pendulum xe is given by
Xe (s) −0.7311s2 + 0.1114s + 34.59
= C(sI − A)−1 B = 4 . (0.10)
V (s) s + 11.74s3 + 26.96s2 + 263.4s
Finally, it is noted that this is a fourth order system.

1 Part (i): The natural frequency of the pendulum


In this part we will experimentally determine the natural frequency of the pendulum. For
the moment assume that the cart is fixed to the origin and does not move. However, the
pendulum is free to swing. So assume that the cart is fixed. Then the equation of motion
for the pendulum is given by
( )
Ip + Mp lp2 α̈ + Mp lp g sin(α) = 0. (1.1)

3
The equation of motion is nonlinear. Recall that for small angles, sin(α) ≈ α. Using this we
see that the linearized equation of motion is determined by
( )
Ip + Mp lp2 α̈ + Mp lp gα = 0. (1.2)
Hence the linear equation of motion for the pendulum is given by

Mp lp g
α̈ + ωp2 α = 0 where ωp = . (1.3)
Ip + Mp lp2
Here ωp is the natural frequency of the pendulum. In other words, the pendulum will oscillate
at ωp for small angles. For example, assume that the initial condition are given by α(0) = α0
and α̇ = 0. The the solution to the linear differential equation in (1.3) is given by
α(t) = α0 cos(ωp t). (1.4)
By consulting the table for our experiment (or the corresponding MATLAB setup file) we
see that
ωp = 4.7543 rad/s. (1.5)
So let us verify this number experimentally. Hold the cart still and start the pendulum off
at a small angle α(0) = α0 and α̇ = 0. Record the output of the angle. Then measure the
period τ . We expect the period to be approximately

τ= = 1.3216 s. (1.6)
ωp

1.1 The Lab steps to experimentally determine ωp


(i) Open MATLAB and change the directory to Desktop : \AAE364L\section#\labgantry.
(ii) Run the setup file setup ip02 spg.m .
(iii) Open labgantrywp in Simulink. Select Tools - External Mode Control Panel -
Signal & Triggering, and change the duration to 10,000.
(iv) In the Simulink window, set simulation time to 19 seconds.
(v) In order to properly record your data, open the theta scope and select
Parameters. Deselect the ”Limit to 5000 data points” check-box. Select
Save data to workspace. Enter an appropriate variable name, in this case
theta. Make sure the format is ”Structure with time”.
(vi) Secure the cart at the center of the track.
(vii) Click Quarc - Build. Select Simulation - Connect to Target, and Quarc - Start.
(viii) Move the pendulum about 15 degrees and let it swing.
(ix) After the pendulum swings about ten revolutions, click stop.
(x) Save the angle history in MATLAB (File - Save - Save as Mat file).
(xi) Close the Simulink model, don’t save changes.

4
1.2 In your lab report include the following under Part (i):
(a) Hand in your experimental plot of the angle.
(b) Hand in your calculation of the frequency ωp that you determined from the experiment.

2 Part (ii): The resonance of ωn


In this part we will determine the natural frequency of the entire system with the cart and
pendulum. Then we will excite the cart at its natural frequency to demonstrate resonance.
In other words, we will show that a small sinusoid at the natural frequency will lead to a
large amplitude in the response.
In this part the cart is free to move. Consider the linearized equations of motion in (0.2).
Recall that the transfer function from the voltage v to the angle α is given by the following
third order system:
α(s) −3.526s −3.526s
Gα (s) = = 3 = .
V (s) 2
s + 11.74s + 26.96s + 263.4 (s − λ)(s2 + 2ζωn s + ωn2 )
Compute the natural frequency ωn and the damping ratio ζ for this transfer function Gα (s).
Observe that one can also compute the natural frequency ωn and the damping ratio ζ from the
eigenvalues of A given in (0.4). The eigenvalues of A are 0, −11.3975 and −0.1689 ± 4.8040i.
So using the complex eigenvalues we have
(s + 0.1689 + 4.8040i)(s + 0.1689 − 4.8040i) = s2 + 2ζωn s + ωn2 .
Recall that one can also determine the damping ratio and natural frequency directly from
the Bode plot of Gα (s). So plot the Bode plot of Gα (s) and determine the natural frequency
ωn from the bode plot.
To demonstrate resonance we will excite the system with a sinusoid of the form
v(t) = A sin(ωt). (2.1)
In this case, the steady state response of the linear system is given by
αss (t) = A|Gα (ıω)| sin(ωt + ∠Gα (ıω)). (2.2)
So as the frequency ω ≈ ωn , the pendulum should start to oscillate wildly. Recall that the
actual system is nonlinear. However, our linear approximation will demonstrate resonance.

2.1 Pre-Lab for resonance. Due at the beginning of the lab experiment. You
will not be allowed to run the lab experiment with out a complete pre-lab.
(i) Hand in your values for the damping ratio ζ and natural frequency ωn that you calcu-
lated.
(ii) Hand in the Bode plot of Gα . Determine |Gα (ıω)| from the Bode plot for ω = 3 rad/s,
ωn , and 7 rad/s.

5
2.2 The Lab steps to demonstrate resonance
(i) In the same directory, open labgantryres in Simulink. Select Tools - External
Mode Control Panel - Signal & Triggering, and change the duration to 20,000.
(ii) In the Simulink window, set simulation time to 39 seconds.
(iii) In the MATLAB command window, type X M AX = 0.6; X M IN = −0.6;.
(iv) To properly record your data, repeat Step (v) from Section 1.1 for the angle (theta)
scope.
(v) Place the cart at the center of the track. Set the sinusoid to 3 sin(ωt), that is, set the
amplitude of the sinusoid to be 3. Run the experiment for ω varying from 3 rad/s to
ωn and then 7 rad/s.
(vi) Click Quarc - Build. Select Simulation - Connect to Target, and Quarc - Start.
After about 30 seconds, stop the simulation.
(vii) Save the angle history in MATLAB (File - Save - Save as Mat file) for ω = 3
rad/s, ω = ωn and ω = 7 rad/s.
(viii) Close the Simulink model, don’t save changes.

2.3 In your lab report include the following under Part (ii):
(a) Hand in the values for ωn and ζ that you calculated.
(b) Notice that ωn ≈ ωp . In two short sentences or less explain why ωn ≈ ωp .
(c) Hand in the Bode plot of Gα . Hand in your value for the natural frequency ωn that you
computed from the Bode plot. In two short sentences or less explain how you computed
ωn from the Bode plot.
(d) Hand in your plots of the angle from the experiment for ω = 3 rad/s, ω = ωn and ω = 7
rad/s. What happens when the frequency ω = ωn ?
(e) Compute |Gα (ıω)| from the Bode plot of Gα and from the experimental results for
ω = 3 rad/s, ω = ωn and ω = 7 rad/s.

3 Part (iii): Pole placement


In this section we will use pole placement to control the oscillations of the pendulum. Con-
sider the state space system given by

ẋ = Ax + Bv and y = Cx. (3.1)

6
The input is v, the output is y and the vector x is the state. Here A is a n × n matrix, B is
a column vector of length n, the state x is a vector of length n and C is the row vector of
length n given by
     
a11 a12 · · · a1n b1 x1
 a21 a22 · · · a2n   b2   x2 
A =   ... .. .. 
 , B=  .. 
 and x =   .. 
. ··· . . . 
an1 an2 · · · ann bn xn
[ ]
C = c1 c2 · · · cn . (3.2)

Recall that the solution to the state space system in (3.1) is given by
∫ t
At
x(t) = e x(0) + eA(t−σ) Bv(σ)dσ
0
∫ t
At
y(t) = Ce x(0) + CeA(t−σ) Bv(σ)dσ. (3.3)
0

The transfer function from the input v to the output y is given by


Y (s)
= G(s) = C(sI − A)−1 B. (3.4)
V (s)
Recall that the characteristic polynomial for A is defined by det[sI − A] where det denotes
the determinant. In particular, the the zeros of the characteristic polynomial det[sI − A] are
the eigenvalues of A. By using the appropriate minors to compute the inverse of sI − A, it
follows that the transfer function
q(s)
G(s) = C(sI − A)−1 B = (3.5)
det[sI − A]
where q is a polynomial of degree at most n−1. In particular, the poles of G(s) are contained
in the set of all eigenvalues for A. Finally, it is noted that the open loop system G is stable
if all the eigenvalues of A are contained in the open left half plane {s : ℜs < 0}.
We say that K is a state feedback gain or state feedback vector if K is a row vector of
length n, that is, [ ]
K = k1 k2 · · · kn . (3.6)
The reference signal r associated with the state feedback vector K is given by

n
v(t) = r(t) − Kx(t) = r(t) − kj xj (t). (3.7)
j=1

Substituting this v into ẋ = Ax + Bv yields the following state variable feedback system:

ẋ = (A − BK) x + Br and y = Cx. (3.8)

7
The solution to the state space feedback system in (3.8) is given by
∫ t
(A−BK)t
x(t) = e x(0) + e(A−BK)(t−σ) Br(σ)dσ
0
∫ t
(A−BK)t
y(t) = Ce x(0) + Ce(A−BK)(t−σ) Br(σ)dσ. (3.9)
0

The transfer function from the reference signal r to the output y is given by
Y (s)
= GK (s) = C (sI − (A − BK))−1 B. (3.10)
R(s)
Notice that the closed loop transfer function GK (s) depends upon the choice of the feedback
gain K. The characteristic polynomial for A − BK is defined by det[sI − (A − BK)]. By
using the appropriate minors to compute the inverse of sI − (A − BK), it follows that the
closed loop transfer function from the reference signal r to the output y is given by
q(s)
GK (s) = C(sI − (A − BK))−1 B = (3.11)
det[sI − (A − BK)]
where q is a polynomial of degree at most n − 1. In particular, the poles of the closed loop
system GK (s) are contained in the set of all eigenvalues for A − BK. Finally, it is noted
that the closed loop system GK is stable if all the eigenvalues of A − BK are contained in
the open left half plane {s : ℜs < 0}.
Recall that the poles of the closed loop system depend upon the choice of the feedback
gain K. The eigenvalues of the closed loop system in (3.8) are determined by the eigenvalues
of A−BK. Our feedback strategy is to pick the state feedback gain K to place the eigenvalues
of A − BK at n specified locations {λj }n1 in the open left hand plane {s : ℜs < 0}. In this
case, the closed loop system GK is stable. Moreover, if the reference signal r set to zero,
then the solution of the feedback system (3.8) converges to zero, that is,

x(t) = e(A−BK)t x(0) → 0.

So by choosing the state feedback vector appropriately, one can force the state to zero.
Moreover, by placing the eigenvalues of A − BK at n specified locations {λj }n1 in the open
left hand plane {s : ℜs < 0} one can dictate how the state x converges to zero. Finally,
it is noted that in order to implement state variable feedback, one needs an actuator or an
instrument to to read all the states {xj }n1 .
Consider the state space system in (3.1) or a pair of matrices {A, B} where A is a n × n
matrix and B is a column vector of length n. The controllability matrix W associated with
the pair {A, B} is the n × n matrix defined by
[ ]
W = B AB A2 B A3 B · · · An−1 B . (3.12)

The state space system in (3.1) or the pair {A, B} is controllable if its controllability matrix
W is invertible, or equivalently, the rank of W equals n. We will use the following result to
control the pendulum swing in our gantry problem.

8
THEOREM 3.1 Consider the state space system

ẋ = Ax + Bv (3.13)

where A is a n × n matrix and B is a column vector of length n. Assume that the pair
{A, B} is controllable. Let {λj }n1 any set of distinct complex numbers. Then there exists a
state feedback vector K such that {λj }n1 are the eigenvalues of A − BK. In particular, the
poles of the feedback system GK are contained in {λj }n1 , that is,

q(s)
GK (s) = C(sI − (A − BK))−1 B = . (3.14)
(s − λ1 )(s − λ2 ) · · · (s − λn )
Finally, this state feedback gain K can be computed by using the place command in MATLAB,
that is, ( [ ])
K = place A, B, λ1 λ2 · · · λn . (3.15)

The Gantry Design Problem. If one hits the pendulum, then the pendulum will oscillate
for a long period of time. Your Prelab assignment is to design a controller to make the
pendulum stop oscillating in 2.2 seconds or less. Bring you control design to the Lab. Then
the TA will tap the pendulum to see if your design works.
One method to design a feedback controller is to consider what happens for transfer
functions F of the form
ωn2
F (s) = 2 . (3.16)
s + 2ζωn s + ωn2
Let P O denote the percent overshoot and ts the settling time due to a step. Then it is well
known that if the natural frequency ωn and ζ are given by
|ln (P O/100)| 4
ζ=√ and ωn = . (3.17)
ts ζ
ln (P O/100)2 + π 2

Then the response of the transfer function F due to a step has the desired percent overshoot
P O and settling time ts . For our problem let us choose P O = 5 and ts = 2.2 s. Hence

ζ = 0.6901 and ωn = 2.6346 rad/s. (3.18)

So if ζ = 0.6901 and ωn = 2.6346 rad/s for the transfer function F in (3.16), then the
response due to a step will have a 5% percent overshoot and a settling time of 2.2 seconds.
The poles λ1 and λ2 of F corresponding to ζ = 0.6901 and ωn = 2.6346 rad/s are given by
solving for the roots of

s2 + 2ζωn s + ωn2 = s2 + 3.6364s + 6.9413 = (s − λ1 )(s − λ2 ).

Therefore the poles of F corresponding to ζ = 0.6901 and ωn = 2.6346 rad/s are given by

λ1 = −1.8182 + 1.9067i and λ2 = −1.8182 − 1.9067i. (3.19)

9
Notice that our state space linear approximation for the cart and pendulum in (0.2) is
fourth order. Moreover, the pair {A, B} in (0.4) is controllable. Now let {λj }41 be any
four distinct complex numbers in the open left half plane {s : ℜs < 0}. Then one can use
the place command in MATLAB to find a state feedback gain K such that {λj }41 are the
eigenvalues of A − BK, that is,
[ ] [ ]
K = k1 k2 k3 k4 = place (A, B, λ1 λ2 λ3 λ4 ) (3.20)

For this choice of K the closed loop system is given by


q(s)
GK (s) = C(sI − (A − BK))−1 B = . (3.21)
(s − λ1 )(s − λ2 )(s − λ3 )(s − λ4 )
[ ]
Here C = c1 c2 c3 c4 can be any matrix. For example, C can be the matrix any one
of the matrices in (0.5), (0.7) or (0.9).
Notice that the closed loop transfer function in (3.21) is not in the same
[ form as F in]
(3.16). However, we can use state feedback to find a state gain vector k = k1 k2 k3 k4
to place the poles {λj }41 of GK at any four locations that we want. So our design procedure
is to place two poles at λ1 = −1.8182 + 1.9067i and λ2 = −1.8182 − 1.9067i which achieve a
5% overshoot and 2.2 seconds settling time for F . Then place the other two poles λ3 and λ4
on the real line far away from −1.8182 ± 1.9067i. In this way we hope to mimic the response
of the transfer function F due to a step. In the first part our experiment we will not be
exciting the cart by a step, we will just tap the pendulum to see how it responds.
For your pre-lab use the place command in MATLAB to place four poles {λj }41 where
λ1 = −1.8182 + 1.9067i and λ2 = −1.8182 − 1.9067i while λ3 and λ4 are on the real line and
far away from −1.8182 ± 1.9067i. Now go to the course Web page (Blackboard) and load
the following MATLAB files in your computer:
• setup lab ip02 spg.m • SPG ABCD eqns.m
• setup ip01 2 configuration.m • d ip02 spg pp.m
• setup sp configuration.m • s spg pp.mdl
Run the MATLAB file “setup lab ip02 spg.m” and open the Simulink file “s spg pp.mdl”.
The Simulink model is displayed in Figure 2. In this Simulink file set the amplitude in the
position set point block to zero. All the variables that you need to run the simulation are now
loaded in the computer. The computer contains all the values in the Table in the Appendix.
In MATLAB set the following initial conditions:
 
0
 0 
X0 =   0 .
 (3.22)
π/2

This sets the initial conditions xc (0) = 0 m, ẋc (0) = 0 m/s, α(0) = 0 rad and the initial
angle angular velocity to α̇(0) = π/2 rad/s. These initial conditions are set to simulate

10
someone hitting the pendulum with α̇(0) = π/2 rad/s and α(0) = 0 rad. Here we want to
see how our controller will respond when the pendulum is struck with an angular velocity of
α̇(0) = π/2
[ rad/s while
] the pendulum is a rest. To simulate the pendulum with no control
set K = 0 0 0 0 in MATLAB. Then run the Simulink file and save the angle plot to
hand in later. Make sure that the amplitude in the position set point block is set equal to
zero.

SPG−plus−IP02 System Simulation:


Pole Assignment

xc_des

Control Effort:
Position Setpoint (m) Vm (V) xc (m) X_eom

alpha (rad)
u = Vm
30e−3 K(1) Vm (V)
xc_dot (m/s) Scopes
Position Setpoint UPM Voltage
Setpoint Amplitude (m) Saturation alpha_dot (rad/s)
SPG + IP02:
Non−Linear EOM

Y = X = [ xc; alpha; xc_dot; alpha_dot ]


K* u

State−Feedback Gain

Figure 2: The closed loop nonlinear model.

Now you can use this Simulink file to design a feedback control with the place command.
To accomplish this choose the poles λ3 and λ4 that you deem appropriate. Then in MATLAB
type
[ ]
K = place (A, B, −1.8182 + 1.9067i −1.8182 − 1.9067i λ3 λ4 ). (3.23)

Then K will be a vector of length 4 which is the state feedback gain used in the Simulink file.
Now run the Simulink file and check out the various scopes to see if you like the response.
Then vary {λj }41 until you achieve the response that meets the design objective. You do not
have to choose λ1 = −1.8182+1.9067i and λ2 = −1.8182−1.9067i. This is just a suggestion.
You can choose {λj }41 to have any value that you want as long as the angle stops moving in
under 2.2 seconds. Save the angle plot for your best values of K. Then plot this angle on
the same plot with K = 0. Bring your best value of the state feedback gain K to the Lab
with you. For your pre-lab also bring your plot of the angle α for your best feedback gain
and no feedback K = 0 on the same plot. Finally, it is noted that K cannot be infinitely
large, that is, |K(j)| ≤ 200 for all j.

11
3.1 Pre-Lab for pole placement. Due at the beginning of the lab experiment.
You will not be allowed to run the lab experiment with out a complete
pre-lab.
(i) Hand in your best values for the state gain K that you computed from Simulink.
(ii) Hand in the graph of the angle α for your best choice of the feedback gain K and the
graph of the angle α for no control K = 0 on the same plot for 15 seconds.

3.2 The Lab steps to pole placement


(i) In MATLAB, enter your best values of K from your Simulink design, that is, set
[ ]
K = K(1) K(2) K(3) K(4) .

(ii) In the same directory, open labgantrypp in Simulink. Select Tools - External Mode
Control Panel - Signal & Triggering, and change the duration to 10,000.
(iii) In the Simulink window, set simulation time to 19 seconds.
(iv) To properly record your data, repeat Step (v) from Section 1.1 for the angle (theta)
scope.
(v) Click Quarc - Build. Select Simulation - Connect to Target, and Quarc - Start.
(vi) Have the TA tap the pendulum. After about 10 seconds hit the stop button.
(vii) If you are not happy with your response you can change the values of K, and run the
experiment again. Note that you can only do this because it can be done cheaply.
(viii) For your best run, save the angle history in MATLAB (File - Save - Save as Mat
file). Close the Simulink model, don’t save changes.

3.3 In your lab report include the following under Part (iii):
(a) Hand in the best values for the state gain K that you calculated using Simulink, along
with the the time it takes for the pendulum to stop swinging after it is given initial
angular velocity α̇(0) = π/2 rad/s.
(b) Hand in the best values for the state gain K that you used in the experiment.
(c) From the plot of the angle from the experiment, determine the initial angular velocity
after you tapped the pendulum. Using the best values for the state gain K that you
used in the experiment, simulate your system in Simulink with this initial condition of
angular velocity. Hand in your plot of the angle from your best experiment. Compare
that with the plot of the angle from your simulation using your best values for the state
gain K.
(d) Is your simulation accurate? Use your simulation to estimate the time it takes for the
pendulum to stop swinging after given initial angular velocity α̇(0) = π/2 rad/s.

12
4 Integral control of the gantry
In this section we will add an integral control to move the pendulum to various positions on
the track. Our design objective is to move the cart and pendulum 0.5 meters on the track
and have the pendulum stop moving as soon as possible. The idea behind our design is to
incorporate an integral controller in our pole placement method. To this end, consider the
four dimensional state variable system in (0.3). Now let us define a new state variable
∫ t
x5 = (u(σ) − x1 (σ)) dσ or equivalently ẋ5 = u − x1 . (4.1)
0

Here u is the new input. Recall that x1 is the position of the cart. In our problem u will be
a constant. So x5 will be the integral between the reference signal u and the position of the
cart. Using ẋ5 = u − x1 , we may write a new state space system as
          
ẋ1 0 x1 b1 0
ẋ2   0 x2  b2  0
   A        
ẋ3  =  0 x3  + b3  v + 0 u (4.2)
        
ẋ4   0  x4  b4  0
[ ]
ẋ5 −1 0 0 0 0 x5 0 1

Now let us define the new state matrix Ai and Bi , that is,
    
0 b1
 0 [ ] b2 
 A    
Ai =  0 and Bi = B = b3 
  0  
  b4 
[ ] 0
−1 0 0 0 0 0
   
xc 0
 α   
  0
x =   ẋc  and D = 0 .
  
 α̇  0

(u − xc ) 1

Our new state space system is given by

ẋ = Ai x + Bi v + Du. (4.3)

Using the matrices A and B in (0.4) one can easily construct Ai , Bi and D in MATLAB.
Recall that you already have A and B in MATLAB once you run “setup lab ip02 spg.m”.
So in MATLAB Ai and Bi are given by

Ai = [A, zeros(4, 1); −1, 0, 0, 0, 0]


Bi = [B; 0] .

Finally, it is noted that Ai is a 5 × 5 matrix and Bi is a column vector of length 5.

13
It turns out that the pair {Ai , Bi } is controllable. So one can use the place command in
MATLAB to place the eigenvalues of Ai − Bi K at any five distinct locations {λj }51 in the
open left half plane {s : ℜs < 0}. Substituting v = −Kx into the new state variable system
(4.3), we arrive at
ẋ = (Ai − Bi K) x + Du. (4.4)
Now choose u to be the step u(t) = u0 for all t ≥ 0. Because all the eigenvalues of A are
in the open left half plane, the state space system in (4.4) will move to steady state, that
is, ẋ = 0 in steady state. In particular, 0 = ẋ5 = u0 − x1 . In other words, in steady state
x1 = u0 , and the cart will move to the position u0 on the track.
Now we would like to design a controller to move the gantry to position u0 = 0.5 meters
on the track and have the system settle down in under 2.2 seconds. To accomplish this
choose five poles {λj }51 that you deem appropriate. Then in MATLAB type
[ ]
K = place (Ai , Bi , λ1 λ2 λ3 λ4 λ5 ). (4.5)

Then K will be a vector of length 5 which is the state feedback gain used in the Simulink file.
One could use λ1 = −1.8 + 1.9i and λ2 = −1.8 − 1.9i and choose the three remaining poles
far away to try to maintain a 5% overshoot and 2.2 seconds settling time. However, this
choice of λ1 and λ2 is not necessary and you may find a much better choice for your poles.
Your design problem is to try to design a controller which will move the pendulum and the
cart 0.5 meters down the track and have the pendulum settle down as fast as possible. You
can use the Simulink file “aae364gantry2.mdl” on the website or simply rebuild the Simulink
file “s spg pp.mdl” to match that given in Figure 2. To test your design, set the step to 1
and slider gain to 0.5 meters. Then choose the poles {λj }51 that you think will work and run
place in MATLAB. Finally, run the Simulink file in Figure 3. Keep changing the closed loop
poles {λj }51 until you find the state feedback gain which matches the design specifications.
Bring your best gain matrix K to the Lab.

position
180/pi

Control Effort convert


xc (m) degree angle

alpha (rad)
0.5 1 K(5) Vm (V)
s xc_dot (m/s)
Step Slider Integrator UPM Voltage
Gain Saturation alpha_dot (rad/s)
SPG + IP02:
Non−Linear EOM

[ xc; alpha; xc_dot; alpha_dot ]


K*u

State−Feedback Gain

Figure 3: The closed loop nonlinear model.

14
4.1 Pre-Lab for the integral controller. Due at the beginning of the lab ex-
periment. You will not be allowed to run the lab experiment with out a
complete pre-lab.
(i) Hand in your best values for the state gain K that you computed from Simulink.
(ii) Hand in the graph of the cart position xc and the angle α for your best choice of the
feedback gain K, along with the settling time of α.

4.2 The Lab steps to integral control


(i) In MATLAB command window, enter your best values of K from your Simulink design,
that is, set [ ]
K = K(1) K(2) K(3) K(4) K(5) .
Make sure X M AX is set to 0.6.
(ii) In the same directory, open up labgantryint in Simulink. Select Tools - External
Mode Control Panel - Signal & Triggering, and change the duration to 10,000.
(iii) In the Simulink window, set simulation time to 19 seconds.
(iv) To properly record your data, repeat Step (v) from Section 1.1 for the angle (theta)
scope and the cart position (x) scope.
(v) Set the Step (final value) to 1, connect it to Slider Gain A (disconnect Pulse Generator
first, if necessary), and set Slider Gain A to 0.5.
(vi) Put the cart and pendulum at the left end of the track.
(vii) Click Quarc - Build. Select Simulation - Connect to Target, and Quarc - Start.
(viii) If you are not happy with your response you can change the values of K, and run the
experiment again.
(ix) For your best run, save the cart position and angle history in MATLAB (File - Save
- Save as Mat file).
(x) You will now test your response using a pulse input. Place the cart 20 cm from the left
of the track. Disconnect the Step block from Slider Gain A and replace the connection
with a Pulse Generator. Set the Amplitude to 1, the Period to 10, and the Pulse Width
to 50%. Set the duration in Signals and Triggering to 20,000, and simulation time
to 39 seconds. Now start the experiment (Build, Connect to Target, Start) and
observe the cart movement. Save the cart position and angle history in MATLAB.
(xi) Close the Simulink model, don’t save changes.

15
4.3 In your lab report include the following under Part (iv):
(a) Hand in the best values for the state gain K that you calculated using Simulink, along
with settling time of the pendulum.
(b) Hand in the best values for the state gain K that you used in the experiment, along
with settling time of the pendulum.
(c) Simulate your system using the best values for the state gain K that you used in the
experiment. Hand in your plots of the cart position from the experiment and the
simulation on the same figure. In a separate figure, hand in your plots of angle from
the experiment and the simulation.

16
5 Appendix: The notation for the pendulum and cart

Symbol Description Value Unit


Rm motor armature resistance 2.6 Ω
Lm motor armature inductance 0.18 mH
Kt motor torque constant 0.00767 N.m/A
ηm motor efficiency 100% %
Km back-electromotive-force(EMF) constant 0.00767 V.s/rad
Jm rotor moment of inertia 3.9 × 10−7 kg.m2
Kg planetary gearbox ratio 3.71
ηg planetary gearbox efficiency 100% %
Mc2 cart mass 0.57 kg
Mw cart weight mass 0.37 kg
Mc total cart weight mass including motor inertia 1.0731 kg
Beq viscous damping at motor pinion 5.4000 N.s/m
Lt track length 0.990 m
Tc cart travel 0.814 m
Pr rack pitch 1.664 × 10−3 m/tooth
rmp motor pinion radius 6.35 × 10−3 m
Nmp motor pinion number of teeth 24
rpp position pinion radius 0.01482975 m
Npp position pinion number of teeth 56
KEP cart encoder resolution 2.275 × 10−5 m/count
Mp long pendulum mass with T-fitting 0.230 kg
Mpm medium pendulum mass with T-fitting 0.127 kg
Lp long pendulum length from pivot to tip 0.6413 m
Lpm medium pendulum length from pivot to tip 0.3365 m
lp long pendulum length: pivot to center of mass 0.3302 m
lpm medium pendulum length: pivot to center of mass 0.1778 m
Jp long pendulum moment of inertia ⟳ center of mass 7.88 × 10−3 kg.m2
Jpm medium pendulum moment of inertia ⟳ center of mass 1.20 × 10−3 kg.m2
Bp viscous damping at pendulum axis 0.0024 N.m.s/rad
g gravitational constant 9.81 m/s2

17

You might also like