You are on page 1of 6

Sensors & Transducers, Vol. 156, Issue 9, September 2013, pp.

324-329

Sensors & Transducers


2013 by IFSA
http://www.sensorsportal.com

Digital Double-loop PID Controller


for Inverted Pendulum
Ming Li
College of Mathematics & Computer Science, Wuhan Textile University, Wuhan, 430070, China
Tel.: 0086-27-59367297
E-mail: lettermail.lm@gmail.com

Received: 5 June 2013 /Accepted: 25 August 2013 /Published: 30 September 2013

Abstract: Inverted pendulum system is a complicated, unstable and multivariable nonlinear system. In order to
control the angle and displacement of inverted pendulum system effectively, a novel double-loop digital PID
control strategy is presented in this paper. Based on impulse transfer function, the model of the single linear
inverted pendulum system is divided into two parts according to the controlled parameters. The inner control
loop that is formed by the digital PID feedback control can control the angle of the pendulum, while in order to
control the cart displacement, the digital PID series control is adopted to form the outer control loop. The
simulation results show the digital control strategy is very effective to single inverted pendulum and when the
sampling period is selected as 50 ms, the performance of the digital control system is similar to that of the
analog control system. Copyright 2013 IFSA.

Keywords: Inverted pendulum, Double-loop PID control, Digital control, Sampling period.

1. Introduction stage numbers, there have single, double and multi-


stage inverted pendulum systems; but according to
In the development of control theory, the the types of control electric motor, there have single
correctness and feasibility of the theory must be motor, multi motors etc. [1-3]. From 1960 s, there are
validated by a typical object. The inverted pendulum increasingly interests to research inverted pendulum
system, which can reflect some problems in control systems. L. F. Sun et al. [3] introduced some control
systems such as nonlinearity, robustness, stabilization, methods for inverted pendulum and holded that
and following control, etc., is an ideal platform to intelligent control method is better than linear control
carry out these experiments. The rocket's flight method. Some researchers [4-8] have developed
control can be simplified as an inverted pendulum some control strategies for the cart-pole inverted
system, so as the step robot control and the satellite pendulum system using fuzzy logic controller. Siuka
attitude control. Therefore it has remarkably et al. [9] deals with the application of energy based
theoretical and practical significances to research control methods for the inverted pendulum on a cart
how to control inverted pendulum systems. model and presented a swing up controller. There
Inverted pendulum is a kind of complicated, have been some studies [10-12] on PID methods for
unstable and multivariable nonlinear system. There the purpose of balance control of inverted pendulum
are many types of inverted pendulum systems. system. Also, some other people [13, 14] have
According to the shapes of the inverted pendulum, researched the adaptive control problems of inverted
there have linear type and ring type etc.; according to pendulum systems. Aguilar-Ibanez et al. [15] present

324 Article number P_1364


Sensors & Transducers, Vol. 156, Issue 9, September 2013, pp. 324-329

an output feedback stabilization method for the The transfer function of the linear inverted
Inverted Pendulum Cart system around its unstable pendulum is:
equilibrium point, and adapt an observer based
controller devoted to render the closed-loop system to X (s)
G(s)
the origin. Mladenov [16] had used two Neural F (s)
Network controllers to swing a pendulum attached to ml g (I ml 2 )s2
a cart from an initial downwards position to an
(MI Mml 2 mI )s4 b(I ml 2 )s3 (M m)m lg s2 bm lg s
upright position. But this works are based on state-
space representation, were focused on the analog PID (2)
controller which cant be implemented by the The control goal of the linear inverted pendulum
computer program easily. is to make the horizontal displacement of the cart
In this paper, under considering there exits the controllable while guaranteeing the pendulum
carts friction, in order to control the displacement of verticality. This problem is a type of classic control
the cart of the inverted pendulum system meanwhile systems with one input (external force F) and two
guaranteeing the pendulum verticality, the model of
outputs (angle of pendulum and car displacement
the single inverted pendulum system is divided into
x). In order to control two output parameters
two parts based on impulse transfer function. A novel
effectively, we must establish the mathematical
double-loop digital PID control strategy and how to
model of the linear inverted pendulum. According to
choose its sampling period are researched in this
formula (2), we can get two transfer functions for two
paper. Finally Use matlab/simulink to verify the
controllable parameters.
performance of the presented control strategy.
( s)
G1 (s)
F ( s)
2. Model of Linear Inverted
mls
Pendulum System
(MI Mml 2 mI )s3 b(I ml 2 )s2 (M m)m lg s bm lg
The single inverted pendulum system consists of (3)
a cart and a pendulum, as Fig. 1 (a) shows.
X ( s) ml g ( I ml 2 ) s 2
G2 ( s ) (4)
( s) mls 2

