You are on page 1of 6

t

1s IEEE International Conference on Power Electronics, Intelligent Control and Energy Systems (ICPEICES-2016)

Design, Implementation and Comparison


of Different Controllers for a Rotary
Inverted Pendulum

Binita Prakashl, Binoy Krishna Roy2 and Raj Kumar Biswas3


1,2,3Electrical Engineering, National Institute ofTechnology, Silchar-78801O, Assam
E-mail: Ibinita.prakash@gmail.com

Abstract-Inverted pendulum is widely used in the study FSF, and LQR. Hybrid control approaches and bio-inspired
of control theory. There are different types of inverted methods like genetic algorithms, and particle swarm
pendulums available, out of which a rotary inverted optimization have attracted more attention because of
pendulum (RIP) with an L-shaped arm is considered in this reduced complexity of controllers [8], [9].
work. The aim of this work is to stabilize the pendulum at its The present paper focused on a comparison of three
vertical upright position with minimum oscillations in both different balanced controllers based on experimental results
the pendulum and L-shaped arm. Firstly, a two loop
in terms of (i) steady state errors in pendulum and arm
Proportional Integral Derivative (PID) control is designed
positions, (ii) control effort, and (iii) robustness against
using root locus method, which is quiet challenging as the
disturbance in the pendulum position. The paper is organized
system is highly non-linear and under actuated. Secondly, a
as folIows. The next section describes the dynamics and
Full State Feedback (FSF) control by pole placement
mathematical model of the pendulum. In Section 3, step by
technique, and an Linear Quadratic Regulator (LQR)
technique have been used. Finally, MATLAB based
step procedure of designing two loop PID control is
simulations and ex- perimental results are compared and
presented. Section 4 describes FSF and LQR control. In
discussed. All controllers have been implemented on Quanser Section 5, experimental results have been discussed and
QNET RIP trainer system using LabVIEW tool and found compared. The conclusion is addressed in the last section.
that the LQR based controller is performing weil.
11. SYSTEM DESCRIPTION AND MATHEMATICAL MODELLlNG
Keywords-Rotary Inverted Pendulum; Stabilization;
Proportional Integral Derivative Control; Linear Quadratic The system ROTPEN which is used in this paper is
Control
shown in Fig. 1. It consists of a pendulum attached to an L­
I. INTRODUCTION
shaped arm. The L-shaped arm is connected to a 24-Volt DC
motor shaft and pivots between ±180 degrees. At the end of
The Inverted Pendulum is a c1assical control problem in the arm, there is a suspended pendulum attached. The
dynamics and control theory and is a widely used benchmark pendulum and arm angle are measured by encoders attached.
for testing control algorithms. There are different types of
inverted pendulum and they offer variety of interesting control
challenges. Rotary inverted pendulum, one among them, is
non-linear, under actuated, and open loop unstable system. It
has a number of practical applications such as missile
launchers, pendubots, segways, earthquake resistant building
design, etc [1].
The problem of balancing the pendulum at its inverted
position has been divided into two major tasks, i.e., swing up
Fig. I: Quanser ROTPEN Trainer System [2]
control and balance control. The swing up control is used to
bring the pendulum from its stable pending position to its TABLE I: ROTPEN COMPONENTS [2]
vertical upright position and balance control stabilizes the 1D Components 1D Components
pendulum at its upright position. Rotary inverted pendulum, 1. DC motor 8. Pendulum link
invented by Furuta, is also known as Furuta's pendulum. 2. Arm angle encoder 9. Pendulum weight
Swing up control technique is designed based on energy 3. Motor metal chamber 10. PCI connector to NI
shaping [4], speed gradient method [5], sliding mode control 4. Rotary arm pivot ELVIS
5. Rotary arm 11. QNET PWM/Encoder
[6], etc. However, it is the balance control which grabbed the 6. Pendulum encoder board
attention of many authors and different control strategies 7. Pendulum pivot 12. 24V QNET power jack
have been designed and implemented in past. Some of them 13. Fuse
are mathematically complex like sliding mode control, 14. +8, +15V, -15V, +5V
Lyapunov's direct method, optimal sliding mode cascade LEDs
control method, etc. In [7], a comparison is done for PID,

