You are on page 1of 22

See discussions, stats, and author profiles for this publication at: https://www.researchgate.

net/publication/330118098

Modeling of Inverted Pendulum System with Gravitational Search Algorithm


Optimized Controller

Article in Ain Shams Engineering Journal · January 2019


DOI: 10.1016/j.asej.2018.11.001

CITATION READS

1 30

3 authors, including:

Mahmoud A. Attia Mohamed Magdy


Ain Shams University Ain Shams University
55 PUBLICATIONS 111 CITATIONS 3 PUBLICATIONS 1 CITATION

SEE PROFILE SEE PROFILE

Some of the authors of this publication are also working on these related projects:

Industrial electrical engineering courses for non-engineers View project

Optimum Power Flow View project

All content following this page was uploaded by Mohamed Magdy on 29 January 2019.

The user has requested enhancement of the downloaded file.


Ain Shams Engineering Journal xxx (xxxx) xxx

Contents lists available at ScienceDirect

Ain Shams Engineering Journal


journal homepage: www.sciencedirect.com

Electrical Engineering

Modeling of inverted pendulum system with gravitational search


algorithm optimized controller
Mohamed Magdy a,⇑, Abdallah El Marhomy a, Mahmoud A. Attia b
a
Department of Engineering Physics and Mathematics, Faculty of Engineering, Ain Shams University, Cairo, Egypt
b
Department of Electrical Power and Machines, Faculty of Engineering, Ain Shams University, Cairo, Egypt

a r t i c l e i n f o a b s t r a c t

Article history: The inverted pendulum (IP) is a common classical control theory problem. Many controllers are used to
Received 26 October 2017 keep the pendulum rod upraise via the control the position of the cart. In this paper, Modelling of IP sys-
Revised 1 October 2018 tem is carried out and then verifies the model through comparison with other models in literature. The
Accepted 27 November 2018
viscous damping effect on the IP system has been also considered in this work. The PID controller is used
Available online xxxx
to control the IP and is tuned by using both Gravitational Search Algorithm (GSA) and Genetic Algorism
(GA). Examination of GSA efficiency has been demonstrated, and then comparison with Genetic Algorism
Keywords:
(GA) in the tuning of PID controller is presented. The results proved the superiority of the controller
Inverted pendulum
PID controller
which is tuned by using GSA (PID-GSA). Finally, the optimized controller (PID-GSA) performance is
Genetic algorithm checked through carrying out the robustness test.
Gravitational search algorithm Ó 2018 Ain Shams University. Production and hosting by Elsevier B.V. This is an open access article under
D’Alembert’s principle the CC BY-NC-ND license (http://creativecommons.org/licenses/by-nc-nd/4.0/).

1. Introduction system to this position. However, it is unstable in the upper posi-


tion (virtual stability), i.e., it needs controller to sustain stability
The inverted pendulum (IP) control system design has become a at this position.
common engineering challenge for researchers due to the impor- Some researchers considered the IP’s cart is on a frictionless rail
tant application of (IP) in practical life. The problem can be as in [1,2,6]. It is to some extent not a logical approximation since
described as a stability of a long broomstick stand on your hand; the cart is exposed to viscous damping caused by lubrication of the
all of us do that in childhood aiming to make the stick stable in rail.
the vertical position. The IP stability and control has been a subject Authors of [5–7] presented the first challenge in modeling the
of research that attracts the attention of engineers and researchers system using Euler-Lagrange’s equations to find the system equa-
since the last 50 years. IP model is used widely nowadays. Rockets tions, but Authors of [1] used MSC Adams software to build a vir-
when launching, Missiles guidance [1,2], Robotic arm behave very tual prototype for the IP and this prototype export to MATLAB and
much like controlled inverted pendulum. Commercial application the simulation is implemented through both MATLAB and Adams
for IP model is the Segway [3], Seismometers and JOE. Humanoid together.
robots which are stable walking under linear inverted pendulum The second challenge is the controller design. There are many
model [4]. controller types Like: P, PI, PD, PID, fuzzy controller, LQR controller,
IP system has two equilibrium states [5], one stable and the distributed order PID [8]. Authors of [9] used PD controller as it is
other is unstable. The IP system is asymptotically stable when it one of a simple controller in implementation. In [5,10], the authors
is in the lower position, i.e., it needs no controller to drive the used LQR controller to improve the system response. In [1,6,11],
the authors used PID controller, but authors of [2] PID combined
⇑ Corresponding author. with LQR controller was used aiming to enhance the performance,
E-mail addresses: engmohamed.abdo92@eng.asu.edu.eg (M. Magdy), mahmoud. in [12] fractional order PID controller was used. Fuzzy-logic con-
abdullah@eng.asu.edu.eg (M.A. Attia). trollers are applicable to an IP system like fuzzy parallel distributed
Peer review under responsibility of Ain Shams University. compensation (PDC) controller which was used in [13].
The controller parameters as well as the controller type can
affect the system stability. Hence, the choice of the parameters is
also another challenge. Try and error method is adopted by [1].
Production and hosting by Elsevier However, this method usually consumes effort and time but to

https://doi.org/10.1016/j.asej.2018.11.001
2090-4479/Ó 2018 Ain Shams University. Production and hosting by Elsevier B.V.
This is an open access article under the CC BY-NC-ND license (http://creativecommons.org/licenses/by-nc-nd/4.0/).

Please cite this article as: M. Magdy, A. El Marhomy and M. A. Attia, Modeling of inverted pendulum system with gravitational search algorithm optimized
controller, Ain Shams Engineering Journal, https://doi.org/10.1016/j.asej.2018.11.001
2 M. Magdy et al. / Ain Shams Engineering Journal xxx (xxxx) xxx

decrease the human effort, artificial intelligent optimization meth-


ods are used like: Genetic Algorithm (GA), Bees Algorithm. The
author [14] compare between both Genetic Algorithm (GA) and
Bees Algorithm in tuning PID controller. The authors [9,11,15] used
Genetic Algorithm to find controller parameters while in [16,17]
the authors used Bees Algorithm to get better fitting for the
controller parameter. In [18] the authors used Artificial Bees
Colony-Predator and Prey Approach to find the parameters of the
PID controller. However, most of the researchers don’t apply
Gravitational Search Algorithm (GSA) to find the parameters even
with its superiority as was proven in the presented work.
In this paper, the inverted pendulum is modeled including the
effect of viscous damping, where the equations of motion are
derived using D’Alembert’s principle. Lagrange’s equations have
been also used to derive the same governing equations of motion
of the system (see Appendix A). The main objective of this work
is to gain an overall insight into the roles played by the parameters
of the controller in affecting the system stability in the upward ver-
tical position. GSA proves its superiority through enhancing the Fig. 1a. Inverted pendulum model.
system performance. The results of our investigation are verified
via the robustness test for many disturbances applied on the sys-
tem. Also investigate the effect of the viscous friction on the stabil-
ity of the system.
This work presents several contributions, like: analysis of the IP
system from scratch. IP system FBD is drawn in more detailed than
any previous works. Using GSA with IP system PID controller is
considered new contribution in this application. Discussing the
effect of viscous friction variation is one of the paper contributions.
Also check more than 2 types of disturbances on the controller are
illustrated clearly in Section 10 in this paper.
In this paper, Section 2 presents the system model derivation by
using D’Alembert’s principle. Section 3 explains the used controller
and its parameters; the controller is a PID- controller. Section 4
Fig. 1b. IP free body and inertia forces diagram at the stable equilibrium position.
explain the viscous friction force and illustrates the effect of it on
the IP system stability. In Section 5, many tests are carried out to
check the validity of the presented model. Section 6 describes
two types of Artificial Intelligent Optimization Algorithms, Gravita- Table 1
The system parameter.
tional search algorithm (GSA) and Genetic Algorithm (GA). In Sec-
tion 7, two tests are carried out to check the superiority of GSA Symbol Description Value
comparing with GA. Section 8 shows a comparison between PID- F Applied force to the cart N
GSA and PID-GA. In Section 9, a robustness test is carried out to X Cart position m
check the stability of the system on a wide range of disturbance. h Pendulum angle with vertical rad
The contributions of this paper are listed in Section 10. Finally in M Mass of the cart 0.5 kg
Section 11, all references that are mentioned in this paper are m Mass of pendulum rod 0.2 kg
listed in this section. b Viscous friction coefficient 0.1 Ns/m
L One half pendulum rod length 0.3 m
I Pendulum rod moment of inertia 0.006 kgm2
2. Modeling R Pulley radius 0.0235 m
s Motor time constant 0.5 s
The system consists of a free vertical rotating pendulum is con- Km Motor gain 24.3 rad/s/v
nected to a horizontal moving cart with smooth hinge. To control Kf Feedback gain 9
p v/rad
the IP, a horizontal force (F) is exerted on the cart through servo
motor. The applied and inertia forces and couples are shown in
Fig. 1, while the system parameters are included in Table 1.

Mg þ mg  ml€h sin h  mlh_ 2 cos h ¼ 0 ð2Þ


2.1. Inverted pendulum model
X
According to D’Alembert’s principle, the presented system is in ) MA ¼ 0
equilibrium under both the applied and inertia forces and couples
mgl sin h þ I€h þ ml €h þ ml€x cos h ¼ 0
2
shown in Fig. 1: ð3Þ
X
) Fx ¼ 0 From Eqs. (1)–(3), we get:
 