3. PID Controller
The PID controller consists of three components
that are proportion, integral and differential. The
mathematical expressions are
(a) (b)

Fig. 1. Single inverted pendulum system. 1 de(t )


u (t ) K P e(t ) e(t )dt TD
T I dt ,
(5)
By ignoring the air fiction and some minor U ( s) 1 KI
D( s ) K P (1 TD s ) K P KDs
fictions, the force diagrams of the cart and the E ( s) TI s s
pendulum are shown as Fig. 1 (b), where M is the
cart mass, x is the cart position, F is the force where
impacted on the cart, b is the cart friction coefficient,
m is the pendulum mass, 2L is the pendulum length, KP
is the included angle between the pendulum and KI , K D K PTD (6)
TI
the vertical direction, and I is the pendulum
rotary inertia.
If T denotes the sampling period, we can conclude
The dynamic models of the single inverted
the positional PID controller as
pendulum system are nonlinear differential equations.
If selecting the working points 0 0, x0 0 and k

linearizing the system, we have the simplified u ( k ) K P' e( k ) K I' e( j ) K D' e(k ) e(k 1) , (7)
j 0
mathematical models of the inverted pendulum
system. They are:
where

( I ml ) mlx ml g
2
T T K
(1) K P' K P , K I' K P TK I , K D' K P D D (8)
x bx ml F
( M m) TI T T

325
Sensors & Transducers, Vol. 156, Issue 9, September 2013, pp. 324-329

