# Stabilization and Tracking Control of Inverted Pendulum Using Fractional Order PID Controllers

Authors: Sunil Kumar Mishra; Dinesh Chandra
Journal: Journal of Engineering
 (2014)

---

## Abstract

This work focuses on the use of fractional calculus to design robust fractional-order PID (PIλDμ) controller for stabilization and tracking control of inverted pendulum (IP) system. A particle swarm optimisation (PSO) based direct tuning technique is used to design two PIλDμ controllers for IP system without linearizing the actual nonlinear model. The fitness function is minimized by running the SIMULINK model of IP system according to the PSO program in MATLAB. The performance of proposed PIλDμ controllers is compared with two PID controllers. Simulation results are also obtained by adding disturbances to the model to show the robustness of the proposed controllers.


---

## Body

## 1. Introduction

The inverted pendulum (IP) system, nonlinear and unstable system, is widely used in laboratories to implement and validate new ideas emerging in control engineering. The control of IP system can be broadly divided into three sections, swing-up control, stabilization, and tracking control. Swing-up control is basically used to swing the pendulum rod from pending position to stabilization zone. Then a balancing or stabilization control is essential to uphold it in upright position for long interval. A switching mechanism between swinging and stabilization zone is necessary for effective control [1, 2]. For swing-up control, a technique based on energy control had been proposed by Åström and Furuta [3].There are several different techniques accessible in literature for stabilization and tracking control of IP system, for example, linear quadratic regulator (LQR), PID control, neural network control, fuzzy logic control, neural-fuzzy control, sliding mode control, and so forth. The LQR, an optimal state feedback controller designed by minimizing a performance index, is ordinarily used controller for IP system modelled in state space form [4]. Here, the state space model of IP system is to be inevitably linearized which leads to modelling error. The PID controller, most widely used controller in several industrial control problems, is one of the favourite controllers for IP system. The comparison of PID controller with other control techniques of IP system was carried out in many studies [5, 6]. The major task of PID controller design is the selection of control parameters for desired response. Some tuning methods of PID controller for IP system could be found in literature [7–9]. In [10], the stabilization as well as tracking control of IP system with actual nonlinear model using PID controllers was investigated but how to choose controllers parameters was not clarified. Various techniques other than PID are also existing [11–15].In last two decades, the fractional calculus has become much popular among the researchers of different streams but its origin is as older as that of classical integer order calculus. Fractional calculus was not much popular earlier because of its highly complex mathematical expressions. But with the development of computational technologies it has become possible to deal with fractional calculus. Fractional calculus provides much accurate and generalized solution as compared to integer order calculus. The applications of fractional calculus include modelling and control of physical systems [16–18]. One such application is the modelling of two-electric pendulum [19].In the area of control engineering, an application of fractional calculus is the fractional order PID (PIλDμ) controller which is an advanced form of PID control. In some recent studies [20–24], the PIλDμ controller gives better outcomes than PID controller. Though there are some applications of PIλDμ controller for IP system [25, 26], PIλDμ controller has not received considerable attention for unstable systems similar to IP system.Hence, in the present work, fractional order PID controller is designed in time domain to control pendulum angle as well as cart position. Fractional order PID controller is challenging to design because of the use of fractional calculus with very complex calculations. Therefore, a direct approach is used for calculating the parameters of both fractional order PID controllers with the help of a multiobjective fitness function (the fitness function consists of the sum of integral squares of pendulum angle, cart position, and control voltage). The fitness function is minimized by running the model according to a particle swarm optimization (PSO) [27–29] program in MATLAB. PSO is used in this work as it provides greater convergence towards optimal values as compared to other optimization techniques and it has the simple algorithm.The rest of the paper is divided into the following sections. Section2 gives a description of the inverted pendulum system and derivation of system equations in state space form. Section 3 describes the fractional calculus and structure of the PIλDμ controller. Section 4 gives details about PSO. Section 5 gives a complete description of control strategy. Section 6 gives a comparison of the simulation results for PIλDμ controller and PID controller with and without disturbances. The paper ends with the conclusions in Section 7, which is followed by the references.


## 2. Inverted Pendulum System