I þ ml €h þ mgl sin h ¼ ml€x cos h
2
ð4Þ
F  bx_  M x_  m€x  ml€h cos h þ mlh_ 2 sin h ¼ 0 ð1Þ
X
) Fy ¼ 0 ðM þ mÞ€x þ bx_ þ ml€h cos h  mlh_ 2 sin h ¼ F ð5Þ

Please cite this article as: M. Magdy, A. El Marhomy and M. A. Attia, Modeling of inverted pendulum system with gravitational search algorithm optimized
controller, Ain Shams Engineering Journal, https://doi.org/10.1016/j.asej.2018.11.001
M. Magdy et al. / Ain Shams Engineering Journal xxx (xxxx) xxx 3

By linearizing the system about h ¼ p; h is measured with verti- 4. Effect of viscous friction
cal downward in counter-clockwise direction, where h ¼ p þ u
and the system start from rest so u_ 2 ¼ 0; we get: Viscous Friction appears in IP model due to the lubrication of
  the rail with a viscous fluid [22,23]. The Viscous Friction has a very
I þ ml u €  mglu ¼ ml€x
2
ð6Þ important role in rapid stabilization for the IP, as it works as Dam-
per element. It is varied linear with the velocity of the cart accord-
ing to Eq. (13). The friction force acts opposite to the direction of
ðM þ mÞ€x þ bx_  mlu
€ ¼F ð7Þ motion. When the cart exposed to an impulse force that increases
By applying Laplace transform on Eqs. (6) and (7), we get: its velocity, viscous friction tries hardly to damp this motion.
 
