Tuning of LQR controller for an experimental inverted pendulum system based on The Bees Algorithm
Hasan Huseyin Bilgic^{1} , Muhammed Arif Sen^{2} , Mete Kalyoncu^{3}
^{1}Department of Mechanical Engineering, Iskenderun Technical University, Hatay, Turkey
^{2, 3}Department of Mechanical Engineering, Selcuk University, Konya, Turkey
^{1}Corresponding author
Journal of Vibroengineering, Vol. 18, Issue 6, 2016, p. 36843694.
https://doi.org/10.21595/jve.2016.16787
Received 6 January 2016; received in revised form 21 June 2016; accepted 26 June 2016; published 30 September 2016
JVE Conferences
Stabilizing of an inverted pendulum (IP) system is a main problem for researchers working on control theory. Balancing of an inverted pendulum system is one of the major benchmark problems in the control system community. This paper presents optimal tuning of linear quadratic regulator (LQR) controller with The Bees Algorithm (BA) for a linear inverted pendulum. In this paper, a metaheuristic approach which is a natureinspired search method that mimics the foraging behavior of honey bees is used for design of LQR controller to obtain optimal performance. In LQR controller design, state (Q) and control (R) weighting matrices are basic parameters of LQR which are tuning by designer using trial and error method in usually. The Bees Algorithm optimizes the weighting matrices of the LQR controller so that it can move the cart to a desired position with the minimum change in pendulum’s angle from vertically upright position during the movement. The tuned LQR controller is benchmarked on the linear inverted pendulum experimental device (IP02) that is manufactured by QUANSER Company. After description of the system and The Bees Algorithm, the paper gives the experimental results obtained from the IP02 system to demonstrating the efficiency of the tuning of the LQR controller. Simulation and experimental results are given graphically to show the success of controller. As a result of the paper, the performance of LQR controller shows the effectiveness of The Bees Algorithm which is a diversity method for provide an efficient solution to conventional trial and error design approach.
Keywords: The Bees Algorithm, tuning of LQR controller, optimization, inverted pendulum.
1. Introduction
The stabilizing of an Inverted Pendulum system is noteworthy an issue in the field of control engineering. It is widely used as design and testing system for control algorithms due to its high degree of instability and nonlinearity. The dynamics of many mechanıcal systems (Two or one wheeled electric vehicle like Segway, selfbalancing robots, a booster rocket at takeoff etc.) are similar to the classic control problem of the inverted pendulum. With the recent studies (1) used inverted pendulum to modeling and stability of Humans Standing Posture, it is still an actually topic in science and technology. The experimental verification of simulation studies about improving the balance and of position control the inverted pendulum will increase its effectiveness on realistic applications. The nonlinear and unstable nature of the plant enables an impressive demonstration of the capabilities of feedback systems. For this reason, an inverted pendulum has been one of the main benchmark problems for verifying the performance and effectiveness of a new control method. This is attributed to a lot of engineering applications of the inverted pendulum based system, such as walking and selfbalancing robot, in missiles and rockets, jetpacks and transport vehicle like Segway etc.
There are a lot of controller techniques to stabilize an inverted pendulum. Some control types are modelbased control approach such as; classical PID, LQR, Robust control, [14]. The performance of classical controller depends on selection and tuning method of one or more design parameters which are commonly determined using customary techniques such as trial and error. The other control types are nonmodel based approach using artificial intelligent methods such as; Neural Network Control, Fuzzy Logic Control and Genetic Algorithms [5].
Selecting weighting matrices of LQR controller is important and difficult [6]. So that, tuning with an optimization algorithm of this matrices are very effective method. In order to improve the controller efficiency and the performance of the designed controller, the optimization of LQR controller parameters has been researched by many researchers. Tan has optimized the LQR controller with improved Particle Swarm Optimization (PSO) and has realized the stability control of the inverted pendulum [7]. Chen has analyzed the relationship between the weight coefficients in weight matrices (Q and R) and the control performance [8]. Wang has adopted an improved Genetic Algorithm (GA) to optimize the LQR parameters and has stabilized the circularrail double inverted pendulum [9]. As one of the most recent swarm intelligence approaches for realparameter optimization proposed by Karaboga, The Artificial Bee Colony (ABC) Algorithm is inspired by the intelligent foraging behavior of honeybee swarm and has been demonstrated its high performance over the Genetic Algorithm, Particle Swarm Optimization Algorithm [10]. The predictive PolePlacement (PPP) algorithm of Gawthrop and Ronco is a continuoustime basis functionbased approach. As discussed elsewhere, the number of basic functions is the order of the controlled system leading to a correspondingly small number of optimization parameters [11].
A lot of optimization techniques about the stabilizing control of an inverted pendulum system have been proposed. In this study, unlike purely simulation study, a LQR controller designed and optimized for an inverted pendulum experiment set (QuanserIP02) using The Bees Algorithm as a diversity method. The obtained experimental results will shape industrial applications and future studies. In order to improve the performance of LQR controller, weighting matrices are tuned with The Bees Algorithm and benchmarked on the experimental setup for stabilize control of the linear inverted pendulum system. The rest of the paper is organized as follows. In Section 2, after introduction, the linear inverted pendulum system is modeled. Section 3 presents the linear inverted pendulum experimental setup. Section 4 describes The Bees Algorithm and optimal tuning of LQR controller method. In Section 5, experimental results and discussions are provided. End of the paper, in Section 6, conclusions are given.
2. Modeling of the linear inverted pendulum
The mathematical model of experimental Inverted Pendulum system (IP02) manufactured by QUANSER Company [12], shown on Fig. 1, consist of cart and pendulum. Cart is of mass (${m}_{c}$) that moves on $x$ axis when any force is applied to system and pendulum is of mass (${m}_{p}$), inertia (${J}_{p}$) and length (2${l}_{p}$) that rotates on attachment point freely.
Fig. 1. Free body diagram of the linear inverted pendulum [12]
The Inverted pendulum system is modeled as Newton’s second law of motion. We obtain notation 1 and 2 when we linearize (for very small pendulum angle). These notations can be represented in state space form:
where:
For the linear inverted pendulum system, the state is defined:
It could be defined ${\dot{x}}_{1}={x}_{3}$ and ${\dot{x}}_{2}={x}_{4}$. Substituting state $x$ into the equations of motion found where ${x}_{c}={x}_{1}$, $\alpha ={x}_{2}$, ${\dot{x}}_{C}={x}_{3}$ and $\dot{\alpha}={x}_{4}$ gives:
and:
The $A$ and $B$ matrices in the $xd=Ax+Bu$ equation are therefore:
In the output equation, only the position of the cart and pendulum angle is being measured. Based on this, the $C$ and $D$ matrices in the output equation are:
Statespace representation is a mathematical model of a physical system as a set of input, output and state variables related by firstorder differential notations. The state of the system can be represented as a vector within that space. It is briefly shown below notation 5.
Table 1 lists and characterizes the main parameters associated with the linear inverted pendulum. These are used in the mathematical model.
Table 1. The linear inverted pendulum system specifications
Symbol

