You are on page 1of 4

Modelling and control of Inverted pendulum

Jacob James
Mechanical and Aerospace Engineering
University of Florida
Email: jacobjamesm@u.edu
AbstractThis paper models an inverted pendulum, designing
a controller for positioning the cart at some position while
keeping the pendulum in a vertical position. The system is
controlled with a single force input.
I. INTRODUCTION
The inverted pendulum is a classic control problem that
can be used as the basis for the modeling of many more
complex problems like stabilization of a rocket during
launch, balancing of robots, biped motion planning building
balancing in earthquakes, in design and stabilization of
personal mobility units and many more applications. The
inverted pendulum is a system that is inherently unstable, and
cannot be balanced without the application of some external
torque. The classic problem deals with the control of the
input torque required to balance the inverted pendulum.
Here the problem of balancing an inverted pendulum
on a carriage is considered. The aim of this exercise to
maintain the pendulum balance while the cart moves to the
required position.
The second section of this paper describes the system,
and derives the dynamic equations of motion for the system.
The system here has two controllable outputs.
The third section derives the state space model for the
inverted pendulum, taking the position of the cart and the
angle of the pendulum as the output variables. The input here
is the force applied on the cart, that has to both position the
cart and maintain the stability of the inverted pendulum.
The fourth section deals with stability analysis for the
system that has been arrived at. The stability analysis of the
system with no feedback applied shows that that system is
unstable as was already known.
The fth section deals with designing a feedback loop
to position the cart at the required position while maintaining
the stability of the system. The design focuses on achieving
a suitably small settling time for the system
II. THE CARRIAGE PENDULUM SYSTEM
1) Mechanical set-up of the carriage inverted pendulum
system: The system consists of a carriage constrained to
move along a straight line. Onto this carriage a pendulum is
mounted that is constrained to move along the plane passing
through the line of motion of the cart. The pendulum will tip
over if its centre of gravity does not pass through the hinge
point. Any motion of the cart will also cause the pendulum
to tip over in the opposite direction. The aim of this control
exercise is to move the cart into the required position without
tripping over the pendulum. Here a single input to the system,
the force on the cart has an impact on the coupled output,
i.e. the motion of the cart in the x direction and the tipping
of the pendulum along the direction of motion by an angle.
2) Equations of motion : The equations of motion for the
system are arrived at from the free body diagram. Considering
the pendulum: Taking the torque about the centre of mass of
the pendulum,
I

= V lsin() Hlcos() (1)


Considering the forces acting on the pendulum,
In the horizontal direction:
m
d
2
dt
2
(x + lsin()) = H (2)
In the vertical direction:
m
d
2
cos()
dt
2
= V mg (3)
Considering the free body diagram of the cart, the horizontal
motion of the cart is given by:
M
d
2
x
dt
2
= u H (4)
Here H and V are the reaction forces along the horizontal
and vertical direction.
To linearise this model the motion of the pendulum is restricted
to a small angle on either side of the article. Under this
condition it can be assumed that the following relations hold
true:
sin() = 0 (5)
cos() = 1 (6)
These assumptions equation 1 through 3 become,
I

= V l Hl (7)
m x + ml

= H (8)
V mg = 0 (9)
From 4 and 6
(M + m) x + ml

= u (10)
And form 5 and 7:
I + ml
2

+ ml x = mgl (11)
III. STATE SPACE MODEL
To model this system as a state space problem, the outputs
are identied as pendulum angle and cart position x. For
deriving a state space model let us assume the mass to be
concentrated at the top of the pendulum, and the pendulum
rod to be massless. In this case the I becomes 0.
The state variables can then be dened as x1, x2, x3, x4
_
_
_
_
x
1
x
2
x
3
x
4
_
_
_
_
=
_
_
_
_
x
x

_
_
_
_
These relations together give the dynamic equations of
motion of the cart pendulum system. The output matrix for
the system becomes
y =
_
x

_
Then from the above denition of our state we get
x
1
= x
2
(12)
x
3
= x
4
(13)
TABLE I
PARAMETERS FOR THE SYSTEM
Parameters Value
Cart Mass M 5kg
Pendulum Mass m 1 kg
Pendulum Length 2l 1 m
Fig. 1. System response to step input
From equation 5 & 6 and taking I to be zero as per our
assumption.
x
2
=
M + m
Ml
gxl
1
Ml
u (14)
x
4
=
m
M
gxl
1
M
u (15)
The state space model for the system becomes:
x = Ax + Bu (16)
which is:
_

_
x
1
x
2
x
3
x
4
_

_
=
_

_
]
0 0 0
M+m
Ml
g 0 0 0
0 0 0 1