I þ ml s2 u  mglu ¼ mls2 x
2
ð8Þ f v iscous ¼ bV ð13Þ
Viscous Friction Coefficient (b) varies directly with the fluid vis-
cosity and the contact area between the rail and the cart, but inver-
F ðsÞ ¼ ðM þ mÞs x þ bsx  mls u
2 2
ð9Þ
sely proportional to the clearance between the contact areas [23].
uðsÞ This paper studies the variation of viscous friction coefficient (b)
Solve Eqs. (8) and (9), to get FðsÞ
transfer function as in equation
on IP closed loop system with PID controller gains such as: Kp = 20,
(10), after substituting by system parameters in Table 1.
Ki = 100, Kd = 1 and when 1000 N impulse force is applied on the
uðsÞ 0:06s cart, Fig. 4 shows that the maximum overshoot (M.O.) inversely
¼ ð10Þ proportional to viscous friction coefficient (b), so the system
FðsÞ 0:0132s3 þ 0:0024s2  0:4166s  0:0588
became more stable when increasing the effect of the viscous fric-
tion. Contrary to what was expected, Table 3 shows clearly the
2.2. Actuation system model variation of the maximum overshoot with viscous friction
coefficient.
This system consists of a Cart move on a rail connected with Dc
Servo Motor by a pulley and belt. The overall TF of the actuation
5. Verification of model:
system is the equivalent TF of the Motor, Pulley, Belt and Cart.
Armature controlled DC Motor is used in the system as shown in
To ensure that the whole model is reliable, and also can repre-
Fig. 2. Finally, Eq. (11) which presents equivalent TF of the actua-
sent the IP better than other models such as model presented in
tion system, is built according to the authors of [19,20] studies.
[12] and in [24], Two tests is carried out to check the validity with
FðsÞ 0:391s both references, test (1) is for Ref. [12] and test (2) is for Ref. [24].
¼ ð11Þ
VðsÞ 0:5s þ 1
5.1. Test (1)

3. PID controller By applying Ref. [12] model parameters (M = 0.5 kg, m = 0.2 kg,
L = 0.3, I = 0.006, b = 0.1) and compare the new model unit step
In order to stabilize and control the angle of the IP, Proportional response with the model presented in [12] response under the
– Integral – Differential (PID) controller is used as it is simple in same unit step disturbance. Both two models are in open loop
implementation and with high reliability. There are three gains mode. Fig. 5 shows the two model response, the two responses
for this controller, Kp: proportional gain, Ki: integral gain, Kd: Dif- had the same response which proves that the new system is iden-
ferential gain. The controller over all Transfer Function [21] is as tical to model in [12].
shown in Eq. (12):

Ki 5.2. Test (2)


T:F ¼ K p þ þ Kds ð12Þ
s
By applying model parameters (M = 0.9 kg, m = 0.1 kg, L = 0.47,
where each gain has its importance as in Table 2, Kp reduces the I = 0.0053, b = 0) and PID controller parameters. Comparison
rising time and improve the settling time, Ki reduces the steady between the presented model response and the response of model
state error to almost zero and Kd reduces overshoot and increases presented in [24] is carried out with the same controller gains:
system stability [21]. The overall closed loop model of the system Kp = 100, Ki = 20, Kd = 1. Two cases studied in comparison as will
with controller is shown in Fig. 3. be presented in the following sections.

5.2.1. Case (1)


When applying impulse disturbance that in Fig. 6 on the cart,
Fig. 7 illustrates Authors of [24] model response, Fig. 8 shows the
response of the designed model which is presented in this work,
the two responses are the same.

5.2.2. Case (2)


When applying impulse that in Fig. 9 on the pendulum angle,
Fig. 10 illustrates Ref. [24] response, Fig. 11 shows designed Model
response. The two responses are the same.
After verification, it is found that the presented model gives
same responses of [24,12] model, which prove that the presented
Fig. 2. Model of Armature controlled DC Motor. model is reliable and give a good representation for the system.

Please cite this article as: M. Magdy, A. El Marhomy and M. A. Attia, Modeling of inverted pendulum system with gravitational search algorithm optimized
controller, Ain Shams Engineering Journal, https://doi.org/10.1016/j.asej.2018.11.001
4 M. Magdy et al. / Ain Shams Engineering Journal xxx (xxxx) xxx

Table 2
Effect of PID parameters on the system stability.

Controller Parameter Rising Time Settling Time Overshoot Steady State Error
Kp Decrease Slight Change Increase Decrease
Ki Decrease Increase Increase Eliminate
Kd Slight Change Decrease Decrease No Change

Fig. 3. IP overall closed loop model.

Fig. 4. The variation of maximum overshoot with ‘‘b”.

Table 3
The variation of the maximum overshoot with viscous friction coefficient.

B 0 0.1 2 4 6
M.O. 0.04972 0.0497 0.0495 0.0493 0.0491

Please cite this article as: M. Magdy, A. El Marhomy and M. A. Attia, Modeling of inverted pendulum system with gravitational search algorithm optimized
controller, Ain Shams Engineering Journal, https://doi.org/10.1016/j.asej.2018.11.001
M. Magdy et al. / Ain Shams Engineering Journal xxx (xxxx) xxx 5

Fig. 5. Response of both models under unit step disturbance.

Fig. 6. Impulse input to the cart.

6. Artificial intelligent optimization algorithms 6.1. Gravitational search algorithm

The mathematical model is complicated to be implemented in Gravitational search algorithm (GSA) [25] is a population search
addition to that the system is a nonlinear problem. Thus AI meth- algorithm proposed by Rashedi et al in 2009. It is an optimization
ods such as GA and GSA are suitable for these types of problems. algorithm based on the law of gravity, mass interactions and also
GA and GSA are used in this work to find out the controller param- based on the newton’s law of gravitation. All objects attract each
eters which used to stabilize the pendulum angle at the zero posi- other by the gravitational force, and this force causes a movement
tion. A Comparative study between GSA and GA in tuning the for all objects in direction of the objects of heavy masses as in
controller is carried out. The fitness function is the Integrated Fig. 12a. which illustrate a live example from the nature (earth
Square Error of the pendulum angle as shown in Eq. (14). and the moon). The heaviest object is presented the problem solu-
Z 1
tion. The Flow chart of the algorithm procedures is shown in the
Angle ISE ¼ ðDV angle Þ2 dt ð14Þ Fig. 12b also general GSA Pseudo code is presented in Fig. 12c. In
0 GSA, each mass is agent, represent a solution for the problem, each