Description

Value

Unit

${M}_{p}$

Pendulum mass (with Tfitting)

0.230

[kg]

${l}_{p}$

Pendulum length from pivot to centre of gravity

0.3302

[m]

${J}_{p}$

Pendulum movement of inertia, about its centre of inertia

7.88 10^{3}

[kg∙m^{2}]

${B}_{p}$

Viscous damping coefficient, as seen at pendulum axis

0.0024

[N∙m∙s/rad]

$g$

Gravitational constant on earth

9.81

[m/s^{2}]

${K}_{g}$

Planetary gearbox gear ratio

0.90


${\eta}_{g}$

Planetary gearbox efficiency

0.90


${B}_{eq}$

Equivalent viscous damping coefficient

5.4

[N∙m∙s/rad]

${J}_{m}$

Rotor moment of inertia

3.90 10^{7 }

[kg∙m^{2}]

${r}_{mp}$

Motor pinion radius

6.35 10^{3}

[m]

3. The experimental setup of inverted pendulum
To obtain controller performance, experiments are conducted using Quanser Linear Motion Plant IP02 [13]. Experimental setup consists of cart and pendulum. Cart moving on horizontal track driven by DC motor and small gear wheel. Rotating pendulum is actuated by cart. Linear position is measured by cart encoder. The angular disturbance is sensed by pendulum encoder. Schematic diagram of experimental setup of the Linear Inverted Pendulum system is given in Fig. 2.
Fig. 2. Schematic diagram of the linear motion plant IP02
Table 2. The linear inverted pendulum system components
ID

