You are on page 1of 5

Advanced Materials Research Vol.

1037 (2014) pp 221-224 Submitted: 2014-06-25


© (2014) Trans Tech Publications, Switzerland Accepted: 2014-08-07
doi:10.4028/www.scientific.net/AMR.1037.221 Online: 2014-10-27

Design of LQR Controller for the Inverted Pendulum

Lili Wan 1,a, Juan Lei 2,b, Hongxia Wu 3,c


1
No.1 Culture Road, Zhifang Street, JiangXia District, Wuhan Donghu University, Wuhan City,
HuBei Province, China
2
No.1 Culture Road, Zhifang Street, JiangXia District, Wuhan Donghu University, Wuhan City,
HuBei Province, China
3
No.1 Culture Road, Zhifang Street, JiangXia District, Wuhan Donghu University, Wuhan City,
HuBei Province, China
a b c
173237883@qq.com, 5091026@qq.com, 12873624@qq.com

Keywords: Inverted Pendulum, LQR, Matlab Simulation

Abstract: For the instability of the inverted pendulum, a LQR controller is designed based on optimal
control algorithm in this paper, which can control the pendulum angle and the cart position at the
same time. The basic principle of LQR optimal control is analyzed and the LQR controller is designed
and simulated in this paper. The simulation results show that the designed controller is effective. It
has a good effect of equilibrium and stability control, and the system's anti-interference ability is
improved.

Introduction
The inverted pendulum is a typical experimental device of control theory. It has the advantages of
low cost and simple structure. But the system itself also has the typical nonlinear, strong coupling,
multi variable and unstable characteristics. As a controlled object, many abstract control concepts can
be expressed directly by the inverted pendulum. The control methods and control strategies excavated
from the inverted pendulum are widely used in aerospace, robots and general industry. For the
unstable inverted pendulum balancing control, can be applied to optimal control theory to design its
controller.

Analysis and basic principle of LQR optimal control


The linear two quadratic optimal control algorithms is a kind of important and basic method of the
modern control theory, whose purpose is the best control effect of the system with a fixed
performance index. In one word, achieve the minimum state error by least control energy.
Assuming the state equation of the linear constant system is
 X = AX + Bu
 (1)
Y = CX + Du
Two quadratic performance index function is
1 ∞
J = ∫ ( X T QX + U T RU ) dt (2)
2 0
Where, X is the state vector. U is the input vector. Q and R is the weighting matrix, which is used
to balance the state vector and the weight of the input vector. Q is positive semidefinite matrix. R is
positive definite matrix. When the system is subjected to external disturbance and deviate from the
zero state, the applied U can make the system back to zero state nearly and J achieve the minimum, it
called optimal control. By the optimal control theory, the optimal control law of the Eq.2 has a
minimum value is
U * = - R −1 B T PX = − KX (3)

All rights reserved. No part of contents of this paper may be reproduced or transmitted in any form or by any means without the written permission of Trans
Tech Publications, www.ttp.net. (ID: 128.119.168.112, Univ of Massachusetts Library, Amherst, USA-13/07/15,15:42:17)
222 Development of Applied Engineering Sciences

For linear systems, according to the selected Q and R, the feedback matrix K can obtained by using
the Matlab command lqr: K=lqr(A,B,Q,R)
Changing the values of the matrix Q, can get different response. Values of Q are larger, the
system's anti-interference ability is stronger, the adjustment time is shorter. But the Q is not too large.
It can't exceeds the capacity of the execution mechanism, and ensures that the amplifier in the
saturation state.

Design and Simulation of inverted pendulum LQR controller


Designed and adjusted the controller of inverted pendulum system using LQR method, can control
rod of the pendulum to keep upright balance, at the same time, it can track the position of the cart. The
inverted pendulum LQR control principle diagram is shown in Fig.1.
R v X = AX + Bu y
N
Y = CX
x
K
Fig.1 Block diagram of control system