Please cite this article as: M. Magdy, A. El Marhomy and M. A. Attia, Modeling of inverted pendulum system with gravitational search algorithm optimized
controller, Ain Shams Engineering Journal, https://doi.org/10.1016/j.asej.2018.11.001
6 M. Magdy et al. / Ain Shams Engineering Journal xxx (xxxx) xxx

Fig. 7. Impulse response of Ref. [24] Model under impulse disturbance.

Fig. 8. Impulse response of designed Model under impulse disturbance.

one has four main information: position, inertial mass, active b. Newton 2nd Law which concerned with the object motion,
gravitational mass, passive gravitational mass, all these masses when F applied to the object, the object start to move with
obey: acceleration a.
F
a. Law of Gravity: according to Newton law of gravity, each a¼
M
object attract each other with gravitational force which
between each two objects is directly proportional to the pro- In this paper, the Fitness function is Integrated Square
duct of their masses and inversely proportional to the dis- Error (ISE) in Eq. (14), which specified by small maximum
overshoot and suitable settling time because it gave all
tance squared F ¼ G MR1 M
2
2

errors equal weight to get Kbest (best fitness value), accord-


Where:
ing to the following steps:
G: gravitational Constant.
M 1 ; M2 : Frist and Second object mass. a. Search space identification.
R2 :Square the Distance bet the 2 objects. b. Initiate with random values of controller gains.

Please cite this article as: M. Magdy, A. El Marhomy and M. A. Attia, Modeling of inverted pendulum system with gravitational search algorithm optimized
controller, Ain Shams Engineering Journal, https://doi.org/10.1016/j.asej.2018.11.001
M. Magdy et al. / Ain Shams Engineering Journal xxx (xxxx) xxx 7

Fig. 9. Impulse input to inverted pendulum.

Fig. 10. Impulse response of the old model.

c. Evaluate the ISE (fitness function) of all agents. Population type: ‘‘double vector”,
d. Update the algorithm parameters: G (t), best (t), worst (t) Population size = 50,
and Mi (t) for i = 1, 2. . . N. Number of iteration (N) = 10,
e. The total force calculation in different directions took place. Stopping criteria: number of iteration.
f. Calculating of acceleration and velocity of the obtained pen-
dulum angle. GSA Pseudo code:
g. Updating agents ‘position (i.e. controller gains).
h. Repeat steps c to g until the stopping criteria (i.e. number of
6.2. Genetic Algorithm (GA)
iteration) is reached.
i. End.
This method is one of the most powerful Artificial Intelligent
optimization methods, GA were invented by John Holland in the
In this paper default GSA aspects in Matlab is used as follow:
1960s; GA is widely used in many important fields like:

Please cite this article as: M. Magdy, A. El Marhomy and M. A. Attia, Modeling of inverted pendulum system with gravitational search algorithm optimized
controller, Ain Shams Engineering Journal, https://doi.org/10.1016/j.asej.2018.11.001
8 M. Magdy et al. / Ain Shams Engineering Journal xxx (xxxx) xxx

Fig. 11. Impulse response of the new model.

Fig. 12a. Every mass accelerate in direction of the resultant force.

Engineering, business, science. This method depends mainly on the


Gens and Chromosomes, as it is moving from one population of
chromosomes to new population according to the flow chart
shown in Fig. 13 explain general of GA and the following steps
using that in the proposed problem:

1. Initialization: random values of the controller gains are


assumed.
2. Fitness Function: evaluate the ISE for each chromosome in the
population, as shown in equation (14).
3. Selection: two chromosomes are selected based on their fitness.
Fig. 12b. Flow chart for GSA.
4. Crossover: these chromosomes reproduce to create one or more
offspring.
5. Mutation: the offspring are mutated randomly. In this paper default GA aspects in Matlab is used as follow
6. The updated value of the pendulum angle are selected and ISE is
checked again if stopping criteria is not reached steps from 1 Population type: ‘‘double vector”
are repeated. Population size = 20,

Please cite this article as: M. Magdy, A. El Marhomy and M. A. Attia, Modeling of inverted pendulum system with gravitational search algorithm optimized
controller, Ain Shams Engineering Journal, https://doi.org/10.1016/j.asej.2018.11.001
M. Magdy et al. / Ain Shams Engineering Journal xxx (xxxx) xxx 9

Stall time: 20,


Function tolerance: 1e–006;
Non-linear constraint tolerance: 1e–006.

7. Results

This section consists of two tests to check the superiority of GSA


comparing with GA.

7.1. Test 1

At this test, tuning of the PID controller by using GSA and GA


when an impulse force of magnitude 1000 N and 0.01 s width is
applied on the Cart.
Fig. 12c. GSA pseudo code.

 By using GSA:

GSA is used to tune the PID controller Parameters. The objective


function is to minimize the error in pendulum rod’s angle. An
impulse force (of magnitude = 1000, and 0.01 s width) is applied
on the Cart. Number of agents = 50, number of iteration = 10 and
by using the parameters range as in Table 4:
The results were found as in Table 5:
By applying the values in Table 5 on the controller and then the
impulse in Fig. 14 is applied on the cart. It is noticed that the max-
imum overshoot is around 0.0271 rad, and the settling time is at
t = 2.7 s as shown in Fig. 15.

 By using GA:

GA is used to tune the PID controller Parameters. The objective