According to Z transformation, we can get the and two outputs, we can divide the mathematical
impulse transfer function of the digital PID controller model into two parts, as shown in equations (3) and
(4). When we use the double-loop PID controller, the
U ( z) inner loop controls the pendulum angle and the outer
D( z ) loop controls the cart horizontal position.
E( z)
(9) Fig. 3 shows the block diagram of the analog
( K ' K I' K D' ) z 2 ( K P' 2 K D' ) z K D' double-loop PID control system. In order to simplify
P
z2 z the computation, two PID controllers are all designed
as PD controllers. An amplifier G is placed in the
The block diagram of single-loop analog PID inner loop in order to suppress interference and unit
control system is shown in Fig. 2 that can only negative feedback is used in the outer loop in order to
control the displacement x of the car. obtain better following performance.

X(s) (s) X(s)


Xr(s)
PID1 Amplifier G G1(s) G2(s)
Xr(s) PID (s)
G1(s) G2(2)
controller PID2

Fig. 2. Single-loop PID control system for single Fig. 3. Analog double-loop PID control system
inverted pendulum. for inverted pendulum.

4. Double-loop Digital PID Controller Although the analog double-loop PID controllers
can make the performance of the inverted pendulum
As to single-loop PID control system, three
system good, they cant be implemented by computer
components, the proportion, integral, differential, are
easily and their development cost is very expensive.
located in the forward channel of control system. But
Therefore we must design a digital controller that can
as to double-loop PID control system, a PID
make the performance of the inverted pendulum
controller and the object can form an inner loop that
control system meet the control requirements. Based
can make the unstable object stable; in the forward
on the analog double-loop PID control system, we
channel of the control system, another PID controller
can get the control strategy of the digital double-loop
and the object form an outer loop that can make the
controller using sampling control theory that is
control system have the expected performance [17].
illustrated in Fig. 4.
Because the single inverted pendulum has one input

Xr(s) (s) X(s)


Digital PID1 Amplifier G ZOH G1(s) G2(s)

Digital PID2

Fig. 4. Structure of digital double-loop PID control system for inverted pendulum.

The sampling period T is a very important digital control systems will be improved, but the
parameter in digital control system. We must choose demands for the operation speed of computers are
the sampling period according to the performance higher, which lead to increase the development cost
requirements and the development cost of the digital of digital control systems. Furthermore, excessive
control systems. When the sampling period is larger, sampling period has little help to improve the control
the demands for the operation speed of computers are performance. Therefore the sampling period T must
lower, so it is helpful to cut down the cost of digital be chosen correctly. In this paper, we suppose the
controllers, but too large sampling period will inner loop and the outer loop in the digital double-
degrade the performance of control systems. While loop control system have the same sampling period.
the sampling period is smaller, the performance of

326
Sensors & Transducers, Vol. 156, Issue 9, September 2013, pp. 324-329

5. Simulation Analysis In order to obtain the control results of digital


double-loop PID control system, set the sampling
In order to compare and analyze the control period T as 100 ms, 90 ms, 80 ms, 50 ms, 10 ms and
results of these control strategies for linear inverted 5 ms respectively. According to equation (8), the
pendulum, Matlab/Simulink [18] is used to simulate. parameters of the digital PID controller will be
Suppose the parameters of the linear inverted obtained directly from the analog PID controller. The
pendulum are: M=1 kg, m=1 kg, 2L=0.6 m, results are shown in Table 1.
b=0.1 N/m.s, I=0.03 kg.m2. From equations (2), (3)
and (4), we can get: Table 1. Parameters of the digital PID controller.

X (s) 0.12 s 2 3 Sampling Digital PID1 Digital PID2


G (s) period T
F ( s ) 0.15s 4 0.012 s 3 6 s 2 0.3s KP1 KD1 KP2 KD2
100 ms 0.12 1.2 1.625 1.75
( s) 0.3s 90 ms 0.12 1.33 1.625 1.94
G1 ( s )
F ( s ) 0.15s 0.012 s 2 6 s 0.3
3 80 ms 0.12 1.5 1.625 2.19
50 ms 0.12 2.4 1.625 3.5
X ( s ) 0.12s 2 3 10 ms 0.12 12 1.625 17.5
G2 ( s) 5 ms 0.12 24 1.625 35
(s) 0.3s 2

The analog single-loop PID control system, When T is set as 100 ms, the simulation result is
illustrated in Fig. 2, can be simulated by Simulink. shown in Fig. 6 (a). While T is set as 90 ms and
The simulation results show that no matter how to 80 ms, the results can be seen in Fig. 6 (b). The
modify the parameters KP, KI and KD of the Fig. 6 (c) is the simulation results when T is set as
controller, the control system is always unstable, 50 ms, 10 ms and 5 ms.
which proves the single-loop PID controller isnt fit From the simulation results, we can get the
for the control of this type of inverted performance indexes of the digital double-loop PID
pendulum system. control system as Table 2 shows.
When simulation of analog double-loop PID
control system for the linear inverted pendulum, we
set the parameters of the control system as Table 2. Performance indexes of the digital
double-loop control system.
K p1 0.12, K D1 0.12 , K p 2 1.625, K D 2 0.175 and
G= -32. Then the step response of the control system Cart position x Pendulum angle
Sampling
can be get in Fig. 5, from which we can conclude that period Over- Setting Over- Setting
for the pendulum angle, the overshoot is 12.33 % and shoot time shoot time
the setting time is 3.12 s ( 2 %); as to the cart 100 ms Unstable Unstable Unstable Unstable
position, the overshoot is 15.55 % and the setting 90 ms 85.5 % 33.03 s 104.7 % 40.23 s
time is 6.15 s ( 2 %). The results show the analog 103.02
80 ms 50.6 % 5.92 s 4.64 s
double-loop PID controller is effective to control the %
linear inverted pendulum system. 50 ms 38.2 % 6.05 s 82.3 % 2.4 s
10 ms 38.5 % 6.13 s 60.7 % 2.46 s
5 ms 38.5 % 6.14 s 59 % 2.46 s

From Table 2, we can conclude that when


T=100 ms the digital control system is unstable;
When T=90 ms the control system become stable, but
the performances are very bad which means the
control system has little practical value; when
T=80 ms, the system performances is improved
greatly. When T is between 5 ms and 50 ms, we can
see that the performances of the digital control
system have little change and are very similar to
those of the analog double-loop control system.
The simulation results further prove that when the
analog control system is transformed into the digital
control system, the system performances will
degrade. So we must select the sampling time T
Fig. 5. Step response of analog double-loop correctly when we use digital control system. As to
PID control system. the single inverted pendulum, the controlled

327
Sensors & Transducers, Vol. 156, Issue 9, September 2013, pp. 324-329

parameter changes very quickly, so it is better that 6. Conclusions


the sampling time T is set as 50 ms. Finally we can
conclude that the digital double-loop PID controller The inverted pendulum system is a complicated,
is a good solution to control the single inverted unstable and multivariable nonlinear system that can
pendulum system. reflect many typical problems in control systems, so
researching inverted pendulum control system has
remarkably theoretical and practical significance.
Because the digital controller can be easily
implemented by the computer program, it is a cheap
controller and has very high practical value. The
research results in this paper show: the single-loop
PID controller is not suitable to control the single
inverted pendulum that is unstable and has one input
and multiple outputs. As to this type of problems, the
controlled objects can be divided into different parts
according to the numbers of the controlled
parameters and also different mathematical models
should be established. The digital double-loop PID
controller is a good solution for the single inverted
pendulum with one input and two outputs. For the
controlled parameter changes very quickly, it is a
good way that the sampling time T is set as 50 ms in
order that the digital control system has good
performance and cheaper cost.
(a)

References
[1]. H. M. Liu, C.-F. Zhang, Stability Control and
realization of single link rotary inverted pendulum on
LQR controller, Journal of Central South University
(Science and Technology), Vol. 43, Issue 9, 2012,
pp. 3496-3501.
[2]. H. Ashrafiuon, A. M. Whitman, Closed-loop
dynamic analysis of a rotary inverted pendulum for
control design, Journal of Dynamic Systems,
Measurement and Control, Transactions of the
ASME, Vol. 134, Issue 2, 2012.
[3]. L. F. Sun, H. Kong, C. G. Liu, Overview of the
control of the inverted pendulum system, Machine
Tool & Hydraulics, Vol. 36, 2008, pp. 306-310, 313.
[4]. S. Kizir, Z. Bingul, C. Oysu, Fuzzy control of a real
time inverted pendulum system, Journal of
Intelligent & Fuzzy Systems, Vol. 21, 2010,
(b) pp. 121-133.
[5]. M. K. B. M., Nor, S. Okubo, Fuzzy servo control of
an inverted pendulum system, Artificial Life and
Robotics, Vol. 17, Issue 2, 2012, pp. 245-250.
[6]. C. H. Huang, W. J. Wang, C. H. Chiu, Design and
implementation of fuzzy control on a two-wheel
inverted pendulum, IEEE Transactions on Industrial
Electronics, Vol. 58, Issue 7, 2011, pp. 2988-3001.
[7]. D. Wang, S. Wu, L. Zhang, et al., Study of inverted
pendulum robot using fuzzy servo control method,
International Journal of Advanced Robotic Systems,
2012.
[8]. H. L. Bui, D. T. Tran, N. L. Vu, Optimal fuzzy
control of an inverted pendulum, Journal of
Vibration and Control, Vol. 18, Issue 14, 2012,
pp. 2097-2110.
[9]. A. Siuka, M. Schberl, Applications of energy based
control methods for the inverted pendulum on a cart,
Robotics and Autonomous Systems, Vol. 57, 2009,
pp. 1012-1017.
(c)
[10]. A. Ghosh, T. R. Krishnan, B. Subudhi, Robust
Fig. 6. Step responses of digital PID controller. proportional-integral-derivative compensation of an

328
Sensors & Transducers, Vol. 156, Issue 9, September 2013, pp. 324-329

inverted cart-pendulum system: An experimental Proceedings of International Conference on Signal


study, IET Control Theory and Applications, Vol. 6, Processing Systems, Singapore, Singapore,
Issue 8, 2012, pp. 1145-1152. 15-17 May 2009, pp. 589-593.
[11]. S. Y. Yang, L. P. Xu, P. J. Wang, Study on PID [15]. C. Aguilar-Ibanez, M. S. Suarez-Castanon, N. Cruz-
control of a single inverted pendulum system, Cortes, Output feedback stabilization of the inverted
Control Engineering of China, Vol. 14, 2007, pendulum system: a Lyapunov approach, Nonlinear
pp. 23-24,53. Dynamics, Vol. 70, Issue 1, 2012, pp. 767-777.
[12]. T. C. Kuo, Y. J. Huang, B. W. Hong, Adaptive PID [16]. V. Mladenov, Application of neural networks for
with sliding mode control for the rotary inverted control of inverted pendulum, WSEAS Transactions
pendulum system, in Proceedings of the IEEE/ASME on Circuits and Systems, Vol. 10, Issue 2, 2011,
International Conference on Advanced Intelligent pp. 49-58.
Mechatronics, Singapore, Singapore, 14-17 July [17]. S. J. Song, J. L. Liu, Z. H. Zhang, A simple method
2009, pp. 1793-1798. for improving the performance of PID controller,
[13]. S. Rudra, R. K. Barai, Robust adaptive backstepping Drive and Control, Issue 5, 2007, pp. 32-35.
control of inverted pendulum on cart system, [18]. J. J. Wang, Simulation studies of inverted pendulum
International Journal of Control and Automation, based on PID controllers, Simulation Modelling
Vol. 5, Issue 1, 2012, pp. 13-26. Practice and Theory, Vol. 19, Issue 1, 2011,
[14]. M. Fallahi, S. Azadi, Adaptive control of an inverted pp. 440-449.
pendulum using adaptive PID neural network, in

___________________

2013 Copyright , International Frequency Sensor Association (IFSA). All rights reserved.
(http://www.sensorsportal.com)

329

You might also like