You are on page 1of 8

1

LINEAR MOTION INVERTED PENDULUM

DERIVATION OF THE STATE-SPACE MODEL

Background
In this experiment, an inverted pendulum on a moving cart will be investigated. A pendulum rod
is free to oscillate around a fixed pivot point attached to a motor-driven cart which is constrained to move
in the horizontal movement. The rod is placed in the upright vertical position, which is an unstable
equilibrium point. The control objective is to apply a force to move the cart so that the pendulum remains
in the vertical unstable position.
The system of interest is shown in Figure 1, where F is the force in Newtons, m is the mass of the
pendulum rod in kilogrammes, M is the mass of the moving cart in kilogrammes, FV is the force applied
to the cart in Newtons, Ff is the force due to friction in Newtons, g is the acceleration due to gravity in
m·s-2, and θ is the angle of the inverted pendulum measured from the vertical y-axis in radians.

θ
mg
M
FV
Ff

Figure 1: Schematic of the Inverted Pendulum System

Mathematical Model of the System


Consider the free body diagrams shown in Figure 2. Furthermore, assume that the co-ordinates of
the centroid (centre of gravity) of the pendulum, (xG, yG), are given by
xG = x + l sin θ
(1)
yG = l cos θ
where l is the distance along the pendulum to the centre of gravity and x is the x-co-ordinate of the cart’s
position.
2

y FY

x lsinθ
FX
FV mg

lcosθ
FX θ l
Ff
a) Mg b)
N FY c)

Figure 2: Free body Diagrams of (a) the Cart and (b) the Pendulum. (c) Determining the Required Distances.

For the horizontal motion of the cart, Newton’s second law of motion

d 2x
∑ F = M dt 2 (2)

can be written as

d 2x
M = FV − FX − Ff (3)
dt 2
since, as can be verified from Figure 2a, there are only three forces acting in the x-direction. Assume that
the friction force can be written as
dx
Ff = γ 2 (4)
dt
Substituting Equation (4) into Equation (3) gives

d 2x dx
M 2 = FV − FX − γ 2 (5)
dt dt
Similarly, from Equation (2), the horizontal motion of the pendulum can be written as

d 2 xG
FX = m (6)
dt 2
The derivative on the right in Equation (6) can be simplified by determining the derivative of xG using
Equation (1). The first derivative can be found as follows

dxG d ( x + l sin θ )
=
dt dt
dx d ( sin θ )
= +l (7)
dt dt
dx dθ
= + l cos θ
dt dt
3

where, since θ is a function of time, the chain rule was applied to the second line in order to obtain the
final form of the first derivative. The second order derivative can be found by differentiating Equation (7),
that is,

d 2 xG d ⎛ dx dθ ⎞
2
= ⎜ + l cos θ ⎟
dt dt ⎝ dt dt ⎠
d 2x d ⎛ dθ ⎞
= + l ⎜ cos θ ⎟
dt dt ⎝ dt ⎠
d 2 x ⎛ d cos θ dθ d 2θ ⎞
= +l⎜ + cos θ 2 ⎟ (8)
dt ⎝ dt dt dt ⎠
d 2x ⎛ ⎞
2
⎛ dθ ⎞ d 2θ
= + l ⎜ − sin θ ⎜ ⎟ + cos θ ⎟⎟
dt ⎜ ⎝ dt ⎠ dt 2
⎝ ⎠
2
d 2x ⎛ dθ ⎞ d 2θ
= − l sin θ ⎜ ⎟ + l cos θ 2
dt ⎝ dt ⎠ dt
Combining Equation (8) with Equation (6) gives
⎛ d 2x ⎛ dθ ⎞
2
d 2θ ⎞
FX = m ⎜ 2 − l sin θ ⎜ ⎟ + l cos θ ⎟⎟ (9)
⎜ dt ⎝ dt ⎠ dt 2
⎝ ⎠
Using Equation (9), Equation (5) can be simplified to give