function is to minimize the error in pendulum rod’s angle when an
impulse force of Fig. 14 is applied on the Cart, by using the param-
eters range shown in Table 6.
The results were found in Table 7:
By applying the values in Table 7 on the controller and then the
impulse in Fig. 14 is applied on the cart. It is noticed that the max-
imum overshoot is around 0.027 rad, and the settling time is at
t = 8 s as shown in Fig. 16.

7.2. Test 2

At this test, tuning of the PID controller by using GSA and GA


when an impulse (of magnitude = 0.3 rad, and 0.01 s width) is
applied on the pendulum’s angle.

 By using GSA:

GSA is used to tune the PID controller Parameters. The objective


function is to minimize the error in pendulum rod’s angle. Number
of agents = 50, number of iteration = 10 and by using the parame-
ters range as in Table 8:
Fig. 13. Flow chart of genetic algorithm. The results were found as in Table 9:
By applying the values in Table 9 on the controller and then an
impulse (of magnitude 0.3 rad and width 0.01 s) is applied on pen-
Scaling function: rank, dulum rod as in Fig. 17. It is noticed that the settling time is at
Selection function: stochastic uniform,
Reproduction: elite count = 2,
Crossover fraction: 0.8, Table 4
Mutation: mutation function—Gaussian, PID-GSA parameters range.

Crossover function: scattered, Upper Limit 20 50 2


Migration: direction—forward, Gains Kp Ki Kd
Stopping criteria: generation—30, Down Limit 0 0 0
Stall generation: 50,

Please cite this article as: M. Magdy, A. El Marhomy and M. A. Attia, Modeling of inverted pendulum system with gravitational search algorithm optimized
controller, Ain Shams Engineering Journal, https://doi.org/10.1016/j.asej.2018.11.001
10 M. Magdy et al. / Ain Shams Engineering Journal xxx (xxxx) xxx

Table 5 Table 6
PID-GSA parameters results. PID-GA parameters range.

Kp Ki Kd Upper Limit 20 50 2
19.7805 30.7466 1.9537 Gains Kp Ki Kd
Down Limit 0 0 0

t = 1.27 s without any oscillation. Also it can be noted that the


maximum overshoot around 0.3 rad as shown in Fig. 19. Table 7
PID-GA parameters results.

 By using GA: Kp Ki Kd
14.6971 11.9060 1.9924
In this section, GA is used to tune the PID controller Parameters.
The objective is to minimize the error in pendulum rod’s angle, by
using the parameters range shown in Table 10.
8. Comparison
The results were found as shown in Table 11:
By applying the values in Table 11 on the controller and then an
After reviewing the presented compensated system response, it
impulse of magnitude 0.3 rad and width 0.01 s is applied on pen-
is clear that the system reliability with PID-GSA controller became
dulum rod as in Fig. 17. It is noticed that the settling time is at
better than using PID-GA. The system response became faster with
t = 2.23 s. Also it can be noted that the maximum overshoot is
many disturbances; all of these will be illustrated in the next
around 0.3 rad with high oscillations as shown in Fig. 19.
section through test 1 and test 2 details.

Fig. 14. Impulse disturbance to the cart.

Fig. 15. IP system response.

Please cite this article as: M. Magdy, A. El Marhomy and M. A. Attia, Modeling of inverted pendulum system with gravitational search algorithm optimized
controller, Ain Shams Engineering Journal, https://doi.org/10.1016/j.asej.2018.11.001
M. Magdy et al. / Ain Shams Engineering Journal xxx (xxxx) xxx 11

Fig. 16. IP system response.

Table 8
Test 2:
PID-GSA parameters range.
An impulse of 0.3 rad in Fig. 17 is applied on the Pendulum rod.
Upper Limit 20 50 2
PID-GSA and PID-GA gave the same maximum overshoot. But in
Gains Kp Ki Kd case of PID-GA, it is noticed that the controller gave high oscilla-
Down Limit 0 0 0
tions before settling. Also PID-GA took a long period than the case
of PID-GSA.

Table 9 9. Robustness test


PID-GSA parameters results.

Kp Ki Kd
To check the stability of the system on a wide range of distur-
bance, the robustness test is carried out. The tests check the con-
3.9359 5.0506 0.1148
troller performance at several disturbances with the same
corresponding controller parameters which obtained in the previ-
ous sections.
Test 1:
9.1. Case (1)
An impulse of 1000 N in Fig. 14 is applied on the cart in case of
PID-GSA and PID-GA. It is noticed that both controllers almost gave
The check made on PID-GSA controlled system which is used in
the same maximum overshoot. But in case of PID-GA, it is settled in
Test (1) with the obtained controller parameters. The check is car-
approximately 3 times longer than the case of PID-GSA.
ried out by applying an impulse of magnitudes 1000 N, 1500 N and

Fig. 17. Impulse disturbance to the pendulum’s angle.

Please cite this article as: M. Magdy, A. El Marhomy and M. A. Attia, Modeling of inverted pendulum system with gravitational search algorithm optimized
controller, Ain Shams Engineering Journal, https://doi.org/10.1016/j.asej.2018.11.001
12 M. Magdy et al. / Ain Shams Engineering Journal xxx (xxxx) xxx

Fig. 18. IP system response.

Fig. 19. IP system response.

Table 10 Table 12
PID-GA parameters range. Results of the robustness test.

Upper Limit 20 50 2 Impulse Peak Settling Time Max. Overshoot


Gains Kp Ki Kd 1000 N 2.7 0.0271
Down Limit 0 0 0 1500 N 2.71 0.0407
2000 N 2.69 0.0542