Component

ID

Component

1

IP Cart

13

DC Motor

2

Stainless Steel Shaft

14

Planetary Gearbox

3

Rack

15

Linear Bearing

4

Cart Position Pinion

16

Pendulum Socket

5

Cart Motor Pinion

17

IP Weight

6

Cart Motor Pinion Shaft

18

Rack and Plate

7

Pendulum Axis

19

Rack Set Screw

8

IP Cart Encoder

20

Track Discontinuity

9

IP Pendulum Encoder

21

Pendulum

10

IP Cart Encoder Connector

22

Pendulum Set Screw

11

IP Pendulum Encoder Connector

23

Axis Set Screw

12

Motor Connector

The linear inverted pendulum system components listed in Table 2 below are labeled in Fig. 3(a)(d). It’s limited motor voltage between +15 V and –15 V and pendulum angle between +1 degree and –1 degree. Encoders are of high resolution of 4096 counts per revolution. To benchmark on setup, it is preferable if the user can use software such as QUARC^{®} or LabVIEW^{®} to read sensor measurements and feed voltages to the motor. The software is built upon Windows7 32 bit operating system to support real time applications.
The system requires an overall space of 2.19 m long by 1.27 m high (0.56 m below table and 0.71 m above) by 0.3 m deep. The system also must be placed on a flat surface and fixed.
Fig. 3. The linear motion plant IP02 component
a) Top view
b) Bottom view
c) Front view
d) Pendulum
4. The Bees Algorithm for LQR controller design
In this section presents the introduction of The Bees Algorithm and applying the proposed tuning diversity method to the LQR Controller design for the IP02 system briefly. The Bees Algorithm, which was developed by Pham in 2005 [14], is an optimization algorithm inspired by the natural foraging behavior of honey bees to find the optimal solution. It includes in both the neighborhood search and random search. Fig. 4 demonstrate the flowchart for the proposed algorithm in its simplest form to summarizes the main steps of The Bees Algorithm. As fully described in [1426], The Bees Algorithm requires a number of parameters to be set namely: number of scout bees ($n$), number of sites selected for exploitation out of n visited sites ($m$), number of toprated (elite) sites among the m selected sites ($e$), number of bees recruited for the best e sites ($nep$), number of bees recruited for the other ($m$$e$) selected sites ($nsp$), initial size of each patch (a patch is a region in search space that includes a visited site and its neighborhood) and stopping criterion (iteration number).
Table 3. The Bees Algorithm parameters and range of LQR parameters
The Bees Algorithm Parameters


$n$

$m$

$e$

$nep$

$nsp$

$ngh$

$itr$


20

10

4

10

7

0.001

30


Optimisation Range of LQR Parameters


${Q}_{1}$

${Q}_{2}$

${Q}_{3}$

${Q}_{4}$

${R}_{1}$


Max.

200

2000

2

2

20


Min.

0

0

0

0

0