d 2x ⎛ d 2x ⎛ dθ ⎞
2
d 2θ ⎞ dx
M 2 = FV − m ⎜ 2 − l sin θ ⎜ ⎟ + l cos θ ⎟⎟ − γ 2
dt ⎜ dt ⎝ dt ⎠ dt 2 dt
⎝ ⎠ (10)
2
d 2x d 2x ⎛ dθ ⎞ d 2θ dx
M 2 = FV − m 2 + ml sin θ ⎜ ⎟ − ml cos θ 2
−γ2
dt dt ⎝ dt ⎠ dt dt
The final form for the horizonal motion of the cart can be given as
2
d 2x dx ⎛ dθ ⎞ d 2θ
( M + m) + γ 2 = FV + ml sin θ ⎜ ⎟ − ml cos θ (11)
dt 2 dt ⎝ dt ⎠ dt 2

For the vertical motion of the pendulum, Equation (2) can be written as

d 2 yG
FY − mg = m (12)
dt 2
Similarly to the horizontal case, the derivative on the right in Equation (12) can be written as follows

dyG d ( l cos θ ) dθ
= = −l sin θ (13)
dt dt dt
4

d 2 yG d ⎛ dθ ⎞
2
= ⎜ −l sin θ ⎟
dt dt ⎝ dt ⎠
⎛ d sin θ dθ d 2θ ⎞
= −l ⎜ + sin θ 2 ⎟
⎝ dt dt dt ⎠
(14)
⎛ ⎛ dθ ⎞
2
d 2θ ⎞
= −l ⎜ cos θ ⎜ ⎟ + sin θ 2 ⎟
⎜ ⎝ dt ⎠ dt ⎟
⎝ ⎠
2
⎛ dθ ⎞ d 2θ
= −l cos θ ⎜ ⎟ − l sin θ
⎝ dt ⎠ dt 2
Using Equation (14), Equation (12) can be rewritten to give
⎛ ⎛ dθ ⎞
2
d 2θ ⎞
FY − mg = m ⎜ −l cos θ ⎜ ⎟ − l sin θ ⎟⎟ (15)
⎜ ⎝ dt ⎠ dt 2
⎝ ⎠
Thus, the vertical reaction force, FY, can be written as
⎛ ⎛ dθ ⎞
2
d 2θ ⎞
FY = mg + m ⎜ −l cos θ ⎜ ⎟ − l sin θ ⎟⎟ (16)
⎜ ⎝ dt ⎠ dt 2
⎝ ⎠
For any object, the relationship between the moment applied on an object and its angular
acceleration is given by the following relationship

d 2θ
∑M = I dt 2
(17)

where M̄ is the moment due to a given force and defined as


G G
M = F ×r (18)
G G
where F is the force vector, r is the position vector of the object with respect to the point about which
the moments are being summed, and I is the angular momentum of the object. For the pendulum,
summing the moment around its centre of gravity, Equation (17) can be written as

d 2θ
FY l sin θ − FX l cos θ = I (19)
dt 2
Substituting Equation (16) for FY and Equation (9) for FX into Equation (19) gives

⎛ ⎛ ⎛ dθ ⎞
2
d 2θ⎞⎞
⎜ mg + m ⎜ −l cos θ ⎜ ⎟ − l sin θ ⎟⎟ ⎟ l sin θ
⎜ ⎜ ⎝ dt ⎠ dt 2 ⎟
⎝ ⎝ ⎠⎠
(20)
⎛ ⎛ d 2x ⎛ dθ ⎞
2
d 2θ ⎞ ⎞ d 2θ
− ⎜ m ⎜ 2 − l sin θ ⎜ ⎟ + l cos θ ⎟ ⎟ l cos θ = I
⎜ ⎜ dt ⎝ dt ⎠ dt 2 ⎟⎠ ⎟⎠ dt 2
⎝ ⎝
Simplifying Equation (20) gives
5

2
⎛ dθ ⎞ d 2θ
mgl sin θ − ml sin θ cos θ ⎜
2
⎟ − ml 2
sin 2
θ
⎝ dt ⎠ dt 2
2
(21)
d 2x ⎛ dθ ⎞ d 2θ d 2θ
−ml cos θ + ml cos θ sin θ ⎜
2
⎟ − ml cos θ 2 = I 2
2 2