As shown in Figure1, an IP system has a cart which can move horizontally. One end of the pendulum rod is connected to the centre of the upper surface of the cart which is called the pivot point while the other end is free to move in vertical plane (xz-plane). This pendulum rod is stable in extreme downwards position and known as normal pendulum. But when the pendulum rod remains in upright position, it is known as IP system. This is an unstable condition which needs a continuous balancing force (Fx) on cart in order to remain upright.Figure 1
Structure of inverted pendulum.In Figure1 horizontal force is used as control action to displace the pivot around x axis and the total kinetic energy (K) due to mass of the pivot (M) in x direction, mass of pendulum rod (m) in x and z directions, and potential energy (P) of the IP system [10] which are
(1)K=12Mx˙2+12m(x˙p2+z˙2p),P=mgzp,
where
(2)xp=x+lsinθ,zp=z+lcos⁡θl = the distance from the pivot to the mass centre of the pendulum, (x,z) = the position of the pivot in the xoz coordinate, (x˙,z˙) = the speed in the xoz coordinate, (xp,zp) = the position in the x′o′z′ coordinate, (x˙p,z˙p) = the speed in the x′o′z′ coordinate, and g = the acceleration constant due to gravity. It is assumed that the inertia of the pendulum is negligible. Numerical values of all the parameters of IP system are given in Table 1.Table 1
Inverted pendulum parameters.
M (Kg)
m (Kg)
l (m)
g (m/s2)
1
0.1
0.3
9.8The Lagrange’s equations of the IP system are given as follows:(3a)ddt(∂L∂x)-∂L∂x=Fx,(3b)ddt(∂L∂θ)-∂L∂θ=0,where L=K-P. By putting the expression of L in (3a) and (3b) and after solving it, Lagrange’s equations of the IP system can be expressed as(4a)(M+m)x¨+mlcos⁡θθ¨-mlsinθθ˙2=Fx,(4b)cos⁡θx¨+lθ¨-gsinθ=0,where(5)-0.5≤x≤0.5.According to (4a) and (4b), the state equations of the IP system can be expressed as(6a)x˙1=x2,(6b)x˙2=-mgcos⁡x3sinx3+mlsinx3x42+FxM+msin2x3+d1,(6c)x˙3=x4,(6d)x˙4=-mlcos⁡x3sinx3x42-cos⁡x3FxMl+mlsin2x3+(M+m)gsinx3Ml+mlsin2x3+d2,where x1=x, x2=x˙, x˙3=θ, x4=θ˙, and d1, d2 are the external disturbances.As it is known that IP system is a highly nonlinear and unstable system. Therefore, accurate modelling of a system having nonlinear dynamics cannot be obtained using standard linearization techniques. Hence, in this paper (6a), (6b), (6c), and (6d) are considered as it is without using any linearization technique.


## 3. Fractional Calculus and Fractional Order PID Controller

### 3.1. Fractional Calculus

Fractional calculus [16–18] is a branch of mathematics which deals with integration and differentiation operators that have fractional number powers. Though these types of operators are complex in nature as compared to integer order operators, they provide a generalization which also includes integer order operators.The three most frequently used definitions are Riemann-Liouville, Grünwald-Letnikov, and Caputo [22]. The most common definition is known as Riemann-Liouville:
(7)aDtαf(t)=1⌈(n-α)dndtn∫atf(τ)dτ(t-τ)α-n+1.The second one is the Grünwald-Letnikov given as(8)aDtαf(t)=lim⁡h→01hα∑j=0(t-a)/h(-1)j(αj)f(t-jh),
where (αj)=⌈(α+1)/⌈(j+1)⌈(α-j+1).Finally, Caputo expression is defined as(9)aDtαf(t)=1⌈(α-n)∫atfn(τ)dτ(t-τ)α-n+1,
where, n-1<α<n, n is an integer number, a is initial condition.


### 3.2. Fractional Order PID Controller

PID controller [30, 31] is one of the most extensively used controllers, but in the last two decades the advancement in fractional calculus has introduced the fractional order PID controller in control applications. PIλDμ controller is a generalized form of PID controller. The PIλDμ controller structure is shown in Figure 2, in which the introduction of two extra parameters λ and μ makes it complex as compared to PID controller because of introduction of fractional calculus in it.Figure 2
FOPID controller structure.The differential equation of the PIλDμ controller [23] is described as
(10)u(t)=KPe(t)+KID-λe(t)+KDDμe(t).
The generalization of PID controller is shown in Figure 3, which can be obtained using different values of λ and μ in (10). PID (λ=1, μ=1), PI (λ=1, μ=0), PD (λ=0, μ=1), or P (λ=0, μ=0) are the special cases of PIλDμ controller.Figure 3
Generalization of the PID controller.Taking Laplace transform of (10), the controller expression ins-domain is obtained as
(11)C(s)=U(s)E(s)=KP+KIsλ+KDsμ.By puttingλ=μ=1 in (11), the expression of PID controller can be written as
(12)C(s)=U(s)E(s)=KP+KIs+KDs.Hence, in the present work PID controller is also studied along with the study of PIλDμ controller. In addition, the performance comparisons with the PID controller based on the same design specifications to show that the PIλDμ controller has better performance in terms of performances index are carried out.In (11), sλ and sμ have fractional orders which are not directly compatible with MATLAB and it becomes difficult to realize hardware of PIλDμ controller. Therefore, there are several integer order approximation methods available for fractional order elements [32–34]. The 5th order Oustaloup’s integer order approximation [32] in the frequency range (10-2,102) rad/s is used in this work. In MATLAB fractional order PID controller is implemented using FOMCOM toolbox [35] where Oustaloup’s approximation is realized.


