You are on page 1of 6

2009 IEEE/ASME International Conference on Advanced Intelligent Mechatronics Suntec Convention and Exhibition Center Singapore, July 14-17,

2009

Adaptive PID with Sliding Mode Control for the Rotary Inverted Pendulum System
T. C. Kuo, Member, IEEE and, Y. J. Huang, Member, IEEE, and B. W. Hong
damages the mechanism. To improve the chattering phenomenon, many approaches were proposed, such as [10-13]. In this paper, we further propose adaptive PID sliding mode controller. We use sliding mode control to handle the nonlinear time varying part, and use adaptive law to tune up the system parameters online. The PID controller is used to achieve the satisfactory system performance. We adjust parameters of PID controller online by adaptive law and simulate with rotary inverted pendulum control system, which is a typical non-linear instable system and possessing control difficulty. The simulation result demonstrates that the proposed control method is indeed effective. II. ROTARY INVERTED PENDULUM DYNAMICS As shown in Fig. 1 is the sketch of the considered rotary inverted pendulum [14]. By applying the Lagrange equation [15-17], d T T V (1) + =i , & dt i i i where T is kinetic energy; V is potential energy; i is included angle of i link; i is the moment of force of i link, one can get 1 & sin 2 + l & cos 2 T = m1 lc1 c 1 1 1 1 1 2 1 & l sin & l cos cos + &l sin sin 2 + m2 1 1 c2 1 1 c2 11 2

AbstractIn this paper, a novel adaptive PID with sliding mode control for the rotary inverted pendulum is proposed. The goal is to achieve system robustness against parameter variations and external disturbances. In this study, the three parameters of PID controller, proportional gain, integral gain, and derivative gain can be systematically obtained according to the adaptive law. Further reduction of the high frequency chattering in the controller is achieved by using the boundary layer technique. The proposed control method is applied to a rotary inverted pendulum control system. By using Lyapunov theorem, the stability and convergence of the proposed scheme is proven. Simulation results show that the chattering and the steady state error are eliminated and trajectory tracking is achieved effectively.

HE Proportional-Integral-Derivative (PID) controller has been proposed for a few decades. Up to now, PID controllers are still popular in industrial fields. However, the control systems include nonlinear, time varying, coupling, structure uncertainty, and so on, that are not simple enough for designing the PID controllers. Tuning the proportional gain KP, the integration gain KI, and the differentiation gain KD becomes a subject worth exploring. In the past, most PID controller parameters were determined as fixed values. When the controlled systems are affected by external interference or influence, the controller would not be able to achieve effective control. In recent years, many robust control theories have been proposed, such as neural network control [1, 2], adaptive control [3], genetic algorithms control [4, 5], fuzzy control [6, 7], and sliding mode control [8, 9]. With the sliding mode control, the control system is robust to external interference and variation parameters. However, the sliding mode control law generates a large control gain and causes the chattering phenomenon. In hardware, the high frequency chattering
Manuscript received January 31, 2009. T. C. Kuo is with the Department of Electrical Engineering, Ching Yun University, 229 Chien-Hsin Rd., Chungli 320, Taiwan (corresponding author to provide phone: +886-34581196; fax: +886-34594937; e-mail: tck@ mail.cyu.edu.tw). Y. J. Huang and B. W. Hong are with Department of Electrical Engineering, Yuan Ze University, 135 Far-East Road, Chungli 320, Taiwan (e-mail: eeyjh@saturn.yzu.edu.tw, s968505@mail.yzu.edu.tw).