m
M
g 0 0 1
_

_
_

_
x
1
x
2
x
3
x
4
_

_
+
_

_
0

1
Ml
0
1
m
_

_
u
The output equation for the system becomes:
y =
_
x

_
=
_
1 0 0 0
0 0 1 0
_
_

_
x
1
x
2
x
3
x
4
_

_
IV. STABILITY ANALYSIS
A. Parameters for the system
For carrying out further analysis the following parameters
are assumed and listed in Table 1.
B. System Response
The response of the system without feedback for a step input
is then plotted.
Plotting the response of the system to an input force of
.5 newton gives the following response. It is evident that the
system is unstable and the pendulum gets knocked over.
The poles of the system are found to be
= 0, 1, 6.766, 6.766
The two poles 1 & 6.7661 lie on the right half of the complex
plain, and 0 lies on the imaginary axis. The system is hence
unstable. A feedback loop is necessary to obtain the required
positioning of the system.
V. CONTROLLER DESIGN
A. Controllability Check
Before beginning the controller design the controllability of
the system is checked. The C matrix is found to be
C =
_

_
0 6.6667 0 305.2
6.6667 0 305.2 0
0 2 2 28.16
2 2 28.16 28.16
_

_
(17)
The C is found to be full rank. Hence the system is
controllable.
B. Controlled Design
The pole placement for the system is done using the matlab
command lqr. Matlab uses the function
J(u) =

_
0
(x
T
Qx + u
T
Ru + 2x
T
Nu)dt (18)
Where Q & R are weighting parameters. Minimizing J aims
at minimizing control energy and minimum state deviation.
The Q is a diagonal matrix which weights each element of
the state. The system response can be tuned by changing the
weighting value for each parameter, a higher value indicating
a larger signicance and more control energy dedicated to
the control of the particular state. Larger values of R relative
the Q a larger energy being spend to keep the deviations of
the state to a minimum.
Here the only parameters that need to be weighted are the
x and . The weighting matrix thus is taken to be
Q =
_

_
q
1
0 0 0
0 0 0 0
0 0 q
2
0
0 0 0 0
_

_
(19)
where q
1
is the weighting for the position and x and q
2
is
the weighting parameter for . The weighting for x and

is
taken to be zero. R is assigned a value of 1. Trying different
weighting conditions for the position x and the pendulum
angle it is observed that a higher weighting value for q
1
& q
2
results in a better response for the system. The response
for
q
1
= 1500
and
q
2
= 100
was found to be satisfactory.
Using the lqr command the gain matrix is found to be
k =
_
103.414 12.7174 10 24.7867

The position plot for step input to the system with feedback
shows that there is a steady state error in the angle and the
cart never reaches the desired position x but instead moves
back. This can be corrected by scaling the input. The scaled
input response is as shown. The poles of the system with
feedback is found to be = 16.1207+14.634, 16.1207
14.6340, 0.984+0.6414, 0.9840.6414 This controller
satises all the requirements placed at the commencement of
the design.
VI. OBSERVER DESIGN
The controller design was carried out assuming availability
of all the states. This is not the case with most cases. To
obtain the states for the use in the controller an observer
needs to be designed. The system rst needs to be checked
for observability.
O =
_

_
1 0 0 0
0 0 1 0
0 1 0 0
0 0 0 1
45.78 0 0 0
3.924 0 0 1
0 45.78 0 0
3.924 3.924 0 1
_

_
The O matrix is full rank and thus observable.
The pole placement should ensure a quicker convergence on
the states by the observer than that shown by the controller.
This ensures that the system performance is only affected by
the controller response time and not the observer response.
Pole position at a location 5-8 times further away form the
j than the controller poles axis should ensure a sufciently
quick response. The observer thus needs to have its poles at
= 80, 80, 4, 4.
The quickest way to design the observer will be to use
the MatLab command place to place the poles. The place
command cannot be used with repeated poles and hence the
poles can be taken to be = 80, 81, 4, 5.
The observer for the system then is:

x = A x + bu + l [y c x]
]
x(0) = x
0
l =
_

_
2.0695 6.2454
45.0151 0.3476
6.404 2.0695
4.1531 0.7366
_

_
A. Response under observer design
The response of the system using the observed states for
feedback is plotted.
VII. CONCLUSION
The system designed here gives a model for the control of
a simplied inverted pendulum. A real system will have many
more issues that needs to be dealt with such as the forces like
friction that have not been considered here. It will also need
to take into consideration noise. This serves design serves as
the starting point for a more robust design for applications
ranging from the balancing of robots to controlling of rockets
while launch.
ACKNOWLEDGMENT
REFERENCES
[1]

You might also like