## 3.1. Fractional Calculus

Fractional calculus [16–18] is a branch of mathematics which deals with integration and differentiation operators that have fractional number powers. Though these types of operators are complex in nature as compared to integer order operators, they provide a generalization which also includes integer order operators.The three most frequently used definitions are Riemann-Liouville, Grünwald-Letnikov, and Caputo [22]. The most common definition is known as Riemann-Liouville:
(7)aDtαf(t)=1⌈(n-α)dndtn∫atf(τ)dτ(t-τ)α-n+1.The second one is the Grünwald-Letnikov given as(8)aDtαf(t)=lim⁡h→01hα∑j=0(t-a)/h(-1)j(αj)f(t-jh),
where (αj)=⌈(α+1)/⌈(j+1)⌈(α-j+1).Finally, Caputo expression is defined as(9)aDtαf(t)=1⌈(α-n)∫atfn(τ)dτ(t-τ)α-n+1,
where, n-1<α<n, n is an integer number, a is initial condition.


## 3.2. Fractional Order PID Controller

PID controller [30, 31] is one of the most extensively used controllers, but in the last two decades the advancement in fractional calculus has introduced the fractional order PID controller in control applications. PIλDμ controller is a generalized form of PID controller. The PIλDμ controller structure is shown in Figure 2, in which the introduction of two extra parameters λ and μ makes it complex as compared to PID controller because of introduction of fractional calculus in it.Figure 2
FOPID controller structure.The differential equation of the PIλDμ controller [23] is described as
(10)u(t)=KPe(t)+KID-λe(t)+KDDμe(t).
The generalization of PID controller is shown in Figure 3, which can be obtained using different values of λ and μ in (10). PID (λ=1, μ=1), PI (λ=1, μ=0), PD (λ=0, μ=1), or P (λ=0, μ=0) are the special cases of PIλDμ controller.Figure 3
Generalization of the PID controller.Taking Laplace transform of (10), the controller expression ins-domain is obtained as
(11)C(s)=U(s)E(s)=KP+KIsλ+KDsμ.By puttingλ=μ=1 in (11), the expression of PID controller can be written as
(12)C(s)=U(s)E(s)=KP+KIs+KDs.Hence, in the present work PID controller is also studied along with the study of PIλDμ controller. In addition, the performance comparisons with the PID controller based on the same design specifications to show that the PIλDμ controller has better performance in terms of performances index are carried out.In (11), sλ and sμ have fractional orders which are not directly compatible with MATLAB and it becomes difficult to realize hardware of PIλDμ controller. Therefore, there are several integer order approximation methods available for fractional order elements [32–34]. The 5th order Oustaloup’s integer order approximation [32] in the frequency range (10-2,102) rad/s is used in this work. In MATLAB fractional order PID controller is implemented using FOMCOM toolbox [35] where Oustaloup’s approximation is realized.


## 4. Particle Swarm Optimization

While solving complex optimization problems having large search space the population based swarm intelligence method is the widely accepted alternatives to find the optimal solution. The particle swarm optimization (PSO) was first proposed by Kennedy and Eberhart [27]. The PSO method [27–29] is population based search techniques used for solving the optimization problems having a large search space. This technique mimics the behaviour of bird flocks and fish schools and their collision-free and synchronized moves. Individual bird or fish is known as particle in a PSO system and each particle has its position and velocity. Now particle moves in multidimensional search space according to its own experience and the experience of the neighbouring particles. During the movement in search space, the position and velocity of the particles are updated. There are three factors inertia, cognitive, and social upon which the velocity and position update of particles depend. The complete procedure of PSO algorithm can be understood with the help of Figure 4 which indicates that the PSO algorithm has three steps:(1)
to evaluate the fitness value of each particle,(2)
to update individual best positions (pbest) and global best positions (gbest) according to best or minimum fitness values,(3)
to update velocity and position of each particle in each iteration.Figure 4
Flow diagram of basic PSO algorithm.The above steps are repeated until some stopping criteria are met.The modified velocity and position of each particle can be calculated using the current velocity and position as follows:(13)Vik+1=W×Vik+c1×rand()×(pbest,i-Xik)+c2×rand()×(gbest,i-Xik).Position update equation is given by(14)Xik+1=Xik+Vik+1,
where, k = iteration number, Vi = velocity of ith particle, W = inertia weight factor, c1, c2 = cognitive and social acceleration factors respectively, rand () = random numbers uniformly distributed in the range (0, 1) and Xi = position of ith particle.The expression forW is given by
(15)W=Wmax⁡-[Wmax⁡-Wmin⁡kmax⁡]*k,
where, Wmax⁡, Wmin⁡ = maximum and minimum values of W respectively, kmax⁡ = maximum number of iterations.


