Professional Documents
Culture Documents
Pendulum System
Vinodh Kumar. E* Jovitha Jerome**
*Department of Instrumentation and Control Systems Engineering, PSG College of Technology, Coimbatore,
India- 641004 (vinothmepsg@gmail.com)
**Department of Instrumentation and Control Systems Engineering, PSG College of Technology, Coimbatore,
Abstract: This paper presents a Particle Swarm Optimization (PSO) based method to determine the optimal weights
of LQR controller for a Self Erecting Single Inverted Pendulum (SESIP). Normally, the weights of LQR controller
are selected based on trial and error approach and there is no specific rule for selecting the weights, which makes it
tedious to tune the controller for optimum performance. To overcome this problem, an intelligent approach
employing PSO based optimization is proposed. Swarm intelligence is used to obtain the optimal weights, which
provides superior performance than the conventional trial and error approach. In order to assess the performance of
the proposed approach, weight selection using GA is compared with the PSO. The performance of the controller is
evaluated not only for stabilizing the pendulum in upright position, but also for tracking the given reference signal.
Keywords: Inverted Pendulum, LQR Controller, Riccatti Equation, Particle Swarm Optimization, Genetic
Algorithm, Weighting Matrices
TABLE 1
List of parameters
K g x b1=RM r 2m + R g K 2g J
m= (6)
rm
2 2
b2=g K g m K t K m + Beq R r m
Therefore (5) can be rearranged to:
The nonlinear model of the inverted pendulum
g m K g K t ( r m V K g K m x ) motion can be derived using Lagranges equation.
F= For brevity, the nonlinear equation of motions can be
R r m2
obtained as follows:
(7)
K T B p M p gl sin =0
M p l x cos + ( I + M p l 2 ) +
Fa = g g a
rm (14)
(8)
The nonlinear model can be linearized which is valid
nd near the equilibrium point (upright pendulum) so that
Applying Newtons 2 law of motion to the motor
shaft:
sin = and cos =1 and also neglecting
higher order term. The linearized model is written in
state space in order to allow the design of state
J =T a feedback controller for upright pendulum
(9) stabilization.
[][ ][ ] [ ]
xc 0 0 1 0 xc 0
= 0 0 0 1 + 0 u
xc 0 2.2643 15.8866 0.0073 xc 2.2772
0 27.8203 36.6044 0.0896 5.2470
(16)
[]
xc
[
y= 1 0 0 0
0 1 0 0 xc ] LQR design specification
gbest= pbestdg , g { 1,2, n } , d { 1,2, . D } PSO algorithm stages for searching proper weighting
matrices are as follows:
Then, the new velocities and the positions of the First, the lower and upper bounds of the parameters
particles for the next fitness evaluation are calculated are specified and the population of the particles is
using the following two equations: initialized randomly. The controller gains are
calculated using LQR command in MATLAB
software. It is important to note that two conditions
v di ( t +1 )=w v di ( t )+ c1 rand 1 ( pbest di ( t ) xdi ( t ) ) + c2 det(R) d
rand 2 ( pbest
0 and ( ) x di (>t )0) must be satisfied. After
g tdet(Q)
(27) that, the control energy matrix (u) and state variable
x di ( t+1 )= xdi ( t ) +vid ( t+1 ) (28) (x) are calculated. Then, the linear quadratic cost
function (J) is evaluated for each particle. If the cost
Where is the inertia weight factor, c1 and c2 are for local best solution is less than cost of the current
constants known as acceleration coefficients, and are global best solution, the global solution is replaced
two separately generated uniformly distributed with the local solution. In each stage, the program
random numbers in the range [0, 1]. Motivated by the saves the cost value and minimum error value and
desire to better control the scope of the search, Shi according to equation (26). If the number of iterations
and Eberhart [20-21] have observed that the optimal reaches the maximum designated by the user, the
solution can be improved by varying the value of the latest global best solution is recorded and the
inertia weight from 0.9 at the beginning of the algorithm comes to the end. The pseudo code of the
search to 0.4 at the end of the search for most PSO based LQ regulator is given as follows:
problems. For each particle:
Initialize each particle
PSO Steps End
Do
The steps of particle swarm optimization algorithm For each particle:
are as follows [22]: Solve P from algebraic Riccati equation (26)
Calculate the feedback gain K by (25)
1. Initialize n number of particles with random Calculate the Integral Absolute Error (IAE),
positions x and velocities v on D dimensions in the x
search space. 2
( d (i ) x (i )) , xd is the desired state
2. For each particle, evaluate the desired optimization E IAE=v
fitness function in D variables. i
trajectory. If the present IAE value is less than the such as GA and trial and error. The settling time of
previous best IAE value, update the present value the system for PSO tuning is also lesser which makes
(pbest), set current value as the new pbest. the pendulum system to stabilize in minimum time.
End When the upright position has been reached, the
Choose the particle with the minimum IAE value system is switched to stabilizing control mode to
of all the particles as the gbest. stabilize the pendulum. By proper selection of the
For each particle: weight matrices in LQR design, the optimal control
Calculate particle velocity by (27). signal is generated which can satisfy the design
Update particle position according to (28). criteria mentioned in section1. The optimal values of
If one of the elements of the Q and R is Q and R obtained manual tuning are obtained as
negative, retain the current particle position
[ ]
End
Until the stopping criterion is met. 2.5 0 0 0
0
Q= 0
In order to investigate the performance of PSO 8 0 R= [ 0.0001 ]
algorithm for determination of proper weighting
0 0 0 0
matrices in LQR controller design, the simulation is
carried out and the results are compared with the 0 0 0 0
results obtained by GA.
The corresponding feedback gain vector for the
weighing matrices is
6. SIMULATION RESULTS
The PSO based optimization and simulation work is
K=[ 158.11 390.40 116.01 38.67 ]
facilitated by Matlab 2006. For simulation purposes,
the pendulum is swung-up from the rest (downward GA
pendulum) by giving sinusoidal input. The travel The parameters used in GA are population size=50
distance of the cart is limited by the amplitude of the chromosomes, cross over rate=0.96, mutation
reference input to 0.3 m . Once the pendulum rate=0.1, search interval=[0,20] and generation
achieves the upward position, the control is number=60. The Q and R matrices determined by
transferred to stabilizing controller which maintains Genetic Algorithm are
the pendulum in upright position. The pendulum
[ ]
angle response of the system for the weights obtained 1 0 0 0
by three methods such as PSO, GA and trial and error 0 0
is shown in Figure 6. The swing up controller is able Q= 0 4.5 R= [ 0.0003 ]
to swing up the pendulum to upright position in less 0 0 0 0
than 5 sec. 0 0 0 0
1
GA
0.8 Trial and Error The corresponding feedback gain vector is
PSO
0.6
0.2
[ ]
-0.8
-1
0 5 10 15 20 25 30
0.4 0 0 0
0 0
Q= 0 4.5
Time (s)
R= [ 0.0002 ]
Figure 6: Pendulum Angle 0 0 0 0
It is observed that the optimal weights obtained using
0 0 0 0
PSO algorithm has a maximum deviation of 0.2
degrees which is lesser than other two approaches The corresponding feedback gain vector is
K=[ 91.29 207.22 65.95 23.50 ]
In this paper, a PSO based optimal weight selection
25
PSO
of LQR Controller to stabilize the pendulum system
20 GA in upright position and to achieve the trajectory
TrialandError
15 ReferenceSignal
tracking has been presented. This approach has been
motivated especially by the fact that the designers
Cart position (cm)
10
often have to face trial and error approach to
5
determine the optimal weighting matrices in case of
0 LQ regulator design. The linearized model of
5 inverted pendulum is obtained to implement the state
10 feedback controller. The effectiveness of the
15
proposed control scheme is compared with the GA
based tuning of LQR and trial and error based
20
approach of LQR tuning. Simulation results
25
0 5 10 15 20 25 30 demonstrate that the proposed method is more
Time (s) efficient and robust compared with other heuristic
Figure 7: Cart Position method i.e., Genetic Algorithm (GA) method. It is
also observed that the speed of computation in PSO is
The reference signal tracking ability of the pendulum very less compare to GA and trial and error method.
system is shown in Figure 7. The overshoot and
settling time in case of PSO tuning is found to be less REFERENCES
compared to other two methods.
Table 2 1. Jia-Jun Wang, Simulation studies of inverted
Comparison of Performance Index of Tuning pendulum based on PID controllers, Simulation
Methods Modelling Practice and Theory, pp. 440449,
Performance Trial and 2011.
PSO GA 2. K.J. strm, K. Furuta, Swinging up a
Index Error
IAE 0.9897 1.022 1.045 pendulum by energy control, Automatica 36 (2)
(2000) 287295.
In order to assess the performance of the controller, 3. P. Mason, M. Broucke, B. Piccoli, Time optimal
the Integral Absolute Error is calculated for all the swing-up of the planar pendulum, IEEE
three methods and it is given in Table 2. The value of Transactions on Automatic Control 53 (8) (2008)
IAE in case of PSO is the least among the three 18761886.
methods and it corroborates for the better 4. C.W. Tao, J.S. Taur, T.W. Hsieh, C.L. Tsai,
performance of the PSO tuning. Design of a fuzzy controller with fuzzy swing-
up and parallel distributed pole assignment
schemes for an inverted pendulum and cart
7. CONCLUSION
system, IEEE Transactions on Control Systems system, IET Control Theory and Application 1
Technology 16 (6) (2008) 12771288. (4) (2007) 979986.
5. R. Shahnazi, T.M.R. Akbarzadeh, PI adaptive 9. Kalman, R. E., When is a linear control system
fuzzy control with large and fast disturbance optimal?, J. Basci Eng. Trans., ASME-86D:51-
rejection for a class of uncertain nonlinear 56,1964.
systems, IEEE Transactions on Fuzzy Systems 10. Wang Yaoqing, The determination of weighting
16 (1) (2008) 187197. matrices in LQ optimal control system, ACTA
6. N.A. Chaturvedi, N.H. McClamroch, D.S. Automatic Sinica, 1992.
Bernstein, Stabilization of a 3D axially 11.Johnny Lam,Control of an inverted pendulum,
symmetric pendulum, Automatica 44 (9) (2008) http://www.ece.ucsb.edu/~roy/student_projects/
22582265. Johnny_Lam_report_238.pdf
7. R.J. Wai, L.J. Chang, Adaptive stabilizing and 12. Mahmud Iwan Solihin, Rini
tracking control for a nonlinear inverted- Akmeliawati, Particle Swam
pendulum system via sliding-mode technique, Optimization for Stabilizing Controller
IEEE Transactions on Industrial Electronics 53 of a Self-erecting Linear Inverted
(2) (2006) 674692. Pendulum, International Journal of
8. L.H. Chang, A.C. Lee, Design of nonlinear Electrical and Electronic Systems
controller for bi-axial inverted pendulum Research, Vol.3, June 2010.
13. A.N.K. Nasir, 1M.A. Ahmad and M.F. Rahmat, 19. A.P. Engelbrecht, Particle swarm optimization:
Performance Comparison between LQR and where does it belong? in Proc. of the IEEE
PID controller for an Inverted Pendulum Swarm Intelligence Symposium 2006 (SIS'06),
system International Conference on Power May 2006, pp. 48-54.
Control and Optimization, Chiang May, 20. J. Kennedy, and R. Eberhart, "Particle swarm
Thailand, 18-20, July 2008. optimization," Proceedings of the IEEE
14. S. Mobaieen, B. Mohamady, H. Ghorbani and A. International Conference on Neural Networks
Rabii, Optimal Control Design Using (ICNN), Vol. 4, Nov. 1995, pp. 1942-1948.
Evolutionary Algorithms with Application to an 21. R. Eberhart, and J. Kennedy, "A new optimizer
Aircraft Landing System, Journal of Basic and using particle swarm theory," in Proc. 6th Int.
Applied Scientific Research, 2012. Symp. Micro Machine and Human Science
15. G. K. Venayagamoorthy, and R. G. Harley (MHS), Oct. 1995, pp. 39-43.
Swarm Intelligence for Transmission System 22. Che-Cheng Chang , Jichiang Tsai and Shi-Jia Pei
Control, Proceedings of the IEEE Conference on ,A Quantum PSO Algorithm for Feedback
Power Engineering, 2007. Control of Semi-Autonomous Driver Assistance
16. Y. Shi and R. C. Eberhart, Empirical study of Systems, 12th International Conference on ITS
particle swarm optimization, in Proc. IEEE Int. Telecommunications, 2012.
Congr. Evolutionary Computation, vol. 3, pp. 23.S. Yang, M. Wang, and L. Jiao, "A quantum
101106, (1999). particle swarm optimization," in Proc. of the
17. J.Hamidi, Control System Design Using IEEE Congress on Evolutionary Computation
Particle Swarm Optimization, International (CEC), Vol. 1, pp. 320-324, June 2004.
Journal of Soft Computing and Engineering
(IJSCE, ISSN: 2231-2307, Volume-1, Issue-6,
January 2012.
18. Ker-Wei, Yu, Zhi-Liang, Huang, LQ Regulator
Design Based on Particle Swarm Optimization,
Proceedings of the IEEE Conference on Systems,
Man, and Cybernetics, October, 2006.