Table 11
PID-GA parameters results. 9.2. Case (2)
Kp Ki Kd
The check made on PID-GSA controlled system which is used in
1.1845 0.0216 0.0027
Test (1) without any change in the obtained controller parameters.
The check is carried out by applying an impulse of magnitudes 0.3,
2000 N with width 0.01 s on the cart. The results are shown at 0.4 and 0.5 rad with width 0.01 s on the pendulum rod. The results
Table 12, Fig. 15, Figs. 20 and 21. From Table 12, it is noticed that are shown at Table 13, Figs. 22–24. From Table 13, it is noticed that
the system in the three cases is settled approximately at the same the controller can keep the settling time approximately constant in
time. The variation in the maximum overshoot is caused by varia- the three cases. The variations in the maximum overshoot follow
tion of the impulse peak. the variation of the impulse peak.

Please cite this article as: M. Magdy, A. El Marhomy and M. A. Attia, Modeling of inverted pendulum system with gravitational search algorithm optimized
controller, Ain Shams Engineering Journal, https://doi.org/10.1016/j.asej.2018.11.001
M. Magdy et al. / Ain Shams Engineering Journal xxx (xxxx) xxx 13

Fig. 20. Response of 1500 N impulse.

Fig. 21. Response of 2000 N impulse.

9.4. Case (4)


Table 13
Results of the robustness test.
The check made on PID-GA controlled system which is used in
Impulse Peak Settling Time Max. Overshoot Test (1) with the same obtained controller parameters. The check is
0.3 rad 1.86 0.3 rad carried out by applying an impulse of magnitudes 0.3, 0.4 and
0.4 rad 1.86 0.4 rad 0.5 rad with width 0.01 s on the pendulum rod. The results are
0.5 rad 1.87 0.5 rad
shown at Table 15, Figs. 27–29. Table 15 shows that the controller
can keep the settling time approximately constant in the three
cases. The variations in the maximum overshoot follow the varia-
tion of the impulse peak.
9.3. Case (3)
9.5. Case (5)
The check made on PID-GA controlled system which is used in
Test (1), without any change to the obtained controller parameters. The check made on PID-GSA controlled system which is used in
The check is carried out by applying an impulse of magnitudes Test (2) without any change in the obtained controller parameters.
1000 N, 1500 N and 2000 N with width 0.01 s on the cart. The The check is carried out by applying impulse of magnitudes
results are shown at Table 14, Figs. 16, 25 and 26. From Table 14, 1000 N, 1500 N and 2000 N with width 0.01 s on the cart. The
it is noticed that the system in the case of 1500 and 2000 N results are shown at Table 16, Figs. 30–32. Table 16 shows that
impulse are settled in period longer than the settling time of the system in the three cases is settled approximately at the same
1000 N case. The variations in the maximum overshoot follow time. The variation in the maximum overshoot is caused by varia-
the variation of the impulse peak. tion of the impulse peak.

Please cite this article as: M. Magdy, A. El Marhomy and M. A. Attia, Modeling of inverted pendulum system with gravitational search algorithm optimized
controller, Ain Shams Engineering Journal, https://doi.org/10.1016/j.asej.2018.11.001
14 M. Magdy et al. / Ain Shams Engineering Journal xxx (xxxx) xxx

Fig. 22. Response of 0.3 rad impulse.

Fig. 23. Response of 0.4 rad impulse.

Fig. 24. Response of 0.5 rad impulse.

Please cite this article as: M. Magdy, A. El Marhomy and M. A. Attia, Modeling of inverted pendulum system with gravitational search algorithm optimized
controller, Ain Shams Engineering Journal, https://doi.org/10.1016/j.asej.2018.11.001
M. Magdy et al. / Ain Shams Engineering Journal xxx (xxxx) xxx 15

Table 14 The robustness tests proved again the superiority of GSA over
Results of the robustness test. GA in tuning the controller parameters. PID-GSA controller makes
Impulse Peak Settling Time Max. Overshoot the system more stable.
1000 N 8 0.027
1500 N 8.14 0.0405 10. Contribution
2000 N 8.02 0.054

Several contributions of this work can be summarized as follow:

9.6. Case (6) 1. Modeling of IP by using D’Alembert’s principle without neglect-


ing the viscous friction force while has been neglected in the
The check made on PID-GSA controlled system which is used in most of literature papers.
Test (2) with the same obtained controller parameters. The check is 2. Investigation of the effect of the variation of viscous friction
carried out by applying an impulse of magnitudes 0.3, 0.4 and coefficient on the system stability. This investigation illustrates
0.5 rad with width 0.01 s on the pendulum rod. The results are that the increasing in viscous friction coefficient has a positive
shown at Table 17, Figs. 18, 33 and 34. From Table 17, it is noticed effect on the system stability.
that the controller in the three cases can keep the system stable 3. Analysis of the system free body diagram (FBD) from scratch,
but with slightly increasing in settling time. The variations in the which can be considered as new contribution to declare the
maximum overshoot follow the variation of the impulse peak. FBD of the system in details.
4. Using GSA, an artificial intelligent optimization technique to
tune PID controller with Inverted pendulum is a new applica-
9.7. Case (7) tion for this technique.
5. Robustness test is carried out to ensure the stability of the
The check made on PID-GA controlled system which is used in controller.
Test (2) without changing the obtained controller parameters. The
check is carried out by applying an impulse of magnitudes 1000 N, 11. Conclusion
1500 N and 2000 N with width 0.01 s on the cart. The results are
shown at Table 18, Figs. 35–37. From Table 18, it is noticed that In this work, modeling of IP systems is presented and verified.
the system give the same settling time. But contains high oscilla- The effect of the viscous friction coefficient is studied also in this
tion and high steady state error which is weakens in the system. work. It has been proven that, neglecting viscous friction has neg-
The variations in the maximum overshoot follow the variation of ative effect on the system maximum overshoot under disturbance
the impulse peak but with very high values out of the approxima- of impulse force on the cart. The effect of using Gravitational
tion of small angle variation. Search Algorithm and Genetic Algorithm to tune the PID controller
on the system stability has been also investigated.
It has been also found that GSA with PID controller can give bet-
9.8. Case (8) ter values for PID parameters which result in improving stability of