dt ⎝ dt ⎠ dt dt

d 2θ d 2x d 2θ
mgl sin θ − ml 2 ( sin 2 θ + cos 2 θ ) − ml cos θ = I (22)
dt 2 dt dt 2
Since
cos 2 θ + sin 2 θ = 1 (23)
Equation (22) can be simplified to give
d 2θ d2x d 2θ
mgl sin θ − ml 2
− ml cos θ 2 = I 2
dt 2 dt dt
(24)
2
d x dθ
2
mgl sin θ − ml cos θ 2 = ( I + ml 2 ) 2
dt dt
Thus, the final equation for the angular position is given as

( I + ml ) ddtθ = mgl sin θ − ml cos θ ddt x


2 2
2
2 2
(25)

Therefore the equations of motion for the inverted pendulum on a moving cart can be written as

⎧ d 2x dx ⎛ dθ ⎞
2
d 2θ
⎪( M + m ) 2 + γ 2 = FV + ml sin θ ⎜ ⎟ − ml cos θ
⎪ dt dt ⎝ dt ⎠ dt 2
⎨ (26)
2 d θ
2
⎪ d2x
⎪⎩ ( I + ml ) dt 2
= mgl sin θ − ml cos θ
dt 2
For the system in the laboratory, the relationship for the force due to the voltage can be written as
FV = γ 1V (27)

where γ1 is conversion factor and V is the applied voltage in volts.

Linearised Model of the System


The model of the system given by Equation (26) is nonlinear and must be linearised in order to
obtain a reasonable model for control purposes. Linearisation will be performed about the point x = 0 m
and θ = 0 radians. Furthermore, it will be assumed that since θ is small 1 ,

1
This is justifiable when controlling an object as it should not deviate greatly from the assumed steady-state value.
6

sin θ ≈ θ
cos θ ≈ 1 (28)
2
⎛ dθ ⎞
⎜ ⎟ ≈0
⎝ dt ⎠
Under these assumptions, Equation (26) can be rewritten as

⎧ d 2x dx d 2θ
⎪⎪ ( M + m ) + γ 2 = FV − ml
dt 2 dt dt 2
⎨ (29)
2 d θ
2
d 2x

⎪⎩ ( I + ml ) dt 2
= mglθ − ml 2
dt
If it is assumed that the centre of the mass of the pendulum is equal to its centre of gravity, then I = 0, and
Equation (29) reduces to

⎧ d 2x dx d 2θ
⎪⎪( M + m ) 2 2 + γ = FV − ml
dt dt dt 2
⎨ (30)
⎪ d 2θ d 2x
l 2 = gθ − 2
⎪⎩ dt dt
Substituting Equation (27) into Equation (30), gives

⎧ d 2x dx d 2θ
⎪⎪( M + m ) 2 + γ 2 = γ 1V − ml 2
dt dt dt
⎨ (31)
⎪ dθ2 2
d x
l 2 = gθ − 2
⎪⎩ dt dt
Therefore, the linearised equations of motion for the pendulum and moving cart can be written as

⎧ d 2x d 2θ dx
⎪⎪ ( M + m ) 2
+ ml 2
+γ2 = γ 1V
dt dt dt
⎨ (32)
⎪ d 2θ d 2 x
l + = gθ
⎪⎩ dt dt
In order to uncouple the equations, that is force each equation to contain only derivatives that are
functions of either θ or x, substitute Equation (32).2 into Equation (32).1. This gives
7

d 2x ⎛ gθ 1 d 2 x ⎞ dx
( M + m) 2
+ ml ⎜ − ⎟+γ2 = γ 1V
dt ⎝ l l dt ⎠ dt
d 2x d 2x dx
( M + m) 2
+ mgθ − m +γ2 = γ 1V
dt dt dt
2
d x dx
M 2 + mgθ + γ 2 = γ 1V
dt dt (33)
2
d x dx
M 2 +γ2 = γ 1V − mgθ
dt dt
d x γ 2 dx
2
γ1 mg
+ = V− θ
dt 2 M dt M M
d 2x mg γ dx γ 1
=− θ− 2 + V
dt 2 M M dt M
Substituting Equation (33) into Equation (32).2 gives