## 5.PIλDμ Controller Design Strategy

The main objectives of controller design are as follows:(1)
to stabilize the pendulum at its upright position,(2)
to uphold the cart position at the origin,(3)
tracking of desired position by pendulum cart,(4)
to use minimum control effort required to control the pendulum angle and cart position.To achieve the abovementioned control objective two PIλDμ controllers are used as shown in Figure 5. There are two feedback paths from the two outputs (pendulum angle and cart position) of the IP system and this feedback is given to PIλD1μ and PIλD2μ. The output of each PIλDμ is added and given as control input to the IP system.Figure 5
Basic block diagram of closed loop control system using two PIλDμ controllers.The fitness functionJ to be minimized using PSO is given as
(16)J=∫0T[w1×θ2(t)+w2×x2(t)+w3×u2(t)]dt,
where θ(t), x(t), and u(t) are pendulum angle, cart position, and control input, respectively, and w1, w2, and w3 are the weights to give equal weightage to all parameters. T is the simulation time used for running model in SIMULINK. The fitness function given by (16) has three terms. The first term is the integral square of pendulum angle θ(t) which is used to stabilize pendulum angle. The second term is the integral square of cart position x(t) which is used to stabilize cart position. Finally, the third term is the integral square of control input u(t) which is used to minimize the required control force.Basic block diagram of closed loop control system as shown in Figure5 is prepared in MATLAB/SIMULINK. This model has ten unknown parameters of two PIλDμ controllers. These parameters are supplied by PSO program. Initially, parameters {KP1,KI1,KD1,λ1,μ1} and {KP2,KI2,KD2,λ2,μ2} are generated randomly but later in terms of pbest and gbest by updating the velocity and position of particles in each iteration. After generating controller parameters SIMULINK model is executed according to PSO program. When this model is executed, the fitness value (as given in (16)) of the SIMULINK model is saved in MATLABworkspace which is further utilized by PSO program for evaluating the minimum fitness value and corresponding controller parameters. The whole process is repeated until maximum number of iteration is reached. At the end of the process the values of parameters {KP1,KI1,KD1,λ1,μ1} and {KP2,KI2,KD2,λ2,μ2} are obtained which provides the desired performance of the IP system. Also, by considering λ=μ=1 in both the PIλDμ controllers, integer order PID controllers have been designed using the same specifications and comparative study has been carried out to show the validity of the proposed work.


## 6. Simulation and Results

Parameters of (16) are given in Table 2. As θ(t) and x(t) lie in the ranges {-0.5,0.5} rad and {-0.5,0.5} m, respectively, and are given equal weight but u(t) is given very less weightage because of its high range {-20,20} N. Therefore, all three terms of (16) are minimized equally.Table 2
Parameters of fitness function.
T
w
1
w
2
w
3
30
1
1
0.05With the help of PSO parameters and controller parameters given in Tables3 and 4, the SIMULINK model shown in Figure 5 is executed by PSO program to obtain final parameters for both PIλDμ and PID cases as given in Table 5.Table 3
Values of PSO parameters.
PSO Parameters
Values
Number of particles
10
Number of iterations
25
c
1
2
c
2
2
W
max
⁡
0.9
W
min
⁡
0.1
R
1
0.1
R
2
0.1Table 4
Range of controller parameters.
Controller parameters
Range
K
P
1
,
K
I
1
,
K
D
1
,
-
K
P
2
,
-
K
I
2,−KD2
{0, 50}
λ
1
,
μ
1
,
λ
2
,
μ
2
{0, 1}Table 5
Values of controller parameters.
Controller
K
P
K
I
K
D
λ
μ
J
PI
λ
D
μ
1
22.4734
1.8185
3.1337
0.3579
0.9038
1.7131
PI
λ
D
μ
2
−1.6749
−0.7636
−1.8977
0.4764
0.8908
PID1
23.9288
1.2548
3.2143
—
—
1.8449
PID2
−2.6622
−1.3422
−2.7675
—
—From Table5 it can be concluded that based on the same specifications as given in Tables 2, 3, and 4, the fitness value J using PIλDμ controller is less as compared to PID controller. Controller parameters are calculated for stabilization control (without disturbances) but these values are also applicable in other cases. Simulation results, as shown in Figures 6–9, are obtained for stabilization and tracking control of IP system with and without disturbances. All the simulation results are particularized in next two subsections titled as stabilization and tracking control of IP system.Stabilization of inverted pendulum (without disturbancesd1=d2=0).
(a)
(b)
(c)Stabilization of inverted pendulum (with disturbancesd1=d2=20sin(20πt)).
(a)
(b)
(c)Tracking of inverted pendulum (without disturbancesd1=d2=0).
(a)
(b)
(c)Tracking of inverted pendulum (with disturbancesd1=d2=20sin(20πt)).
(a)
(b)
(c)


