Professional Documents
Culture Documents
Qdoc - Tips Rotary Inverted Pendulum
Qdoc - Tips Rotary Inverted Pendulum
2 Introduction
The rotary motion inverted pendulum, which is shown in Figure 1, is driven by a rotary
servo motor system (SRV-02) that is illustrated in Figure 2. The servo motor drives an
independent output gear whose angular position is measured by an encoder. The rotary
pendulum arm is mounted to an output gear. At the end of the pendulum arm is a hinge
instrumented with another encoder. The pendulum attaches to the hinge. The second
encoder measures the angular position of the pendulum. The system is interfaced by
means of a data acquisition card and driven by Matlab° R
/Simulink° R
based real time
software.
Notice that the pendulum has two equilibrium points. A stable equilibrium at the
point where the rod is vertical and pointing down. An unstable equilibrium at the point
where the rod is vertical and pointing up. In this practical session, a control scheme will
be designed to stabilise the pendulum around the unstable equilibrium point.
3 Mathematical modelling
3.1 Nonlinear model
Consider the diagram shown in Figure 3. A nonlinear model of this system, which can be
derived by means of the Euler-Lagrange equations, is given by:
where the symbols used are described in Table 1. Note that the zero position for α and
θ are defined as the pendulum being vertical “up”. A positive angle in the pendulum α
is defined for a fall to the right when looking at the pendulum from the motor shaft. A
positive rotation of the arm θ is defined as clockwise when looking at the SRV-02 from
above. Also note that parameter lp is half the pendulum length.
1
Figure 1: The rotary inverted pendulum
2
Table 1: Description of the mathematical model variables and parameters
Variable Description Units Value
T input torque from motor Nm
mp mass of rod kg 0.125
lp distance from arm to the centre of gravity of rod m 0.1714
r length of pendulum arm m 0.2159
Jb Inertia of arm and gears kg m 0.0038
g Acceleration of gravity m/s2 9.8
θ Deflection of arm from zero position rad
α Deflection of pendulum from vertical UP position rad
θ̇ Angular velocity of θ rad/s
θ̈ Angular acceleration of θ rad/s2
α̇ Angular velocity of α rad/s
α̈ Angular acceleration of α rad/s2
where s is the Laplace variable, θ(s), α(s) and T (s) represent the Laplace transforms of
θ, α and T , respectively. Define the following auxiliary parameters:
mp rg
a=
Jb
1
b=
Jb
(4)
g(Jb + mp r2 )
c=
l p Jb
r
d=
lp Jb
3
Pendulum rod
2l p
Pendulum arm
d
α(s) = − T (s) (6)
s2 − p2
√
where p = c.
Substituting in the first sub-equation of (3), results in the following equation for θ(s):
b(s2 − z 2 )
θ(s) = T (s) (7)
s2 (s2 − p2 )
where r
bc − ad
z= (8)
b
4
Table 2: Variables and parameters associated with the servo motor
Variable Description Units Value
T Torque generated by the servo-motor Nm
v Voltage applied to the armature of the motor V
R Armature resistance Ω 2.6
Km Motor torque constant N m/A 0.00767
Kg Gear ratio - 70
θ̇ Angular velocity of the output gear rad/s
t1 b(s2 − z 2 )
θ(s) = v(s) (12)
s(s3 + t2 bs2 − p2 s − t2 bz 2 )
So that the transfer function from v(s) to θ(s) is:
t1 b(s2 − z 2 )
Gv,θ (s) = (13)
s(s3 + t2 bs2 − p2 s − t2 bz 2 )
5
u(s) α(s)
Gv ,θ ( s) Gθ ,α ( s )
θ ( s)
Figure 4: Block diagram of the linearised model of the inverted pendulum including the
servomotor, gearbox and pendulum arm
4 Procedure
You should sketch all the root locus diagrams and write down the transfer functions found
with Matlab° R
as you work through the different tasks on your log book. Please note that
the servo and pendulum can rotate quite quickly, so be careful when starting and operating
the system.
4.1 Task 1
Introduce the values of the parameters given in Tables 1 and 2 as relevant variables in
the Matlab° R
workspace. Calculate the values of the auxiliary parameters a, b, c, d, z, p, t1
and t2 . Use the tf command1 to define the transfer functions Gv,θ and Gθ,α as objects in
the Matlab° R
workspace (see Equations (13) and (14) ).
Hint: To do this, it is useful to define the Laplace variable s in the Matlab°
R
workspace
as follows:
>> s= tf( [1, 0], [0, 1]);
Then, transfer function Gv,θ may be defined in Matlab° R
, as follows:
>> G_V_theta=b*t1*(s^2-z^2)/(s*(s^3+t2*b*s^2-p^2*s-t2*b*z^2));
4.2 Task 2
Consider the block diagram given in Figure 5, where Cθ (s) is a Proportional+Derivative
(PD) compensator, with the following transfer function:
µ ¶
Tθ,d s Kθ,d s
Cθ (s) = Kθ,p 1 + 1 = Kθ,p + 1 (15)
N
s+1 N
s+1
1
Type >> help tf for help on this command
6
v(s) θ (s) α(s)
A + B
Gv ,θ ( s ) Gθ ,α ( s )
-
Cθ ( s )
where Kθ,p , is the proportional gain, Tθ,d is the derivative time constant and Kθ,d =
Kθ,p Tθ,d is the derivative gain. Note that the derivative action has a lag with time constant
1/N , which is included to avoid amplifying high frequency signals.
Assume that the values of the compensator parameters are Kθ,p = −1 and Kθ,α =
−1.42 and N = 50.
Use the feedback command2 to compute the closed loop transfer function GA,B be-
tween points A and B of Figure 5 including the transfer function Gv,θ and the controller
Cθ (s).
4.3 Task 3
Consider the block diagram given in Figure 6, where Cα (s) is a Proportional+Derivative
(PD) controller, with the following transfer function:
µ ¶
Tα,d s Kα,d s
Cα (s) = Kα,p 1 + 1 = Kα,p + 1 (16)
N
s+1 N
s+1
where Kα,p , is the proportional gain, Tα,d is the derivative time constant and Kα,d =
Kα,p Tα,d is the derivative gain.
Compute the open loop transfer function seen by the α-controller by using the product
(’*’) operator:
GA,α = GA,B (s)Gθ,α (s) (17)
Notice that this transfer function exhibits pole-zero cancellations. To see this, use the zpk
command3 to convert the transfer function to pole-zero form. To eliminate the common
poles and zeros you must use the minreal command4 (it is important to do this).
Now assume for the moment that Kα,p = 1 and Tα,p = 0 and use the product operator
(OL)
(’*’) to compute the open loop transfer function GR,α as follows:
(OL)
GR,α (s) = Cα (s)GA,α (s) (18)
2
Type >> help feedback for help on this command
3
type >> help zpk for help on this command
4
type >> help minreal for help on this command
7
θ (s ) α(s)
R(s) + A + v(s) B
Cα ( s) Gv ,θ ( s ) Gθ ,α ( s )
- -
Cθ ( s)
Figure 6: Block diagram of the control scheme including the inner control loop on θ and
the outer control loop on α
Use the rlocus command5 to compute the root locus based on the above values of Kα,p
and Tα,d . Write your observations on your log book. Now let Kα,p = −1 and Tα,p = 0 and
(OL)
recalculate GR,α and the root locus. Write your observations on your log book. Repeat
this procedure leaving Kα,p = −1 but for different values of Tα,d = {0.1, 0.5, 1}. Write
your observations on your log book, and indicate what value of Tα,d is best and why.
Using the root locus for the best value of Tα,d compute the best value of the gain Kα,p
to achieve a good damping ratio for the dominant complex poles ( ζ ≈ 0.7 is reasonable;
you can do this by placing the pointer and clicking the mouse on different points of the
loci and reading the values from the screen.) and take a note of the value of the gain Kα,p
and compute the corresponding derivative gain using Kα,d = Kα,p Tα,d . Using the same
root locus, find a value of the gain Kα,p for which the system is unstable. Take a note of
this other value of Kα,p and find the corresponding value of the derivative gain.
4.4 Task 4
Open the Simulink°
R
file exp106.mdl and assign values to the following Matlab°
R
variables
from the command prompt:
Switch on the Universal Power Module (See Figure 7; the switch is located at the back
of the module), hold the pendulum steady at the upright position, from the Simulink° R
window
called exp106 choose the menu option WinCon/Build. Then, from the small window
5
Type >> help rlocus for help on this command
8
Figure 7: The Universal Power Module and associated connections
entitled WinCon Server press the start button, release the pendulum and observe the
results. Apply a slight tap to perturb the pendulum using your hand and see if it recovers.
After a while, press the Stop button in the WinCon server window.
4.5 Task 5
Assign values to the following Matlab°
R
variables from the command prompt:
Again, hold the pendulum steady at the upright position, from the Simulink°
R
window
called exp106 choose the menu option WinCon/Build. Then, from the small window
entitled WinCon Server press the start button, release the pendulum and observe the
results.
5 Conclusions
Your conclusions must address the following points.
1. How robust is this control scheme to large perturbations on the pendulum and why?
9
Figure 8: The terminal board and associated connections
2. How accurate was the root locus approach based on the linearised model in predict-
ing the stability/unstability of the system?
Appendix
Set up and connections
The required setup and connections will be made by the demonstrator.
This experiment is performed with the SRV-02 in the high gear ratio configuration.
Attach the pendulum arm to the central gear of the SRV-02 using the two brass thumb
screws.
The connections are indicated in Figures 2, 7 and 8. The required connections are
listed below:
1. Encoder output of SRV-02 to encoder input No. 0 of terminal board (white cable).
2. Encoder output of pendulum arm to encoder input No. 1 of terminal board (white
cable).
3. Analog ouput No. 0 of terminal board to connector labelled From D/A on Uni-
versal Power Module (black cable).
4. Output labelled To Load on Universal Power Module to left connector (as seen
from the back) of SRV-02 (black cable).
10
Written by Dr. V. M. Becerra, October 2002.
11