The check made on PID-GA controlled system which is used in


Test (2) without changing the obtained controller parameters. The
check is carried out by applying an impulse of magnitudes 0.3, 0.4 Table 15
Results of the robustness test.
and 0.5 rad with width 0.01 s on the pendulum rod. The results are
shown at Table 19, Figs. 19, 38 and 39. From Table 19, it is noticed Impulse Peak Settling Time Max. Overshoot
that the controller can keep the settling time approximately con- 0.3 1.88 0.3
stant in the three cases but with high oscillations. The variations 0.4 1.88 0.4
in the maximum overshoot follow the variation of the impulse 0.5 1.9 0.5
peak.

Fig. 25. Response of 1500 N impulse.

Please cite this article as: M. Magdy, A. El Marhomy and M. A. Attia, Modeling of inverted pendulum system with gravitational search algorithm optimized
controller, Ain Shams Engineering Journal, https://doi.org/10.1016/j.asej.2018.11.001
16 M. Magdy et al. / Ain Shams Engineering Journal xxx (xxxx) xxx

Fig. 26. Response of 2000 N impulse.

Fig. 27. Response of 0.3 impulses.

Fig. 28. Response of 0.4 impulses.

Please cite this article as: M. Magdy, A. El Marhomy and M. A. Attia, Modeling of inverted pendulum system with gravitational search algorithm optimized
controller, Ain Shams Engineering Journal, https://doi.org/10.1016/j.asej.2018.11.001
M. Magdy et al. / Ain Shams Engineering Journal xxx (xxxx) xxx 17

Fig. 29. Response of 0.3 impulses.

Table 16
Results of the robustness test. the system under several disturbances with response better than
the Genetic Algorithm. After carrying out the robustness test to
Impulse Peak Settling Time Max. Overshoot
check the stability of the controller performance, it is noticed that
1000 N 1.52 0.33
using PID-GSA will give better response than PID-GA, and will
1500 N 1.52 0.4959
2000 N 1.52 0.6612
decrease the system oscillations.

Fig. 30. Response of 1000 N impulse.

Fig. 31. Response of 1500 N impulse.

Please cite this article as: M. Magdy, A. El Marhomy and M. A. Attia, Modeling of inverted pendulum system with gravitational search algorithm optimized
controller, Ain Shams Engineering Journal, https://doi.org/10.1016/j.asej.2018.11.001
18 M. Magdy et al. / Ain Shams Engineering Journal xxx (xxxx) xxx

Fig. 32. Response of 2000 N impulse.

Table 17 Table 18
Results of the robustness test. Results of the robustness test.

Impulse Peak Settling Time Max. Overshoot Impulse Peak Settling Time Max. Overshoot
0.3 rad 1.27 0.3 1000 N 8.99 1.414
0.4 rad 1.28 0.4 1500 N 8.99 2.121
0.5 rad 1.31 0.5 2000 N 8.99 2.829

Fig. 33. Response of 0.4 rad impulse.

Fig. 34. Response of 0.5 rad impulse.

Please cite this article as: M. Magdy, A. El Marhomy and M. A. Attia, Modeling of inverted pendulum system with gravitational search algorithm optimized
controller, Ain Shams Engineering Journal, https://doi.org/10.1016/j.asej.2018.11.001
M. Magdy et al. / Ain Shams Engineering Journal xxx (xxxx) xxx 19

Fig. 35. Response of 1000 N impulse.

Fig. 36. Response of 1500 N impulse.

Fig. 37. Response of 2000 N impulse.

Please cite this article as: M. Magdy, A. El Marhomy and M. A. Attia, Modeling of inverted pendulum system with gravitational search algorithm optimized
controller, Ain Shams Engineering Journal, https://doi.org/10.1016/j.asej.2018.11.001
20 M. Magdy et al. / Ain Shams Engineering Journal xxx (xxxx) xxx

Table 19 V ¼ PotentialEnergy ¼ mglcosðhÞ


Results of the robustness test.
0 1 2
Impulse Peak Settling Time Max. Overshoot
D ¼ Rayleigh sDissipationFunction ¼ bx_
0.3 2.23 0.3
2
0.4 2.23 0.4
0.5 2.23 0.5 L ¼ LagrangeFunction ¼ T  V
1 2 2
A
¼ ðM þ mÞx_ 2 þ ml h_ 2 þ mlx_ h_ cos ðhÞ þ mglcosðhÞ
2 3

Derivation of system equations of motion using Lagrange’s q1 ¼ x :


Equations.  
Lagrange’s equations of motion of the presented holonomic d @L @L @D
 þ ¼F
non-conservative system are: dt @ x_ @x @ x_
 
d @L @L
 @q þ @@D ¼ Q i ; i ¼ 1; 2 )ðM þ mÞ€x þ bx_ þ ml€h cos ðhÞ  mlh_ 2 sin ðhÞ ¼ F
dt @ q_i i q_
i

T ¼ Kinetic Energy ¼ 12 mv c 2 þ 12 Ic h_ 2 þ 12 Mx_ 2


q2 ¼ h :
where  
d @L @L
 ¼0
Ic ¼ Moment of inertia about center of mass ¼ 13 ml
2
dt @ h_ @h
!
v c ¼ VelocityofcenterofmassofIP ¼ xi
_ þ lh_ cos ðhÞi þ lh_ sin ðhÞj
4 2
)ml€xcosðhÞ þ ml €h þ mglsinðhÞ ¼ 0
1 2 2 3
)T ¼ ðM þ mÞx_ 2 þ ml h_ 2 þ mlx_ h_ cos ðhÞ
2 3

Fig. 38. Response of 0.4 impulses.