### 6.1. Stabilization of Inverted Pendulum

For stabilization, reference cart positionr(t)=0. In Figure 6, waveforms for θ(t), x(t), and u(t) settle to steady state approximately at the same time for both PIλDμ controller and PID controller but during transient period PIλDμ performs better than PID controller. Now to check the robustness of the designed PIλDμ and PID controllers, disturbances are d1=d2=20sin(20πt).Figure7 shows the simulation results with disturbances which are still valid and proves the effectiveness of proposed PIλDμ and PID controllers. The waveforms for θ(t) and u(t) in Figure 7 in case of PIλDμ are better than PID controller but, for x(t) PID, perform slightly better than PIλDμ controller. Also, in the case of control input u(t) PIλDμ provides less deviation during steady state as compared to PID controller.


### 6.2. Tracking Control of Inverted Pendulum

For tracking control, reference cart positionr(t) is considered as 0.3sin(0.05 πt). Figure 8 shows the tracking control of IP system in which PIλDμ controller for θ(t) provides less deviation in transient period and settles earlier to steady state as compared to PID controller. In Figure 8, both PIλDμ and PID provide good tracking but in case of PIλDμ, less control effort is required. In Figure 9, in the presence of disturbances, the PIλDμ controller still outperforms PID controller and in PIλDμ case less control effort is required.Simulation results shown in Figures6–9 are furthermore important from real-time implementation viewpoint as in this simulation study practical conditions have also been taken into consideration.


## 6.1. Stabilization of Inverted Pendulum

For stabilization, reference cart positionr(t)=0. In Figure 6, waveforms for θ(t), x(t), and u(t) settle to steady state approximately at the same time for both PIλDμ controller and PID controller but during transient period PIλDμ performs better than PID controller. Now to check the robustness of the designed PIλDμ and PID controllers, disturbances are d1=d2=20sin(20πt).Figure7 shows the simulation results with disturbances which are still valid and proves the effectiveness of proposed PIλDμ and PID controllers. The waveforms for θ(t) and u(t) in Figure 7 in case of PIλDμ are better than PID controller but, for x(t) PID, perform slightly better than PIλDμ controller. Also, in the case of control input u(t) PIλDμ provides less deviation during steady state as compared to PID controller.


## 6.2. Tracking Control of Inverted Pendulum

For tracking control, reference cart positionr(t) is considered as 0.3sin(0.05 πt). Figure 8 shows the tracking control of IP system in which PIλDμ controller for θ(t) provides less deviation in transient period and settles earlier to steady state as compared to PID controller. In Figure 8, both PIλDμ and PID provide good tracking but in case of PIλDμ, less control effort is required. In Figure 9, in the presence of disturbances, the PIλDμ controller still outperforms PID controller and in PIλDμ case less control effort is required.Simulation results shown in Figures6–9 are furthermore important from real-time implementation viewpoint as in this simulation study practical conditions have also been taken into consideration.


## 7. Conclusion

The stabilization and tracking control of IP system are attained successfully using PSO based direct tuning method. The use of PSO technique for calculating controller parameters is very simple and provides good convergence towards optimal values. Two integer order PID controllers have also been designed by keeping the same specifications. A comparative study has been carried out and the obtained results are quite acceptable for both PIλDμ and PID controllers but the PIλDμ controller seems to be more robust. The PIλDμ could be the good replacement for PID in the forthcoming years. The real time implementation of PIλDμ controller might be the subject of further research.



---

*Source: 752918-2014-04-23.xml*