Documente Academic
Documente Profesional
Documente Cultură
Control
Marc Russel
10017882
Chris Macdonald
10075289
Safwan Bhuiyan
10168831
Tara Gholami
10056821
Introduction:
The inverted pendulum is a typical problem in the study of control systems. The unstable, nonlinear nature of the system poses many challenges to the controls engineer. Design and implementation
of a control system on an inverted pendulum has ideas that can be extended to many problems in
control.
The system we will be using for this project is an inverted pendulum system by Quanser, the
IPO2 linear servo based system. This system consists of three major components a pendulum, cart and
track. The cart seats on the track interfacing through a gear system, the pendulum is attached to the
cart through a shaft and bearing system so that there is very little friction acting on the spin of the
pendulum. For this system there is two feedbacks, the position of the pendulum from an optical encoder
and the position of the cart through a potentiometer. This two feedbacks can also be used to find two
more outputs, the velocities of both the pendulum and cart. The input to the system is through a voltage
applied to a DC motor that applies force to the cart through a gear system. The control of the system
will be implemented and designed using MATLAB/Simulink.
The pendulum systems has two equilibrium points one in the upright 180, inverted pendulum,
and one in the downwards 0, gantry crane, positions. For the project we will study both of these cases.
The downward case will be studied first based on the stable nature of the system, the system will
naturally tend to this equilibrium position. The ladder case will be studied once we are familiarized with
the system from the downward case. Once a stabilizing control for the upwards case in designed and
implemented the last challenge of swing up control will be explored. The swing up control is taking the
system from the downward equilibrium position to the upward equilibrium position where it can be
then controlled by the controller for the configuration.
Modeling:
A schematic of the pendulum can be seen in figure 1 along with the free body forces, including
inertial forces in green. In this model the force exerted by the motor, F, was initially externally
represented. Afterwards the relationship between the motor parameters, voltage and exerted force was
determined. Also, it is assumed that the joint between the cart and the pendulum is frictionless.
F
N
P
Ff
M
m
N
N
N
N
Kg
Kg
m
Kgm2
Kg/s
From the free body of the cart and newtons second law of motion:
=
Substituting in the definition of friction force into the above we can get the dynamic model of the cart:
+ + =
Now the relationship between the force exerted by the DC motor and the voltage input to the motor
needs to be determined: required to be determined, as the input to the system is voltage and not force.
To do this the following parameters must be considered:
T
e
R
L
V
b
Ke
Kt
Kg
i
r
J
Nm
V
rad
H
V
Kgm/s
V/rad/sec
Nm/Amp
Amp
m
Kgm2
+ =
These relationships can be further simplified to a final expression relating force and voltage1:
=(
)(
+ )
It can be seen from this equation that the force exerted on the cart is dependent on both the input
voltage and the momentum of the cart. This model assumes that the DC motor is 100% efficient.
The complete model is therefor given by:
1) ( + ) + =
2) ( + 2 ) =
3) = (
)(
+ )
2
) =
1) ( + ) + ( + 2 ) =
2) ( + 2 ) =
2
2
) () 2 () =
2) ( + 2 ) 2 () () = 2 ()
()
To simplify the analysis from here on the following constants will be defined:
= ( + )
= ( +
2
)
2
=
=
= ( + 2 )
=
2
()
2
Substitution in equation 1 gives the relationship between the pendulum angle and input voltage:
2
() =
()
( 2 ) 4 + 3 2
Therefore:
() =
()
2
=
() ( 2 ) 4 + 3 2
The relationship between the voltage and the cart position is also needed and can be determined as:
() =
2
()
( 2 ) 4 + 3 2
()
2
=
() ( 2 ) 4 + 3 2
State Space:
In order to turn equations 1 and 2 into state space form, they are first rearranged to ensure and do
not explicitly depend on each other:
1) + =
2) =
Plug 2 into 1:
+
+ (
) =
( 2 ) + =
=
( 2 )
( 2 )
( 2 )
Plug 1 into 2:
= (
+
)
= 2 +
=
+ +
2
3) = ( 2 ) + ( 2 ) + ( 2 )
4) =
= [ ]
= []
From equations 3 and 4:
1 = 2
2 =
2 +
3 +
2
2
( )
( )
( 2 )
3 = 4
4 =
2
3
2
2
2
0
2
=
0
0
[0 2
=[
( 2 )
0
2
1 0
0 0
0
( 2 )
+
1
0
0]
[ 2 ]
0 0
0
] + [ ]
1 0
0
Thus:
0
0
=
0
[0
2
0
( 2 )
0
( 2 )
=
0
[ 2 ]
1 0
=[
0 0
0 0
]
1 0
0
=[ ]
0
0
0
1
0]
The value of the parameters for this specific experiment are as follows:
M
0.37 kg
0.23 kg
2.6
Kg
3.71
Kt
0.00767 Nm/amp
Km
0.00767 V.s/rad
6.35E-003 m
0.1 kg/s
0.6413m
0.0315 kgm2
After some experimentation, a controller was settled upon that used a lead compensator, with its zero
set at -4.79, and its pole at -43.1. This controller had a gain of -125. The root locus diagram of the system
using this controller is shown below. The control moves the system into a much more stable region, and
allows the system to be more damped, but also more responsive.
This controller was implemented into an actual system, and the following data was taken. The figure
below shows the angular displacement of the pendulum, (in encoder counts) in response to an impulse
at t = 0. There are approximately 11 counts in one degree of angular displacement. As can be seen, the
system moves by a maximum of 7 degrees, recovers fully in under 2 seconds, and has a steady state
error of less than 1 degree.
Fuzzy logic was then implemented to attempt to improve the systems behaviour. Adapting the model
developed in lab 8, we were able to achieve a much better level of control than by using the lead
compensator. For fuzzification, we used memberships that had a range of 100 counts for the encoder
position, and 50 counts per second for the encoder velocity. The figure below shows the response of this
system to the same impulse as before:
Figure 6 - Angular Response (in degrees) to Impulse Signal using Fuzzy Logic
In this case, the maximum displacement was much lower, at less than 1.5 degrees, and after 2 seconds,
the oscillation is both smaller than using lead compensation, and is decreasing.
The LQR method is a method to find the optimal stabilizing control of a system based on tunable
parameters Q and R. The Q matrix can be seeing as almost a weighting factor for each state if only the
diagonal has values. Each value of the diagonal can be looked at as weighting factors for each state, the
higher the value the more emphasize will be put on controlling that state. The R matrix can be looked at
as a weighting factor as to how aggressive you want the control to be. Two factors were tuned through
an iterative process testing each control found on the system and following trends to gain the desired
control of the system.
Angle (radians)
0.005
0
17
18
19
20
21
22
23
24
25
-0.005
-0.01
-0.015
-0.02
Time (s)
Figure 9 - Inverted Pendulum Angle (in degrees) in Response to Cart Position Step Change using LQR Tuning
26
27
Position (m)
0.05
0
17
18
19
20
21
22
23
24
25
26
27
-0.05
-0.1
-0.15
-0.2
-0.25
Time (s)
Figure 10 - Cart position (in meters) in response to Cart Position Step change of Inverted Pendulum with LQR Tuning
Swing up Control:
Finally with both control of the inverted and regular pendulum designed and examined we went
on to design of a swing up control for the system. This will be implemented into a hierarchal control
system, with the swing up control happening first with then the inverted control taking over. The system
will have a trigger once the pendulum reaches an angle inside the set angle range of the inverted
control.
The approach that will be used to try and design the controller for swing up is an energy
approach. This energy approach will try and get the inverted pendulum into a zero energy state which
will be set in the upright position by setting the datum of the pendulum appropriately. Through adding
energy into the system through movement of the cart the pendulum can be swung up to the upright
position. To start the system will be in a negative energy state, so to get the pendulum to zero energy
state energy needs to be added into the system. An energy balance between the potential energy and
kinetic energy will be used, so at certain points when the pendulum change velocity or drops below a
certain point the cart will change direction and eventually be turned off when approaching the top
equilibrium position. The block diagram for the swing up controller is shown in Figures 11 and 12
As the system runs, the controller continues to add energy to the system, causing the pendulum to
swing higher and higher. Figure 13 shows the resulting pendulum position, and Figure 14 shows the cart
motion used.
Angle of Pendulum
1
0
Angle (rad)
-1
10
15
20
-2
-3
-4
-5
-6
-7
Time (s)
25
10
15
Position (m)
-0.1
-0.15
-0.2
-0.25
-0.3
-0.35
-0.4
-0.45
Time (s)
20
25