d 2θ ⎛ mg γ dx γ 1 ⎞
l +⎜− θ− 2 + V ⎟ = gθ
dt ⎝ M M dt M ⎠
d 2θ mg γ dx γ 1
l = gθ + θ+ 2 − V (34)
dt M M dt M
d 2θ M + m γ dx γ 1
= gθ + 2 − V
dt Ml Ml dt Ml
Thus, the uncoupled form of the equations of motion for this system are given as

⎧d 2x mg γ 2 dx γ 1
⎪⎪ dt 2 = − M θ − M dt + M V
⎨ 2 (35)
⎪ d θ = M + m gθ + γ 2 dx − γ 1 V
⎪⎩ dt Ml Ml dt Ml
The state-space form of a linear equation is given by
G
dx G G
= Ax + Bu (36)
dt
G G
where x is the state vector, u is the input vector, A is the state matrix, and B is the input matrix. If it is
assumed that

⎡ x ⎤
⎢θ ⎥
⎢ ⎥
G ⎢ dx ⎥ G
x = ⎢ ⎥ ,u = V (37)
⎢ dt ⎥
⎢ dθ ⎥
⎢⎣ dt ⎥⎦
8

Equation (35) can be rewritten into state-space form by defining the matrices to be

⎡0 0 1 0⎤ ⎡ 0 ⎤
⎢0 0 0 1 ⎥⎥ ⎢ 0 ⎥
⎢ ⎢ ⎥
A = ⎢⎢ 0 mg γ2 ⎥ , B = ⎢ γ1 ⎥ (38)
− − 0⎥ ⎢ ⎥
⎢ M M ⎥ ⎢ M ⎥
⎢0 M +m γ2 ⎢− γ 1 ⎥
⎢⎣ g 0 ⎥⎥ ⎢⎣ Ml ⎥⎦
Ml Ml ⎦
Thus, the state-space can be given as

⎡ dx ⎤
⎢ dt ⎥ ⎡ 0 0 1 0⎤ ⎡ x ⎤ ⎡ 0 ⎤
⎢ ⎥ ⎢
⎢ dθ ⎥ ⎢ 0 0 0 1 ⎥⎥ ⎢⎢ θ ⎥⎥ ⎢⎢ 0 ⎥⎥
⎢ dt ⎥ ⎢ mg γ2 ⎥ ⎢ dx ⎥ ⎢ γ ⎥
⎢ 2 ⎥ = ⎢0 − − 0⎥ ⎢ ⎥ + ⎢ 1 ⎥ V (39)
⎢d x⎥ ⎢ M M ⎥ ⎢ dt ⎥ ⎢ M ⎥
⎢ dt 2 ⎥ ⎢ M +m γ2 dθ γ
⎢ 2 ⎥ ⎢0 g 0 ⎥⎥ ⎢⎢ ⎥⎥ ⎢⎢ − 1 ⎥⎥
⎢d θ ⎥ ⎣ Ml Ml ⎦ ⎣ dt ⎦ ⎣ Ml ⎦
⎢⎣ dt 2 ⎥⎦

Physical Parameters
For the system in the laboratory, Table 1 presents the physical parameters of the system.

Table 1: Physical Parameters of the Pendulum System

Parameter Value
l (half-length of pendulum) 0.305 m
m (mass of pendulum rod) 0.231 kg
M (mass of the cart) 0.792 kg
γ1 1.72 N·V-1
γ2 7.68 kg·m

Note: The MATLAB programme requires that the angle be entered in degrees rather than radians and so
all the values should be converted using the relationship 180° = πr.

Acknowledgements
This manual was written by Ryan Lee Robles and Yuri A.W. Shardt. The authors would also like
to thank William Weng for his proofreading of this manual.

You might also like