Description
Consider an inverted pendulum balanced on a moving cart. (Figure 1). The cart can
move in the direction d, the pendulum can rotate in the plane.
Figure 1: Inverted pendulum and cart
Let f(t) be force on the cart (N), d(t) cart position (m) and θ(t) the angle of the pendulum (rad). The angle is measured from the vertical up position, with clockwise angles
positive. Hamilton’s Principle can be used to derive the mathematical model, two secondorder differential equations:
(M + m)
¨d(t) +
˙d(t) + mIp
¨θ(t) cos(θ(t)) − m ˙θ
2
(t)Ip sin(θ(t)) = f(t),
mIp cos(θ(t)) ¨d(t) + 4
3
m¨θ(t)I
2
p − mgIp sin(θ(t)) = 0.
Note that viscous damping
˙d(t) has been included in the model. The cart is moved to
balance the pendulum about the vertical. The force f is applied to the cart through voltage
u to a motor so
f(t) = αu(t) − β ˙d(t)
where the second term represents electrical resistance in the motor.
1. Define the state x = (d, θ, ˙d, ˙θ) and write the equations in first-order form
x˙(t) = F(x, u).
Linearize the equations about the upright equilibrium (0, 0, 0, 0), and write the linearized equations in state-space form:
x˙(t) = Ax(t) + Bu(t).
1
2. Find the equilibrium points of the original model and determine whether they are
locally asymptotically stable or unstable.
3. Substitute in the parameter values in Table 1.
4. Show that the linearized system is controllable.
5. Is a short or long pendulum easier to balance? Explain why this would be the case,
with reference to the eigenvalues of the linearized system.
6. Where should you look to make it easier to balance? Speculate briefly on reasons for
this.
7. A linear-quadratic (LQ) controller will be used to stabilize the pendulum. Since there
is only one control, the control weight can be set to R = 1 and the relative weighting
of state and control adjusted by changing Q.
The resulting controller should stabilize
the system with little overshoot so that the system does not leave the region where the
linearization is valid. Also, the control signal should not exceed 5 volts.
Trial and error shows that state weight Q = Q1 where Q1 = diag
5000 3000 20 20
,
which penalizes positions heavily with little cost on the velocities, works well. (Other
choices of Q are of course possible.) Use a Matlab routine such as care or are to solve
the algebraic Riccati equation and hence the LQ-optimal feedback control K1 for the
linear system.
8. Produce plots of the response (d, θ, u) of the controlled linearized system with control
K1 to the initial condition (0, 0.06rad, 0, 0) . (Useful Matlab routines are initial , lsim.
The command subfigure may also be useful. )
9. For state weight Q2 = diag
5000 15000 20 20
, find the corresponding feedback
controller K2. Plot the response (d, θ, u) with the control K2 and the same initial
condition as in step 8. Compare the response to that in step 8.
10. Also design a controller K3, with the state weight Q1, but using a different estimate
for the friction coefficient, = 2.0kg/s.
Produce plots, using the original linearized
plant model, of the response (d, θ, u) of the controlled system with initial condition
(0, 0.06rad, 0, 0). Compare the different plots.
11. For what range of is the linearized plant and state feedback controller K3 stable?
12. The position d(t) and angle θ(t) are measured. Define the appropriate matrix C defining the vector y(t). (The matrix C will be 2 × 4.).
Show that the system is observable.
13. Since the velocities aren’t measured, an estimate of the full state needs to be designed.
This will have the form
dxˆ
dt (t) = Axˆ(t) + L(y(t) − Cxˆ(t)) + Bu(t). (1)
If A − LC is Hurwitz, limt→∞ xˆ(t) = x(t).
2
Parameter Description Value
M cart mass (with weight) 0.815 kg
m pendulum mass 0.210 kg
Ip distance from pivot to pendulum centre of mass 0.305 m
g gravitational constant 9.8 m/s2
α voltage to force conversion factor 1.719 N/V
β electrical resistance 7.682 Ns/m
coefficient of friction 3.86 kg/s
Table 1: Parameter Values
(a) Show that the eigenvalues of A − LC can be placed arbitrarily by choice of L.
(b) Previous experience has shown that chosing L so that the eigenvalues of A − LC
are at −60, −90, −120, −150 works well. Use the Matlab routine place to find L.
14. Make a simulink diagram to simulate the controlled linear system with measurements
d, θ. The controller will be
u(t) = K1xˆ(t)
with estimator (1).
Include a screen shot of your Simulink diagram.
15. Check the diagram by seeing if you obtain the same plots as in step 8 if the initial
condition on the pendulum and the estimator is the same; that is xˆ(0) = x(0).
16. What happens if you put a different initial condition on the estimator than on the
plant?
17. Add an external input to the pendulum and set it to a step. Compare the response of
the plant and the estimated plant. Use the initial conditions from step 16.
18. (*) Repeat steps 14 and 15 with the linear pendulum model replaced by the nonlinear
model. Compare the response with that of the linear system.
19. (*) With the nonlinear model, simulate the system with the controller K3 designed
using the smaller friction coefficient. Discuss the response.
3