I. INTRODUCTION

) (

inverted pendulum; l1 is length (m ) of rotary arm, l2 is mass of rotary arm to the extreme point; lc 2 is distance (m ) length (m ) of inverted pendulum, lc1 is distance (m ) of

where m1 is mass (kg ) of rotary arm, m2 is mass (kg ) of

V = m2 glc 2 (1 sin ) .

( &l cos )2 + 1 J &2 + 1 J &2 , + ( c2 2 11 2 2

& l cos & & l cos sin &l sin sin + 11 1 1 c2 1 1 c2

(2) (3)

of mass of inverted pendulum to the extreme point; J 1 is inertia rotary kg m 2 of rotary arm; J 2 is inertia rotary

978-1-4244-2853-3/09/$25.00 2009 IEEE

1804

rotary arm, 2 is angle (rad ) of inverted pendulum; the symbol is defined as


& is angle velocity 2 ; 1 2 (rad / sec ) of rotary arm; &2 is angle velocity (rad / sec ) of

(kg m )
2

of inverted pendulum, 1 is angle (rad ) of

Rm 1 2 &1 sin(2q1 ) + m2 l1lc 2 q & 2 sin q2 m2 l c 2 q , (13) kb 2 1 2 &1 cos(2q2 ) , C21 = m2 lc (14) 2q 2 C22 = 0 , (15) C12 =
G1 = 0 , G2 = m2 glc 2 sin q2 .

inverted pendulum; and

(m / sec ).
2

is gravity acceleration

(16) (17)

Rewrite 2 =

, then Eqs. (1)-(3) turn out to be 2 2 2 2 2 && && m1lc 1 + m2l1 + m2lc 2 sin 2 + J 1 1 + (m2l1lc 2 cos 2 ) 2 & & + m l l sin &2 = m l 2 sin (2 ) (4)

III. ADAPTIVE PID SLIDING MODE CONTROLLER Consider a system of rotary inverted pendulum and dynamic function expressed as (7). First, define the tracking error of system follow as e = yd y , (18) where y d = [ y d 1 joint.
y d 2 ]T are the desired output of each

2 c2

1 2

2 1 c2

2 2

2 && + (m l 2 + J ) && 1 (m2l1lc 2 cos 2 ) &12 1 2 c2 2 2 m2lc 2 cos(2 2 )

+ m2 glc 2 sin 2 = 0 . (5) The input signal is the voltage feeding into the rotary inverted pendulum. A voltage signal is supplied to a PWM driver amplifier which drives the servo-motor to control the pendulum. The relationship of control input 1 and voltage v is

1 =

kb k2 &1 . v b q Rm Rm

(6)

y q y = 1 = 1 . (19) y 2 q2 In order to set up the error dynamic function, define x r R 2 as &r = & &d + K1e & + K 0e , x y (20)

where

where Rm is the armature resistance. Let q1 = 1 and


q2 = 2 . Eqs. (4)-(6) can be rewritten as && + C (q, q & )q & + G (q ) = u M (q )q

K1 = diag [k11 , k12 ] k1i = 2 ini , i = 1,2 . K 0 = diag [k11 ,


2 ,i k 02 k 0i = ni

(21) (22)

= 1,2 .

(7)

where

M M (q ) = 11 M 21

M 12 C12 C & ) = 11 , C (q, q M 22 C21 C22

& q q G v & = 1 and G (q ) = 1 , u = q = 1 q &2 0 q2 q G2 && q && = 1 . All elements are: q & &2 q R 2 2 2 2 M 11 = m m1lc 1 + m2 l1 + m2 l c1 sin q2 + J 1 , kb

The symbol i is the damping ratio and ni is the natural frequency, i = 1,2 . Generally, designing sliding mode controller has two steps. First, define the sliding function. Second, derive the control law. Define sliding function as = x2 xr , (23)
&1 q & 2 ]T . where x 2 = [q & = 0 , and When the sliding mode is met, &2 = x &r . x

(24) (25) (26)

(8) (9) (10) (11)

M 12

R = m (m2 l1lc 2 cos q2 ) , kb


2 m2l2

M 21 = m2 l1lc 2 cos q2 , M 22 =
C11 =

Substituting (20) to (24) yields &2 = & &d + K1e & + K 0e . x y Rewrite (25) to obtain && + K1e & + K 0e = 0 . e

+ J2 ,
2 kb

Rm kb

1 2 m2 l c , & 2 sin (2 q2 ) + 2q 2 Rm

(12)

If k1i and k 0i are positive, the control system is stable. Next, choose the control law u as u = u S + u PID , (27) where

1805

v K e + K I edt + K D e & , u PID = PID = P 0 0 v ( vPID + K 2 )sgn( 1 ) uS = S = , 0 0


K2 & r + Cxr ) T (G + Mx k P2 ]

(28)

If converge velocity 2 is more slower than 1 , the

2 1

where

K D = [k D1

K P = [k P1

1
,

(29) ,

k D 2 ] , and the function sgn() is

K I = [k I 1 k I 2 ]

+ 1, > 0 sgn( ) = . (30) 1, < 0 The proposed adaptive law to online tuning K P , K I and
K D to obtain better effect of control are & = e , i = 1,2 , k
Pi Pi i i

where 1 = [1 11 ] and 2 = [22 33 ] . Choose control law u as ~ +u ~ , u =u S PID where ~ & ~ = v PID = K P e + K I edt + K D e , u PID 0 0

may be a larger and cause system instability. Therefore, define the sliding function as ~= e (37) 1 & + 2e ,

(38)

(39)

M + M ~ = u 11 11 21 S
' '

) (k + M
1

' PID sgn( ) ,(40) + 11M 21 0 ' 11

(31) (32) (33)

& = e dt , i = 1,2 , k Ii Ii i i & = e k Pi Di i &i , i = 1,2 ,

&&d + 1 M 1Cq & + 1 M 1G + 2 q &d 2 q & . k 1q

(41)

and K D = [k D1

In the equation (39), K P = [k P1

k D 2 ] . Here we modify the tuning rules of

k P 2 ] , K I = [k I 1 k I 2 ]

where Pi , Ii and Di , i = 1,2 , are tuning constants.


Theorem 1. Consider the dynamic equation of rotary inverted pendulum (7) and use the control input (27)-(29) and adaptive control law equation (31)-(33). The control system is stable. Proof. Choose a Lyapunov function as 1 V = T M . (34) 2 Differentiating (34) obtains & v & + Cx ) , V (v + K ) + T (G + Mx
1
PID

K P , K I and K D by adaptive laws to achieve better result

of control. The adaptive laws obtained by chain rule is as following, & = M ' + c M ' e , k (42) P1 P1 11 11 21 1 & = M ' + c M ' e , k (43) P2 P2 11 11 21 2

PID

(35) & Base on Lyapunov stability theorem, if V > 0 and V 0 , the stability of the control system will be improved. The Lyapunov function will decrease to zero so that tracking error decrease to zero.

0.

( ) & = (M + c M ) e dt , k & & , k = (M + c M )e & = (M + c M )e & , k


& = M ' + c M ' e dt , k I1 I1 11 11 21 1
I2 I2

( (

) )

(44) (45) (46) (47)

' 11

11

' 21

D1

D1

' 11

11

' 21 1 ' 21

D2

D2

' 11

11

where Pi , Ii and Di , i = 1,2 , are the learning rate. The


of M 1 is determined as component M ij M M 12 M 1 = 11 . M 22 M 21 Choose a Lyapunov function as ~ 1 ~2 V = . 2 Differentiating (49) yields ~ & ~ ' ' ~ ~ ~ & M' +c M' v V M 11 + 11M 21 v PID 11 11 21 PID

(48)

IV. FURTHER IMPROVEMENT OF THE ADAPTIVE PID SLIDING MODE CONTROLLER In previous section, Equation (29) implies & r1 + M 12 x & r 2 + C11 x r1 + C12 x r 2 1 G1 + M 11 x K2

( )

(49)

& r1 + M 22 x & r 2 + C 21 x r1 + C 22 x r 2 2 G2 + M 21 x . + 1

(36)

1 ~k + ~q & + 1M 1G + 2 q &d 2q &, 1 &&d + 1 M Cq

0. (50) Based on Lyapunov stability theorem, the Lyapunov

1806

function will decrease to zero so that the tracking error decreases to zero. The tracking command is y d 1 = 0.5 cos(1.25t ) . (51) The parameters of the sliding function and the control are 1 = [1 0.5] , 2 = [8 1] , and k = 5 . In order to reduce the input chattering, the saturation function is used to replace the sign function in (40). The function sat () is defined as + 1, 1 (52) sat = , 1 < < 1 . 1, 1 where is the boundary layer. In this simulation, is equal to 0.1. The results of simulation are shown in Figs. 2 to 11. Figs. 2 and 3 are the tracking performance of rotary arm and inverted pendulum respectively. The performance of the control input v is shown in Fig. 4. The performance of the sliding function is shown in Fig. 5. Figs. 6 and 7 are the proportional gains k P1 and k P 2 respectively. Figs. 8 and 9 show the integration gains k I 1 and k I 2 respectively. Figs. 10 and 11 are the differential gains k D1 and k D 2 respectively. It is clearly that the proposed adaptive PID sliding mode controller makes the system stable and robust effectively. The tracking performance is satisfactory. Most of all, the control gains KP, KI, and KD are determined online and converge very fast. V. CONCLUSION This paper proposes a novel adaptive PID sliding mode controller. This control method improves defect of traditional PID controllers. The controller involves adaptive laws to tune up the control gains KP, KI, and KD. Sliding mode control is applied. The rotary inverted pendulum control system is controlled effectively. The main advantage of the proposed control method is that PID controller gains can be obtained online and converge efficiently. Tracking performance can be guaranteed. ACKNOWLEDGEMENT The authors would like to thank National Science Council, Taiwan, for supporting this work under Contract NSC 97-2221-E-231-005 and NSC97-2221-E-155 -020 -MY2.

REFERENCES
[1] [2] [3] [4] S. Akhyar and S. Omatu, Self-tuning PID control by neural-networks, IEEE on Proceedings of 1993 International Joint Conference on Neural Networks, Vol. 3, pp. 2749-2752, 1993. S. Omatu and M. Yoshioka, Stability of inverted pendulum by neuro-PID control with genetic algorithm, IEEE World Congress on Computational Intelligence, Vol. 3, pp. 2142-2145, 1998. W. D. Chang and J. J. Yan, Adaptive robust PID controller design based on a sliding mode for uncertain chaotic systems, Chaos, Solitons & Fractals, Vol. 26, pp. 167-175, 2005. A. Altinten, S. Erdogan, F. Alioglu, H. Hapoglu, and M. Alpbaz, Application of adaptive PID control with genetic algorithm to a polymerization reactor, Chemical Engineering Communications, Vol. 191, pp.1158-1172, 2004. Y. Mitsukura, T. Yamamoto, and M. Kaneda, A design of self-tuning PID controllers using a genetic algorithm, Proceeding of the American Control Conference, Vol. 2, pp. 1361-1365, 1999. H. S Choi, Y. H. Park, Y. S. Cho, and M. Lee, Global sliding-mode control improved design for a brushless DC motor, IEEE Control Systems Magazine, vol. 21, pp. 27-35, 2001. S. Chiu, Using fuzzy logic in control applications: beyond fuzzy PID control, IEEE Control Systems Magazine, Vol. 18, pp. 100-104, 1998. U. Itkis, Control System of Variable Structure, John Wiley & Sons, New York, 1976. V. I. Utkin, Sliding Mode in Control And Optimization, Springer-Verlag, New York, 1992. Q. D. Zhang and S. K. Panda, Chattering-free and fast-response sliding mode controller, IEE Proceeding-Control Theory and Applications, Vol. 146, pp. 171-177, 1999. A. Ishigame, T. Furukawa, S. Kawamoto, and T. Taniguchi, Sliding mode controller design based on fuzzy inference for nonlinear Systems, IEEE Transactions on Industrial Electronics, Vol. 40, pp. 64-70, 1993. T. C. Kuo, Y. J. Huang, W. C. Huang, Y. R. Wu, and B. W. Hung, Fuzzy sliding mode control of a rotary inverted pendulum, 2006 The 14th National Conference on Fuzzy Theory and Its Applications, pp. B1-5-1-B1-5-5, 2006. T. F. Wu, P. S. Tsai, F. R. Chang, and L. S. Wang, Adaptive fuzzy CMAC control for a class of nonlinear systems with smooth compensation, IEE Proceedings-Control Theory and Applications, Vol. 153, pp.647-657, 2006 TeraSoft, Electro-Mechanical Engineering Control System Users Manual, 2005. J. J. Craig, Introduction to Robotics Mechanics and Control, Addison-Wesley, New York, 1989. M. W. Spong and M. Vidyasagar, Robot Dynamics and control, Wiley, New York, 1989. S. Awtar, N. King, T. Allen, I. Bang, M. Hagan, D. Skidmore, and K. Craig, Inverted pendulum systems rotary and arm driven a mechatronic system design case study, Mechatronics, pp. 357-370, 2002.

[5] [6] [7] [8] [9] [10] [11]

[12]

[13]

[14] [15] [16] [17]

1807

2
lc1
l1

J2 m2

m1 J1

lc 2

l2

Fig.1 Sketch of the rotary inverted pendulum


0.8 0.6 0.4 0.2 q1 (Rad) 0 -0.2 -0.4 -0.6 -0.8 q1 y d1

Fig. 4 Control input v of the rotary inverted pendulum.

10 15 time (sec)

20

25

Fig. 2 Tracking performance of the rotary arm.

Fig. 5 Performance of the sliding function .

Fig. 3 Tracking performance of the inverted pendulum. Fig. 6 Performance of the ratio gain KP1.

1808

Fig. 7 Performance of the ratio gain KP2.

Fig. 10 Performance of the ratio gain KD1.

Fig. 8 Performance of the ratio gain KI1.

Fig. 11 Performance of the ratio gain KD2.

Fig. 9 Performance of the ratio gain KI2.

1809