Because the output feedback signal is multiplied by a coefficient matrix K, then subtraction with
input control signal, which makes the input dimension not consistent to the feedback dimension. In
order to make the input and feedback dimensional match each other, multiply the input signal by a
gain N .
The state equation of the system is show in Eq.1. The related parameters selection for the inverted
pendulum: the cart quality M=0.5kg, the pendulum quality m=0.2kgm, friction coefficient of the cart
b=0.1N/m/sec, the length of the pendulum rotation axis to the pendulum centroid l=0.3m, the
pendulum inertia I=0.006kg*m*m, sampling time T=0.005s. Then the state equation coefficient
matrix is:
0 1 0 0 0 
0 - 0.1818 2.6727 0  1.8182 
A= ;B =   ; C = 1 0 0 0 ; D = 0 (4)
0 0 0 1 0  0 0 1 0  0 
   
   
0 - 0.4545 31.1818 0 4.5455
The premise condition of the optimal control system is controllable. Then judge the system's
controllability.
The rank of the system's controllability matrix is rank [ B AB A 2 B A 3 B ] = 4 . The rank of the
system's observability matrix is rank[C CA CA 2 CA 3 ] = 4 . The system is controllable and
observable. So, add the optimal controller to the system to make it closed-loop stability and satisfied
the transient performance. When designing the LQR controller, it is important to obtain
feedback vector K. A key problem is the weighting matrices Q and R two quadratic performance
index function's selection. In order to simplify the problem, we select Q as the diagonal
matrix. Assume that
Q11 0 0 0 
0 Q 0 0 
Q=  22
; R = [r ] (5)
0 0 Q33 0 
 
0 0 0 Q44 
Then the performance index function is obtained as:

J = ∫ [Q11 x12 + Q22 x 22 + Q33 x32 + Q44 x 42 + ru 2 ]dt (6)
0
Advanced Materials Research Vol. 1037 223

So, Qii is the square of the weighted xi . The relative increase of Qii means the requirements of xi
relative strictly to other state variables. It's in a big proportion of the performance index. xi 's deviation
status reduce relatively. Considering the main controlled volume are x and φ in the inverted
pendulum system running process. When choose each element value of the weighted diagonal
matrices Q , Q11 represents the weight of the cart position. Q33 represents the weight of the pendulum
angle. So we only choose Q11 = 6000 , Q33 = 300 ,but Q22 = Q44 = 0 .
Using Matlab programming can be calculated:
1)The open loop poles are 0,5.5651,-1.1428,-5.6041. Visible, the system is open-loop unstable;
2)When R = 1 , getting feedback control vector K=[-77.4597 -41.3470 114.4822 22.5602];
3) N = -77.4597 ;
4)The step response of Matlab simulation map controlled by LQR controller is shown as Fig.2. In
the figure, solid line represents the cart position, the dotted line represents the pendulum angle.

Fig.2. The step response of Matlab simulation map

Conclusions
As the Fig.2 shows, the cart position tracking the input signal, and the pendulum overshoot is small
enough, the steady-state error meets the requirements, the rise time and stable time meet the design
index.

References
[1] Zhang Jing: Application of MATLAB in control system.(2007)
[2] Yi Jie, Xie Xianjin: Application of optimal control of inverted pendulum system
[3] Fan Xingzhe, Cheng Ning, Zhao Naiyao: Two Fuzzy Cascade Control Schemes of a Trip le
Inverted Pendulum[A].Proceedings of the 3th World Congress on Intelligent Control and Automation:
Vol 3 [C].Hefei:IEEE,2000,1721-1726
224 Development of Applied Engineering Sciences

[4] Mori Shoze, H. Nishihara and K.Furuta.Control of unstable mechanical system: Control of
pendulum [J]. Int.J.of Control 1976,23(5):673-692
[5] J.W.Watts. Control of an inverted pendulum. ASEE Annual Conference, session
2527,1984,706-710.
[6] Shuliang Lei, Reza Langari, Hierarchical Fuzzy Logic Control of a Double Inverted Pendulum.
C2000 IEEE
[7] Fuyan Cheng, Guomin Zhong, Youshan Li, Zhengming Xu. Fuzzy control of a double-inverted
pendulum. Fuzzy Sets and Systems,1996,79(3)
Development of Applied Engineering Sciences
10.4028/www.scientific.net/AMR.1037

Design of LQR Controller for the Inverted Pendulum


10.4028/www.scientific.net/AMR.1037.221

You might also like