Fig. 39. Response of 0.5 impulses.

Please cite this article as: M. Magdy, A. El Marhomy and M. A. Attia, Modeling of inverted pendulum system with gravitational search algorithm optimized
controller, Ain Shams Engineering Journal, https://doi.org/10.1016/j.asej.2018.11.001
M. Magdy et al. / Ain Shams Engineering Journal xxx (xxxx) xxx 21

References [13] Roose Ahmad Ilyas, Yahya Samer, Al-Rizzo Hussain. Fuzzy-logic control of an
inverted pendulum on a cart. Elsevier, Comput Electr Eng 2017;61:31–47.
ß en Muhammed Arif, Bakırcıoğlu Veli, Kalyoncu Mete. Performances
[14] S
[1] Çakan A. PID control of inverted pendulum using adams and matlab co-
comparison of the bees algorithm and genetic algorithm for PID controller
simulation. Proceedings of the 4th international conference on control,
tuning. In: ICMCE ’16, Italy, December 14–17, 2016. p. 4503–5215.
mechatronics and automation, vol. 978(1). p. 4503–5213.
[15] Moghaddas M, RezaDastranj M, Changizi N, Khoori N. Design of optimal PID
[2] Prasad Lal Bahadur, Tyagi Barjeev, Gupta Hari Om. Modelling & simulation for
controller for inverted pendulum using genetic algorithm. Int J Innov Manage
optimal control of nonlinear inverted pendulum dynamical system using PID
Technol 2012;3(4).
controller & LQR. IEEE Comput Soc 2012;978. pp. 7695-4730.
[16] Sen MA, Kalyoncu M. Optimisation of a PID controller for an inverted
[3] Younis W, Abdelati M. Design and implementation of an experimental segway
pendulum using the bees algorithm. Appl Mech Mater 2015;789–
model. AIP Conf Proc 2009;1107:350–4.
790:1039–44.
[4] Kajita S, Morisawa M, Miura K, Nakaoka S, Harada K, Kaneko K, et al. Biped
[17] Pham DT, Koc E, Kalyoncu M, Tınkır M. Hierarchical PID controller design for a
walking stabilization based on linear inverted pendulum tracking. In:
flexible link robot manipulator using the bees algorithm. In: Proceedings of
Proceedings of the IEEE international conference on intelligent robots and
6th international symposium on intelligent manufacturing systems, Sakarya,
systems, Taipei. p. 4489–96.
Turkey. p. 757–65.
[5] Kumar Pankaj, Chakraborty Kunal, Mukherjee RabiRanjan, Mukherjee
[18] Salem Mohammed, Khelfi Mohamed F. Nonlinear inverted pendulum PID
Suvobratra. Modelling and controller design of inverted pendulum. Int J Adv
control by an improved artificial bees colony-predator and prey approach. IEEE
Res Comput Eng Technol 2013;2(1).
proceedings of the 3rd international conference on systems and control, 2013.
[6] Wang Jia-Jun. Simulation studies of inverted pendulum based on PID
pp. 4799-0275.
controllers. Simulat Model Pract Theory 2011;19:440–9.
[19] Dorf, Bishop. Modern control systems. Chapter 2 Mathematical models of
[7] Kafetzis Ioannis, Moysis Lazaros. Inverted pendulum: a system with
systems, section 2.5. 12th ed. Pearson/Prentice-Hall; 2005. p. 70–3.
innumerable applications. 9th international week dedicated to maths, 2017.
[20] Kim Sang-Hoon. Electric motor control: DC, AC, and BLDC motors. In: Chapter
[8] Jakovljevića Boris B., Sekara Tomislav B., Rapaića Milan R. and Jeličić
2 – Control of direct current motors. Elsevier; 2017. p. 39–93.
Zoran D., On the distributed order PID controller, Int J Electron Commun
[21] Yusuf Lukman A, Magaji Nuraddeen. GA-PID controller for position control of
79(September), 2017, 94–101.
inverted pendulum. IEEE; 2014. p. 4799–998.
[9] Wei Fu, Liangzhong Giang, Bian Qingqing Yang Jin. Inverted pendulum control
[22] Guida Domenico, Nilvetti Fabio, Pappalardo Carmine Maria. Dry friction
system based on GA optimization. IEEE Comput Soc 2007.
influence on cart pendulum dynamics. Int J Mech 2009;3(2).
[10] Zhang J, Zhang L, Xie J. Application of memetic algorithm in control of linear
[23] Bahr Khalil Medhat K. Estimated versus calculated viscous friction coefficient
inverted pendulum. In: IEEE international conference on cloud computing and
in spool valve modeling. IFPE 2008 technical conference, 2008.
intelligence systems (CCIS). p. 103–7.
[24] Sultan Khalil. Inverted pendulum analysis, design and
[11] Dastranj MR. Design of optimal PID controller using genetic algorithm. Aust J
implementation. Karachi (Pakistan): The Instrumentation and Control Lab at
Basic Appl Sci 2011;5(10):996–1001.
the Institute of Industrial Electronics Engineering; 2003.
[12] Wang Chunyang, Yin Gaofeng, Liu Canglong, Fu Weicheng. Design and
[25] Rashedi Esmat, Nezamabadi-pour Hossein, Saryazdi Saeid. GSA: a gravitational
simulation of inverted pendulum system based on the fractional PID
search algorithm. Inf Sci 2009;179:2232–48.
controller. IEEE 11th conference on industrial electronics and applications
(ICIEA), China, 2016. pp. 4673-8644.

Please cite this article as: M. Magdy, A. El Marhomy and M. A. Attia, Modeling of inverted pendulum system with gravitational search algorithm optimized
controller, Ain Shams Engineering Journal, https://doi.org/10.1016/j.asej.2018.11.001
View publication stats

You might also like