978-1-4673-8587-9/16/$31.00 ©2016 IEEE [11

Authorized licensed use limited to: Universidad Nacional Autonoma De Mexico (UNAM). Downloaded on March 22,2023 at 01:22:43 UTC from IEEE Xplore. Restrictions apply.
t
1s IEEE International Conference on Power Electronics, Intelligent Control and Energy Systems (ICPEICES-2016)

The pendulum link and weight combined has the mass and from (3), (4) and (5), we get
Mp and a total length of Lp and can rotate freely in the vertical ( Jo q +MpT � ) Ö Toutpu,+Mp ipTCOSo& - MplpTS i nao. �
=
(8)
plane. It sets up the angle a in the vertical direction. The
From (7) and (8), we obtain,
length from arm pivot to pendulum pivot is rand sets up the
1
angle e in the horizontal direction. The length from pendulum ä: =
ac -b
2 2
'cos-a
(adsiTIO: - b2 sino:cosoa2
centre of mass to its pivot is lp. Fig. 2 shows the calculation
model for inverted pendulum. Let the center of gravity of
- b e coso: & + bfcoso:Vm )
pendulum is at point B. Then the rotational velocity of point (9)
B with respect to 0 has following components
.
and
. 1
e ac _ b2 coS2 o. ( bcsi na:a2 I bdsi nacosa:
L,
=

\ (10)

The specifications of the ROTPENT system parameters,


given in Table 11, are taken from [ 2]. The linear model is
Fig. 2: Rotary Pendulum Calculation Model TABLE 2: ROTPENT MODEL PARAMETER AND PWM POWER AMPLIFIER
SPECIFICATIONS [2]
{XB = re - lp o:cosa:,
Symbol Description Value Unit
YB = -lp o: sina: Rm Motor armature resistance 8.7 n

re --: ;pä:co�.o: + lpa2 sino: ,


(1) Kr Motor current-torque constant 0.03334 N-m
Differentiating (1), we obtain Kill Motor back emf constant 0.03334 V/(rad/s)

{�
YB
B =

-lpO: - lp o:szno:
.
JIII Moment of inertia of motor rotor
Equivalent moment of inertia about
I:8xI0'o kg:m'

=
(2) Jeq motor shaft pivot axis with pendulum 1:84xI0' kg:m'
4
assembly
r Length of arm pivot to pendulum pivot 0.0826 m
Mp Mass ofpendulum link and weight 0.0270 Kg
combined
Lp Length ofpendulum center ofmass 0.153 m
from pivot
Jp Pendulum moment of inertia about its 1:70xI0' kg:m'
4
pivot axix
-'-.
Obtained by linearising the non-linear model given by
(10) about the equilibrium point at
Fig. 3: Free Body Diagram for Pendulum and arm
and after substituting the
Now, Fig. 3 describes forces acting on the arm and the value of the system parameters the following linear state

{LFr
-
pendulum. From that we obtain,
= I\'{P�B = '-'''{prO � ;"lplp&GO�O!+ Mpipc. � 8ina,
space model is obtained.

LFy AfpYB - -Mp lpQ - Afplpo smo. + Mp g


(3)
As frictional coefficients are negligible, applying the
Euler equation to the rotational motion of pendulum around
point B, we obtain,
JpÜ = l:: Fx lpw!;ll + l:: Fy/p!;üu.x
(4)
0,

L Fx r
and from the rotational motion of arm around point
(11)
we have,
JeqÖ = Tou.t put - III. Two Loop PID CONTROL
(5)
here A PID control, commonly used in industries, is given by.
Kt(Vm - RTf/i) rlp.
Tautpu t =

(6)
u ( t) = kp e(t ) - k,
10, o
e (T)d(T) + kr--:
dt
(12)
Now, solving (3) and (4), we get where, kp is proportional gain, kr is integral gain, and kd
( J1' + Ml'l�)ä = Ml' ll' rcoso.& + Mp g/l's i no.
(7)
is derivative gain. The controller has been designed using
SISO tool in MA TLAB. At first, a single PID controller has

[2)

Authorized licensed use limited to: Universidad Nacional Autonoma De Mexico (UNAM). Downloaded on March 22,2023 at 01:22:43 UTC from IEEE Xplore. Restrictions apply.
t
1s IEEE International Conference on Power Electronics, Intelligent Control and Energy Systems (ICPEICES-2016)

been designed taking pendulum angle as the only output. So, with single PID is not feasible to implement on the system
plant transfer function taking pendulum angle as output is 1l.
obtained from (11) and is given by (l3). Therefore, a two loop PID structure is used where two
a( s ) 7 . 31s - 3 . 2 46 e - 01 5 PID controllers are implemented. At first the controller for
G( s) = -- = --;;------,---- ,- pendulum position is designed as done previously and then
,.;3 + O .5728,.;2 83, 4 b
Vm(,.;) 28. 94 -
(13) another controller is designed for controlling the arm position
The root locus plot of (13) is shown in Fig. 4. To make for which the plant dynamics is the e10sed inner loop system
the system stable a PID controller with in series with the arm mechanism. So, the open loop transfer
-� function (Gel) to control is given by (14). The root locus is
�r- -' ' -'1'- given in Fig. 8.
I'
Ci'"

�'" vr------! �"


�'�
i",�
I
§
78
1

�m
� 1'------1
�'76 :!J

1 ".

\
f 1 1�.l-�,---
---c --; , ----!-
---- -;- , ----!-
, ---;----!----:-----!
- -�o!--!--!------"
-;- , ----!-
, ---;- - , """'.
, ....,. . :-,.
--., ......-!
time(s) tlme(s)
(a) (b)

"
; Fig. 6: Simulation Results of Close Loop System with a Single PlD:
(a) Pendulum Angle, (b) Arm Angle

.,I\r-----'\

Fig. 4: Root Locus Plot for Open Loop System Taking Pendulum Angle
as the Output

I7IO�---';----;---:-'----!- , --;---:--:-� ·'.-)o)--�:---;'---:,---:-


, --:-, ----!-
, --:-, --:-, �..
300(1 + 0 . 1s)(1 + 0. 091s) , ----!-
time(s) time(s)

,G e = -�-----"--'--------"'--- (al (b)


S
Fig. 7: Simulation Results of Close Loop System with a Single PlD and
is designed with parameters kp = 57:3; k, = 300; kd = 2:73 Added Disturbance at (=5s; (a) Pendulum Angle, (b) Arm Angle
and the root locus ofGGc is shown in Fig. 5. The simulation
9 (8 ) N (s)
-Gel =

Vm (s) D( s)
=

(14)
"
where, N (s ) = 17.18s6 + 9.842s5 - 2301s4 - 994, 5s 3 +
7,241e4s2 + 2,513e4s, and D ( s ) = s 8 + 21.1s7 + 263.8s6 +
614,8s 5 - 2.733e4s4 - 1.902e 5 s 3 - 6,263e4 82 + 2.81ge - 01 1 s

By examining the root locus it can be said that the


system can be stabilized if the negative gain is considered.
Now, adding a PI controller with kp = 3, and k, = 5 to the
1---+----0 <>-. - ....... .. ...---t--�·u
system is making it stable (Fig. 9). The simulation results
with two loop PID controller are shown in Fig. 10, where
..
disturbance is added at lOs and it is observed that the system
is stabilized even after adding the disturbance.

IV. FULL ST ATE FEEDBACK

Two controllers based on full state feedback are


considered here. These are (i) Pole-placement technique and
��:---��--���--,.�.---7.'''��4�--7---�--�,
�- (ii) Linear Quadratic Regulator (LQR). A brief summary of
these techniques is given below.
Fig. 5: Root Locus Plot for GGc
A. Pole-Placement Design
Results have been shown in Fig. 6. The e10sed system
response with the disturbance at time t=5s is shown in Fig. 7. The control is achieved by feeding back the state
We can see that although pendulum is balanced but arm is variables through a regulator with constant gains. Consider
constantly rotating in negative direction. Hence, the design the control system as

[3)

Authorized licensed use limited to: Universidad Nacional Autonoma De Mexico (UNAM). Downloaded on March 22,2023 at 01:22:43 UTC from IEEE Xplore. Restrictions apply.
t
1s IEEE International Conference on Power Electronics, Intelligent Control and Energy Systems (ICPEICES-2016)

the states are controllable. Two states, i.e., pendulum and arm
positions are measurable and other two states, i.e., pendulum
and arm velocity are estimated. The feedback gain matrix K
to stabilize the pendulum can be found as folIows.
Let the desired characteristic equation (CE) is taken
from the integral time absolute error (ITAE) table. The
coefficients that minimizes the ITAE performance criteria for
a step input for the general c1osed-loop system T(s), given
below are shown in Table m and T(s) is given as
. -. . .• _
.------

"
... -
4 •

Fig. 8: Root Loeus for Open Loop Plant Gel

"

Lf----
-- -------- l Fig. 10: Simulation Results with Two Loop PID Control with a Step
Disturbanee at t=IOs; (a) Pendulum Angle, (b) Arm Angle, (e) Control
Effort

TABLE 3: THE OPTIMUM COEFFICIENT OF T( S ) BASED ON ITAE


CRlTERlON FOR A STEP INPUT

S + Wn
s:A + ;
;.4;VnS +
W 3
s3 + 1.75wns- S- + 2.15wns + Wn

... ... s4 + 2 , lW"1, s 3 + 3.4w�s'J + 2,7w �s + w�


35 I 2. 8wns4 I 5, O"W�33 I 5.5w!�2 I 3.4"W�,g I w!.
s" + 3 . 2 5u'n s + 6.60w!s' + 8. 60w�s3 + 7. 4 5w � s 2 + 3.95w! s2
s + w!

{
Fig. 9: Root Loeus ofPlant with Two Loop PID Control Implemented
For the given plant, a 4th order CE with WI/ 10, i.e., / + =

X(t) = AX(t) + Bu (t), 21i + 340i + 2700s + 10000 is chosen. Hence, using

Ackerman's formula, the state feedback gain is obtained


Y(t) = CX(t)
(15) as K [-11:5192 85:0021-3:1435 10:5426]. The simulation
=

where the control input is given in (16) results of c10sed loop plant have been shown in Fig. 11.

u(t) -KX (t)


=
(16) B. Linear Quadratic Regulator
where K is a lxn vector of constant feedback gains. In optimal regulator design, we try to determine an
Now, substituting (16) into (15), the c1osed-loop system is optimal control law u*(x,t) which can transfer the system
given as from its initial state to the final state such that a given
X ( t) = (A - B K )X ( t) (17)
performance index is minimized. A widely used performance
index in optimal control design is the quadratic performance
The c1osed-loop system characteristic equation is
I sI BK I
index is based on minimum-error and minimum-energy
- A+ = 0 criteria [ 3]. Considering the plant described in (15), the
(18)
Here, the design objective is to find the gain matrix K problem is to find the feedback gain vector K(t) of the control
such that the characteristic equation for the controlled system law given by (16) which minimizes the value of a quadratic
is identical to the desired characteristic equation. In the case performance index J given in (19)
of rotary inverted pendulum system represented by (11), all

[4)

Authorized licensed use limited to: Universidad Nacional Autonoma De Mexico (UNAM). Downloaded on March 22,2023 at 01:22:43 UTC from IEEE Xplore. Restrictions apply.
t


1s IEEE International Conference on Power Electronics, Intelligent Control and Energy Systems (ICPEICES-2016)

J (" (XTQX + UT RU ) dt
.Jto
=

(19)
In (19), Q is a positive semi-definite matrix and R is a
real positive symmetric matrix. The constraint problem is
solved by augmenting (15) into (19) using an n-vector of
Lagrange multipliers A. The problem reduces to the
minimization of the following unconstrained function
T, (r., A , 1l,t) : x'j ' Q X +rfj ' Rr!] +.\ :I" [A X + RU - X]
=

(20)
After solving (20), we get
pet ) - P (t ) A + AT p et ) - Q + P ( t ) BR- 1 BT p et)
=

(21)
where, K K1BTp. The equation given by (21) is
=
.... - .... -
referred to as the Matrix Differential Riccati equation. For ""r--��-�---

linear time-invariant systems, when the process is of infinite


duration, h f> 0, and hence, (21) reduces to (22) and is
=

referred as Aigebraic Riccati Equation.


PA +A T p + Q - PBR-1 B T p =
(22)
0

For the given system, A and B are given by (11) and Q


h� Fig. 12: Experimental Results with 2 Loop PlD Control without

: [fTrr- : :::�
" d ' 'h "
Disturbances (Motor Voltage, Pendulum Angle, and Arm Angle,
Respectively)
:
o 0 0 0
Thus state feedback gain obtained from ARE is K [-

:--
=

6:3246 79:5802-2:7280 10:5426].


The simulation results of c10sed loop plant have been
shown in Fig. 11. ....- -,----: ------,'--,-
10'
-I", - ....

i'�
-hf -fsl �
r"''"
�IB'J
E ''''

-g ue
!C,�

"
1140
's
time{s) time(s)
<al (b)
-Iqr
-hf

Fig. 13: Experimental Results with FSF Control without Disturbances


(Motor Voltage, Pendulum Angle, and Arm Angle Respectively)

Since the linear model of the RIP system works weil for
a range of ± 30 deg, the controller is activated only when the
pendulum is within this range from its vertical upright
position. Figures 11-13 show the results of two loop PID,
time(s)
(c) FSF, and LQR control, respectively, without disturbances.
We can observe that two loop PID has very high overshoot as
Fig. 11: Simulation Results using FSF/LQR; (a) Pendulum Angle,
compared with other two control techniques. It takes a little
(b) Arm Angle, (c) Control Effort
time to stabilize the pendulum but continuous oscillations
V. RESULTS AND DISCUSSIONS exist even after the pendulum gets stabilized. These
oscillations are least in the case of LQR control as compared
All controllers have been implemented on the Quanser with two loop PID and FSF. Also, the control effort, i.e.,
ROTPEN trainer system and the experimental results (Figs. motor voltage is minimum in case ofLQR control. Fig. 14-16
11-16) show the control effort, pendulum angle, and arm show the results of two loop PID, FSF, and LQR control
angle of the pendulum with different controllers. respectively

[5)

Authorized licensed use limited to: Universidad Nacional Autonoma De Mexico (UNAM). Downloaded on March 22,2023 at 01:22:43 UTC from IEEE Xplore. Restrictions apply.
t
1s IEEE International Conference on Power Electronics, Intelligent Control and Energy Systems (ICPEICES-2016)

concluded that FSF and LQR are better than two loop PID,
but LQR is most efficient in terms of control effort and, the
oscillations in arm and pendulum. LQR is most robust against
disturbances in pendulum position.
--- ,...-.,.Tl.
.--.,-,...--- ..._

� � � � � � � � � .
f, ... W
� � � I� � � I� � ,h �
.-

Fig. 14: Experimental Results with LQR Control without Disturbances Fig. 16: Experimental Results (Motor Voltage, Pendulum Angle, and
(Motor Voltage, Pendulum Angle, and Arm Angle Respectively) Arm Angle Respectively) with FSF Control with Disturbances

Fig. 15: Experimental Results (Motor Voltage, Pendulum Angle, and Fig. 17: Experimental Results (Motor Voltage, Pendulum Angle, and
Arm Angle Respectively) with LQR Control with Disturbances
Arm Angle, Respectively) with 2 PlD Control with Disturbances

Along with disturbanees. The disturbance is added by VII. REFERENCES


giving a slight push to the inverted position of the pendulum
[ I] O. Boubaker, "The Inverted Pendulum Benchmark in Nonlinear Control
both positive and negative direction and the robustness is Theory: A Survey", Int J Adv Robotic Sy, vol. 10, no. 10, pp. 1-9,2013
tested for all three cases. It is found that LQR is more robust [2] Inc. Quanser, "Qnet Rotpen - User Manual", pp. 1-26,2011
against the disturbances in the pendulum position for both [3] D. S. Naidu, Optimal Control Systems First Edition,101-147,2003
positive and negative directions. Robustness is measured in [4] K. J. Astrom and K. Furuta, "Swinging Up a Pendulum by Energy
terms of maximum degree of angular displacement that the Control", Automatica, vol. 36, pp. 287-295,2000
pendulum can sustainve and negative direction from its [5] F. Gordillo, J. A. Acosta, and J.Aracil, "A New Swing-up Law for the
inverted stable position. A comparison of all three controllers Furuta Pendulum", International Journal of Control, vol. 76, no. 8, pp.

based on their experimental data has been done in table (IV). 836-844,2003

TABLE 4: COMAPRAlSON OF PlD, FSF, AND LQR [6 ] M. S. Park and D. Chwa, "Swing-up and Stabilization Control of
Inverted-Pendulum Systems via Coupled Sliding-Mode Control
Controller Seitling Overshoot Range of Range of Range Robustness
Method", lEEE transactions on industrial electronics, vol. 56, no. 9, pp.
Type Time (deg) Pendulum Arm Osc of Motor (deg)
3541-3555,2009
(s) Osc. (deg) Voitage
(de!!) (V) [7] M. Akhtaruzzaman and A. A. Shafie, "Modeling and Control of a
2100p 0.5 16.5 [-3.5,4.5] [-60,60] [-2.5,2] [-6,7] Rotary Inverted Pendulum Using Various Methods, Comparative
PlD Assessment and Result Analysis", IEEE International Conference on
FSF 0.3 -I [-4.5,5] [-18,27] [-2.2,2.2] [-12.5,16] Mechatronics and Automation, Xi'an, China, 2010
LQR 0.2 I [-3,2.21 [-28,181 1[-1.8,1.61 [-13,191
[8] A. Rahimi, K. Raahemifar, K. Kumar and H. Alighanbari, "Controller
Design For Rotary Inverted Pendulum System Using Particle Swarm
VI. CONCLUSION Optimization Algorithm", 26th lEEE Canadian Conference Of
Electrical And Computer Engineering, Toranto, Ontario, 2013
Here, different types of controllers are designed to
[9] C. G. Lhee, J. S. Park, H. S. Ahn, and D. H. Kim "Sliding Mode - Like
balance a rotary inverted pendulum with L-shaped arm
Fuzzy Logic Control with Self -Tuning the Dead Zone Parameters",
structure. All the controllers, i.e., two loop PID, FSF and lEEE Transaction on Fuzzy Systems, vol. 9, no. 2, pp. 343-348,2001
LQR are simulated and successfully tested on the
experimental setup. From the obtained results it can be

[6)

Authorized licensed use limited to: Universidad Nacional Autonoma De Mexico (UNAM). Downloaded on March 22,2023 at 01:22:43 UTC from IEEE Xplore. Restrictions apply.

You might also like