Fig. 4. Flowchart of the basic the Bees algorithm
Fig. 5. Block diagram of LQR controller tuning
The LQR controller is predesigned and its parameters $Q$ and $R$ weight matrices are determined by tuned with The Bees algorithm to minimize the objective function which consists of the angle of pendulum step responses and the positioning of cart step responses in time domain.
The idea is to search for the optimal values of the weighting matrices of LQR controller with respect to a determined objective function. The Bees Algorithm and The objective function created according to existed studies [2125] which defined in Eq. (12):
$+\left(5{\alpha}_{norm}+10\alpha {t}_{s}+100\alpha {t}_{p}+500{\alpha}_{max}+1500\alpha {e}_{ss}\right),$
where ${t}_{r}$ is the rise time, ${t}_{s}$ is the settling time, ${t}_{p}$ is the peak time, $max$ is the maximum overshoot, ${e}_{ss}$ is the steady state error, norm is angle of matrix norm.
LQR control is one of the most effective control algorithm which is concerned with operating a dynamic system at minimum cost, and it’s also commonly used in all field of industry control. The importance and difficulty is selecting the weighting matrices of LQR controller.
For the linear time invariant state space model of the system:
and quadratic cost function:
LQR is a state feedback controller, $u=Kx$ to stabilize the system and minimize the cost function $J$, where $K$ is given by $K={R}^{1}{B}^{T}P$ and $P$ is obtained by solving the Ricatti notation:
Weighting parameter $Q$ can be defined as a symmetric positive semi definite matrix and $R$ can be selected as a symmetric positive definite matrix:
After calculating $K$, it is applied to system. Full state feedback control was applied to system and results were given in Section 5.
5. Experimental results and discussion
In order to verify the effectiveness of The Bees Algorithm and the optimized LQR controller, experiments have been done. To obtain more efficient LQR controller in order to minimize the objective function $J$, a predesign LQR controller tuned owing to with excellent search ability of the tuning methods. The Bees Algorithm was programmed in MATLAB and run on an Intel Core2 CPU 2.5 GHz PC with 3.0 GB memory to find a minimum value for the objective function. The optimization procedure carried out successfully and the objective function value corresponding to the optimized solution is 127.4 after 30 iterations in about 15 minutes. The optimization results are $Q=$[177.8062, 1257.3748, 1.7537, 0.5337] and $R=$ [0.2574] and the corresponding control gain matrix is $K=$[–26.2782, 111.7990, –31.9969, 17.9490]. Control block diagram of the linear inverted pendulum was designed in Simulink and simulated for 25 seconds and controller was benchmarked on experimental setup for same time. Results in graphs show the graphical results obtained by the LQR controller tuned by The Bees Algorithm for angular displacement and angular velocity of pendulum, linear displacement and linear velocity of cart and motor voltage. To verify the effectiveness of the improved The Bees Algorithm and the optimized LQR controller, the controller has benchmarked on the linear inverted pendulum setup.
Fig. 7. Pendulum’s angular displacement
Fig. 7 shows the system output, state pendulum angle ($\alpha $), together with experimental and simulation results. The control signal first responds to the set point change at $t=$4 s. The increasing set point amplitude leads to the change on the pendulum angle. Controller brings pendulum angle ($\alpha $) back to upright position “0 rad” in 2.5 s. When modeling the system, some nonlinear cases lead to difference between simulated and actual results. The LQR controller optimised with The Bees Algorithm brought system back to stable state against to sudden change in acceleration.
Fig. 8 shows the system output, pendulum angular velocity ($\dot{\alpha}$), together with experimental and simulation results.
Fig. 8. Pendulum’s angular velocity
Fig. 9. Cart’s linear displacement
Fig. 10. Cart’s linear velocity
The amplitude increased in steps of 0.04 m. Fig. 9 show the system output, cart position (${x}_{c}$), obtained from both experiment and simulation. As shown on Fig. 10, the step response of optimized LQR controller with The Bees Algorithm has satisfactory tracking performance. Settling time is 2.5 s and overshoot is small enough. Compared with the performance of simulated and experimental results, it is good enough. System output (cart position) followed repeated orbit and simulation and experimental result took place very close.
Fig. 10 show the system output, cart velocity (${\dot{x}}_{C}$), obtained from both experiment and simulation. Controller tries to decrease error and response time to minimum so that noise can be tolerated.
Fig. 11. show the system input $Mv$ (motor voltage), obtained from both experiment and simulation. Motor voltage took shape according to controller criteria prognosticatively.
Fig. 11. Motor voltage
6. Conclusions
The tuning of LQR controllers for unstable linear inverted pendulum system with The Bees Algorithm was reported in this paper. In LQR controller design for system, an efficient and alternative solution was investigated to conventional trial and error design methods using The Bees Algorithm which is a natureinspired search method. The Bees Algorithm which is a tuning method and balancing control of the linear inverted pendulum system is investigated by experimental. The LQR controller obtained by tuning with The Bees Algorithm which is a diversity method for optimization of a controller. The $Q$ and $R$ weight matrices of the LQR controller were tuned using The Bees Algorithm to minimize step response parameters of system in time domain. The aim of optimization is to design a LQR controller to perform an effective control with a minimum error in pendulum angle and cart’s position from desired. Simulation and experimental results of system controlled by the tuned LQR controller are given in figures and were compared with each other to verify the optimization techniques. Results demonstrated that the tuned LQR controller has a sufficient performance to control of the system within controller design criteria. Briefly, the tuning method with using The Bees Algorithm is adequately successful in tuning of a LQR controller. Furthermore, the advantage of the optimization method proposed in this study that it ensures the expected specifications of time domain response of IP02 system in optimization. It can improve performances of the controller by changing The Bees Algorithm parameters, the objective function and the optimization range.
References
 Chalupa P., Bobál V. Modelling and predictive control of inverted pendulum. 22nd European Conference on Modelling and Simulation, 2008, p. 531537. [Publisher]
 Nasir A. N. K., Ahmad M. A., Rahmat M. F. A. Performance comparison between LQR and PID controllers for an inverted pendulum system. International Conference on Power Control and Optimization: Innovation in Power Control for Optimal Industry, Vol. 1052, Issue 1, 2008, p. 124128. [Publisher]
 Prasad L. B., Tyagi B., Gupta H. O. Optimal control of nonlinear inverted pendulum dynamical system with disturbance input using PID controller and LQR. Control System. IEEE International Conference on Computing and Engineering, 2011, p. 540545. [Publisher]
 Khan A. A., Hussain K. Comparative performance analysis between fuzzy logic controller (FLC) and PID controller for an inverted pendulum system. International Journal of Electrical, Electronics and Computer Systems, Vol. 10, Issue 2, 2012. [Search CrossRef]
 Noh J. S., Lee G. H., Jung S. Position control of a mobile inverted pendulum system using radial basis function network. International Journal of Control, Automation and Systems, Vol. 8, Issue 1, 2010, p. 157162. [Publisher]
 Ogata K. DiscreteTime Control Systems, 2nd Edition. PrenticeHall, Englewood Cliffs, NJ, 1995, p. 566633. [Search CrossRef]
 Wenlong T. A. N. An improved method for rectilinear double inverted pendulum LQR controller parameter optimization. Journal of Chongqing University of Technology (Natural Science), 2012. [Search CrossRef]
 Chen J., Zhang C. Control of triple inverted pendulum based on LQR coefficients optimization. Computer Engineering and Applications, Vol. 5, Issue 29, 2009, p. 245248. [Search CrossRef]
 Haiying W., Hongwen L., Jinlin J., Rui X. LQR control of circularrail double inverted pendulum based on genetic algorithm. Journal of North University of China, Vol. 2, 2010, p. 132135. [Search CrossRef]
 Karaboga D. An Idea Based on Honey Bee Swarm for Numerical Optimization. Technical Report TR06, Computer Engineering Department, Erciyes University, Turkey, 2005. [Search CrossRef]
 Gawthrop P. J., Ronco E. Predictive poleplacement control with linear models. Automatica, Vol. 38, Issue 3, 2002, p. 421432. [Publisher]
 IP02 Linear Inverted Pendulum Experiment for MATLAB / Simulink Users Workbook – Student Version 1.0. QUANSER Inc., 2013. [Search CrossRef]
 Linear Motion Plant IP01 and IP02 User Manual. Document Number 501, Revision 5.0. QUANSER Inc., 2012. [Search CrossRef]
 Pham D. T., Ghanbarzadeh A., Koc E., Otri S., Rahim S., Zaidi M. The Bees Algorithm Technical Note. Manufacturing Engineering Centre, Cardiff University, UK, 2005 [Search CrossRef]
 Pham D. T., Koç E., Ghanbarzadeh A. Optimisation of the weights of multilayered perceptrons using The Bees Algorithm. Proceedings of 5th International Symposium on Intelligent Manufacturing Systems, Sakarya, Turkey, 2006, p. 3846. [Search CrossRef]
 Pham D. T., Castellani M. The Bees Algorithm: modelling foraging behaviour to solve continuous optimization problems. Proceedings of the Institution of Mechanical Engineers, Part C: Journal of Mechanical Engineering Science, Vol. 223, Issue 12, 2009, p. 29192938. [Publisher]
 Pham D. T., Koç E. Design of a twodimensional recursive filter using The Bees Algorithm. International Journal of Automation and Computing, Vol. 7, Issue 3, 2010, p. 399402. [Publisher]
 Pham D. T., Darwish H. A. Using The Bees Algorithm with Kalman filtering to train an artificial neural network for pattern classification. Proceedings of the Institution of Mechanical Engineers, Part I: Journal of Systems and Control Engineering, Vol. 224, Issue 7, 2010, p. 885892. [Publisher]
 Pham D. T., Ghanbarzadeh A., Koc E., Otri S., Rahim S., Zaidi M. The Bees Algorithm – a novel tool for complex optimisation. Proceedings of the 2nd International Virtual Conference on Intelligent Production Machines and Systems, 2006, p. 454. [Publisher]
 Zhou Z. D., Xie Y. Q., Pham D. T., Kamsani S., Castellani M. Bees Algorithm for multimodal function optimisation. Proceedings of the Institution of Mechanical Engineers, Part C: Journal of Mechanical Engineering Science, 2015. [Search CrossRef]
 Pham D. T., Castellani M. Benchmarking and comparison of natureinspired populationbased continuous optimization algorithms. Soft Computing – A Fusion of Foundations, Methodologies and Applications, Vol. 18, 2013, p. 871903. [Search CrossRef]
 Pham D. T., Castellani M., A comparative study of The Bees Algorithm as a tool for function optimisation. Cogent Engineering, Vol. 2, Issue 1, 2015, p. 1091540. [Publisher]
 Pham D. T., Koc E., Kalyoncu M., Tınkır M. Hierarchical PID controller design for a flexible link robot manipulator using The Bees Algorithm. Proceedings of 6th International Symposium on Intelligent Manufacturing Systems, Sakarya, Turkey, 2008, p. 757765. [Search CrossRef]
 Pham D. T., Kalyoncu M. Optimisation of a fuzzy logic controller for a flexible singlelink robot arm using The Bees Algorithm. Proceedings of 7th IEEE International Conference on Industrial Informatics, Cardiff, UK, 2009, p. 475480. [Publisher]
 Fahmy A. A., Kalyoncu M., Castellani M. Automatic design of control systems for robot manipulators using The Bees Algorithm. Proceedings of the Institution of Mechanical Engineers, Part I, Journal of Systems and Control Engineering, Vol. 226, Issue 4, 2012, p. 497508. [Publisher]
 Sen M. A., Kalyoncu M. Optimisation of a PID controller for an inverted pendulum using The Bees Algorithm. International Conference on Mechatronics and Automation Science, Applied Mechanics and Material Journal, Section: Manufacturing Science and Technology, Paris, France, Vols. 789790, 2015, p. 10391044. [Publisher]
