Download Cart-Pendulum System: Nonlinear Model, Equations of Motion, Controller Design and more Study Guides, Projects, Research Electrical and Electronics Engineering in PDF only on Docsity!
ECE360 System Modeling and Control
Design Project
Due: Monday, December 10, 2007
I. System Description
The IP-02 inverted pendulum from Quanser Consulting, Inc., consists of a motor-driven cart
which is equipped with two encoders. One encoder measures the position of the cart via a pinion
which meshes with the track. The other encoder measures the angle of the pendulum which is
free to swing in front of the cart. The objective of this project is to design a controller that starts
with the pendulum in the “down” position then swings it up and maintains it upright. Thus, the
desired controller has two parts: a “swing-up” controller which will oscillate the cart until it has
built up enough energy in the pendulum that it is almost upright. (This controller will be
provided for your project.) When the pendulum is almost upright, a “balance” controller is turned
on and is used to maintain the pendulum vertical. You need to design this stabilizing controller
subject to several transient specifications.
II. Nonlinear Model
Figure 1: Simplified Picture of Cart-Pendulum System
The equations of motion for the cart-pendulum system shown in Figure 1 can be derived from
the Euler-Lagrange equations
F
x
L
x
L
dt
d
.
.
L L
dt
d
where
x
: Cart position (m)
: Pendulum angle (rad)
F
: Input force to the cart (N)
p
M
: Mass of pendulum rod (kg)
c
M
: Mass of cart (kg)
L : Length of rod (m)
g
: Gravitational constant (g = 9.81 m/s
2
and
L
is the Lagrangian of the system defined as
L T V (3)
where T is the total kinetic energy of the system and V is the total potential energy of the
system. According to the referential system in Figure 1, the total kinetic energy T of the
system is
.
2
.
2
.
2
T M x M r J
c p p
and the total potential energy of the system is
cos
p
L
V M g
and where
p
r
: Position of the center of gravity of the pendulum (m) in the chosen referential
p
M
: Mass of pendulum rod (kg)
c
M
: Mass of cart (kg)
J
: Mass moment of inertia of pendulum rod around its center of gravity (kg-m
2
g
: Gravitational constant (g = 9.81 m/s
2
The mass moment of inertia J of a slender rod of length L and mass M
p
with respect to an axis
perpendicular to the rod and passing through the center of gravity is
2
J M L
p
Assignment I :
Using the following kinematic equations,
sin
L
x x
p
cos
L
y
p
is transmitted as a force F to the cart via the pinion,
r
T
F
From the above motor equations, we obtain an expression of the force F as
v
R r
K K
E
R r
K K
F
m
m g
m
m g
2
2 2
Since the actual system is voltage driven, we replace the force F with the voltage E to obtain the
following linearized system
E
M M LR r
K K
M M R r
K K
v
x
M M LR r
K K
M M L
M M g
M M R r
K K
M M
M g
v
x
c p m
m g
c p m
m g
c p m
m g
c p
c p
c p m
m g
c p
p
( 4 )
6
( 4 )
4
0
0
0
( 4 )
6
( 4 )
6 ( )
0
0
( 4 )
4
( 4 )
3
0
0 0 0 1
0 0 1 0
2
2 2
2
2 2
Table 1: System Parameters
Parameter Symbol Value Units
Motor Torque Constant Km 0.00767 N-m/A
Motor Armature Resistance Rm 2.6 W
Gearbox Ratio Kg 3.
Motor Pinion Radius r 0.00635 m
Cart Mass Plus Additional Weight Mc 0.815 kg
Pendulum Actual Length L 0.61 m
Pendulum Mass Mp 0.210 kg
Gravitational Constant g 9.81 m/s 2
After substituting the parameter values in Table 1, the following linear system is obtained:
E
v
x
v
x
Assignment III :
Find the eigenvalues of the system matrix (open-loop system) using either the MATLAB
functions “eig” or “damp” and explain why that the equilibrium point
( , , , ) ( 0 , 0 , 0 , 0 )
x v
is unstable.
III. Control System Design
Assignment IV : Design a state feedback controller
1 2 3 4
E K x K K v K
to stabilize the inverted pendulum. The coefficients K
1
-K
4
are positive numbers. Design the four
controller parameters to meet the following design objectives:
1. The system must be stabilizable for an initial pendulum angle of 10 degrees and all other
initial conditions zero.
2. The cart position should remain within
25 cm of the center of the track at all times.
3. The pendulum angle should stabilize in two seconds or less (settling time of 2 seconds or
less).
4. The pendulum angle should be stabilized with two oscillations or less (transient
frequency equal or greater than
rad/s).
5. The output voltage of the amplifier should not saturate and its output must remain within
the range of - 5 to +5 volts.
Submit your final design parameters as well as plots showing that you have met all
specifications. Once you have designed a suitable linear controller as shown in Appendix II,
simulate the linear system together with the saturation nonlinearity representing the voltage
amplifier. This final check will ensure that your linear controller will still work when you
reintroduce the nonlinearity due to amplifier saturation.
IV. Nonlinear Simulation
Assignment V:
(a) Using Simulink, simulate the original nonlinear differential equations using the linear
controller you designed. The pendulum angle should have an initial angle (0) = 10° = /18 rad
and the other three states should start at their equilibrium values x(0) = v(0) = (0) = 0. Compare
the nonlinear angle response μ(t) with the linear response from Part III.
(b) Find the maximum initial angle (positive and negative) for which the system is stable.
Appendix I
Example of Controller Design Using Pole Placement
Consider a system expressed in state variable form as
.
x Ax Bu t
with an n x n open-loop system matrix A and a single input u(t). If we assume that all state are
measurable, we search for a feedback controller of the form
u Kx
The closed-loop system becomes
x A BK x A x
c
.
where
A ( A BK )
c
is the closed-loop system matrix. We seek to design a state feedback
controller given by (2) such that the closed-loop dynamics are stable (all poles are in the left half
plane) and meet certain dynamic or transient specifications. This last requirement can be
achieved by requiring the poles of the closed-loop system to be located in certain admissible
regions in the left half plane in order to satisfy certain transient specifications (e.g., settling time
less than 4 time constants, overshoot less than 10%, etc.)
Assume that the above A and B matrices take the “controllable canonical form”
4 3 2 1
.
x u t
a a a a
x
Note that the open-loop characteristic polynomial is
3 4
2
2
3
1
4
sI A s as as as a
provides an alternative way of computing the coefficients
1 2 3 4
a , a , a , a
even when the original
A-matrix is not in the controllable canonical form. Suppose that four poles (complex or real)
have been selected so that, by direct calculation
3 4
2
2
3
1
4
1 2 3 4
( s p )( s p )( s p )( s p ) s bs bs bs b
Now, consider the state feedback law
u t b a b a b a b a x Kx
4 4 3 3 2 2 1 1
It is easily verified that
x
b b b b
x A BK x
4 3 2 1
.
and hence the closed-loop characteristic polynomial is
3 4 1 2 3 4
2
2
3
1
4
sI A BK s bs bs bs b s p s p s p s p
To deal with the general case when the matrices A and B are not in the controllable canonical
form, suppose that there exists a matrix T such that
4 3 2 1
a a a a
A T AT
and
1
0
0
0
B T B
Then, the identity
3 4
2
2
3
1
1 * 4
sI A T ( sI A ) T sI A s as as as a
indicates that
1 2 3 4
a , a , a , a
are simply the coefficients in the characteristic polynomial of A.
Choosing the state feedback control law
u Kx b a b a b a b a T x
1
4 4 3 3 2 2 1 1
the identity
4 4 3 3 2 2 1 1
1 * *
sI A BK T ( sI A BK ) T sI A B b a b a b a b a
4 3 2 1
0 0 0 1
0 0 1 0
0 1 0 0
b b b b
sI A BK
3 4 1 2 3 4
2
2
3
1
4
sI A BK s bs bs bs b s p s p s p s p
indicates that this control law solves our problem. It remains to find the transformation matrix T.
Let
k
t
be the k-th column of T, i.e.
1 2 3 4
T t t t t
and rewrite (10) and (11) in the form
TA AT
and
B TB
. It can then be verified, by
equating columns on the left- and right-hand sides of these equations, that
1 2 3 4
t , t , t , t
are the
solutions of the following recursive equations
1 44
2 1 34
3 2 24
4 3 14
4
At a t
At t a t
At t a t
At t a t
t B
The last of these equations will be automatically satisfied as a result of the Cayley-Hamilton
theorem.
The design procedure follows:
1. Given the matrices A and B, compute the matrix T from (16)
2. Compute the coefficients
1 2 3 4
a , a , a , a
of the open-loop characteristic polynomial in (5)
Appendix II
Example of MATLAB Script and Results
In this Appendix, we illustrate the previous procedure of designing of a feedback controller using
pole placement by state feedback. The example shown below, however, does not meet the
desired transient specifications.
%Enter the A,B,C,D matrices of the inverted pendulum system:
A = [0 0 1 0; 0 0 0 1; 0 -1.7811 -8.8553 0; 0 28.5026 21.7754 0]
A =
0 0 1.0000 0
0 0 0 1.
0 -1.7811 -8.8553 0
0 28.5026 21.7754 0
B = [0 0 1.9814 -4.8724]'
B =
0
0
-4.
C = [0 1 0 0]
C =
0 1 0 0
D = 0
D =
0
%Compute the coefficients a1,a2,a3,a4 of the open-loop characteristic
%equation:
poly(A)
ans =
1.0000 8.8553 -28.5026 -213.6149 0
a1 = ans(2)
a1 =
a2 = ans(3)
a2 =
-28.
a3 = ans(4)
a3 =
-213.
a4 = ans(5)
a4 =
0
%Compute the columns t4,t3,t2,t1 of the T matrix transformation:
t4 = B
t4 =
0
0
-4.
t3 = At4+a1t
t3 =
-4.
-0.
t2 = At3+a2t
t2 =
-0.
-47.
-0.
t1=At2+a3t
t1 =
-47.
-0.
-0.
T = [t1 t2 t3 t4]
T =
-47.7968 0.0000 1.9814 0
-0.0000 -0.0008 -4.8724 0
0.0000 -47.7968 0.0000 1.
-0.0000 -0.0000 -0.0008 -4.
400
%Compute the closed-loop system matrix Ac = A - BK:
Ac = A-B[b4-a4 b3-a3 b2-a2 b1-a1]inv(T)
Ac =
0 0 1.0000 0
0 0 0 1.
16.5819 114.9614 18.2382 16.
-40.7759 -258.5754 -44.8493 -40.
%Check the eigenvalues of the closed-loop system matrix and their
%damping:
eig(Ac)
ans =
-10.0000 +10.0000i
-10.0000 -10.0000i
-1.0000 + 1.0000i
-1.0000 - 1.0000i
damp(Ac)
Eigenvalue Damping Freq. (rad/s)
-1.00e+000 + 1.00e+000i 7.07e-001 1.41e+
-1.00e+000 - 1.00e+000i 7.07e-001 1.41e+
-1.00e+001 + 1.00e+001i 7.07e-001 1.41e+
-1.00e+001 - 1.00e+001i 7.07e-001 1.41e+
%Run a linear simulation to verify the system meets the specifications:
x0 = [0 10*pi/180 0 0]'
x0 =
0
0
0
t = [0:0.05:10];
size(t)
ans =
1 201
u = zeros(size(t));
[y,x] = lsim(Ac,B,C,D,u,t,x0);
%Plot the pendulum angle and cart position:
plot(t,x(:,1),'.',t,y,'-'),grid
xlabel('Time (sec)')
ylabel('\theta(t) (rad), x(t) (m)')
title('Pendulum Angle and Cart Position for \theta(0) = 10 deg')
legend('Cart Position x(t)','Pendulum Angle \theta(t)')
print -deps dpout
%Plot the DC motor voltage:
u = -[b4-a4 b3-a3 b2-a2 b1-a1]inv(T)x';
plot(t,u,'-'),grid
xlabel('Time (sec)')
ylabel('DC Motor Voltage u(t) (V)')
title('DC Motor Voltage for \theta(0) = 10 (deg)')
print -deps dpout
Figure 2: Cart Position x ( t ) and Pendulum Angle ( t ) Responses for an Initial Pendulum Angle
(0) = 10 (deg).
The pendulum angle and cart position responses are shown in Figure 2. Clearly, the
specifications are not met in this case since the settling time is greater than 2 seconds.