Cited By
Deu Muhendislik Fakultesi Fen ve Muhendislik
Hasan Hüseyin BİLGİÇ, Muhammed Selimhan TUTUMLU, Çağlar CONKER

2021

Arabian Journal for Science and Engineering
Hasan Huseyin Bilgic, Muhammed Arif Sen, Ahmet Yapici, Hakan Yavuz, Mete Kalyoncu

2021

Load balancing transmission technology of network communication based on phase spectrum compensation
Journal of Physics: Conference Series
Qian Zhai, XingHua Lu

2021

Konya Journal of Engineering Sciences
Semih ÖZKAYA, Çağlar CONKER, Hasan Hüseyin BİLGİÇ

2021

Metals and Materials International
Berkay Eren, Mehmet Ali Guvenc, Selcuk Mistikoglu

2021

The International Journal of Artificial Organs
Ahmet Onder, Omer Incebay, Muhammed Arif Sen, Rafet Yapici, Mete Kalyoncu

2021

International Journal of Hydrogen Energy
Yıldız Koç, Hüseyin Yağlı, Adnan Görgülü, Ali Koç

2020

Energy Sources, Part A: Recovery, Utilization, and Environmental Effects
Rajan V. Vamja, Mahmadasraf A. Mulla

2020

Construction and Building Materials
Umur Korkut Sevim, Hasan Huseyin Bilgic, Omer Faruk Cansiz, Murat Ozturk, Cengiz Duran Atis

2020

Çukurova Üniversitesi MühendislikMimarlık Fakültesi Dergisi
Serdar COŞKUN

2020

Proceedings of the Institution of Mechanical Engineers, Part I: Journal of Systems and Control Engineering
Hasan Huseyin Bilgic, Caglar Conker, Hakan Yavuz

2020

Konya Journal of Engineering Sciences
Hasan Huseyin BILGIC, Mehmet Ali GUVENC, Mustafa CAKIR, Selcuk MISTIKOGLU

2019
