Keywords

1 Introduction

Inverted cart-pendulum is an example of inherently nonlinear, unstable, multivariable and non-minimum phase system. It has always been a challenging task for the engineers to develop a proper control strategy to control this system. Many researchers have proposed different control techniques which include use of classical methods to modern methods, such as artificial neural network (ANN), fuzzy logic, genetic algorithm (GA), and swarm intelligence. [14]. In last few decades, the use of these modern methods has gained immense popularity in different field of research because of the ability to provide satisfactory and accurate result [5, 6].

The aim of this paper is to design a two-loop PID controller for cart-pendulum system so that it moves the cart to a desired position and pendulum stabilizes in an upright equilibrium position [7, 8]. In this paper, modified genetic algorithm has been applied to optimize the controller parameters.

This paper is organized in eight sections. Section 1 gives the introduction of the paper. In Sect. 2 brief overview, specifications, free body diagram, mathematical model and state space representation of cart-pendulum system is provided. Sections 3 and 4 deals with dominant pole calculation and the structure of plant with two-loop PID controller. In Sect. 5, optimization of objective function through modified GA has been provided. Section 6 is about the simulation diagram and response of the system with two-loop PID, LQR and LQG control. Performance comparison between different methods and conclusion are provided in Sects. 7 and 8 respectively.

2 Cart-Pendulum System

The schematic diagram of cart-pendulum system considered in this paper is provided in Fig. 1.

Fig. 1
figure 1

Cart-pendulum system

The system consists of an inverted pendulum mounted on a motorized cart. In this paper, a two dimensional problem is considered where the pendulum is allowed to move in the vertical plane with the presence of the control force ‘F’. This force works as the input to this system and it moves the cart horizontally. The outputs of the systems are the horizontal position of the cart ‘x’ and the angular position of the pendulum ‘\( \theta \)’.

The parameters of the cart pendulum system [9] are taken as follows:

M—mass of the cart (2.4 kg), m—mass of the pendulum (0.23 kg), b—coefficient of cart friction (0.055 Ns/m), L—length of the pendulum (0.4 m), J—moment of inertia of pendulum (0.099 kg m2), g—gravitational constant (9.81 m/s2), F—applied force to cart \( \pm \)24 N, x—position of the cart from reference (\( \pm \)0.3 m), \( \theta \)—angle of pendulum with respect to vertical (\( \le \)0.1 rad).

By applying the laws of dynamics on cart-pendulum system, the equations of motions [9] are obtained as:

$$ \ddot{\theta} = mL/\sigma \{ \left[ {F - b\dot{x}} \right]\cos \theta - mL\left( {\dot{\theta }} \right)^{2} \cos \theta \,\sin \theta + \left( {m + M} \right)g\,sin \theta \} $$
(1)
$$ {\ddot x} = 1/\sigma \{ \left({J + mL^{2} } \right)\left[ {F - b\dot{x} - mL{\dot{\theta }}^{2} \sin \theta } \right] + mL^{2} g\,\sin \theta \,\cos \theta \} $$
(2)

where

$$ \sigma = mL^{2 } \left( {M + m cos^{2} \theta } \right) + J(M + m) $$
(3)

Linearizing Eqs. (1) and (2) for a small angle \( \theta \) from the vertical equilibrium point and by neglecting friction coefficient b which is very small, the state space model is obtained as:

$$ \left[ {\begin{array}{*{20}c} {\dot x} \\ {\ddot{x}} \\ {\begin{array}{*{20}c} {\dot{\theta }} \\ {\ddot{\theta }} \\ \end{array} } \\ \end{array} } \right] = \left[ {\begin{array}{*{20}l} 0 \hfill & 1 \hfill & 0 \hfill & 0 \hfill \\ 0 \hfill & 0 \hfill & {0.2381} \hfill & 0 \hfill \\ 0 \hfill & 0 \hfill & 0 \hfill & 1 \hfill \\ 0 \hfill & 0 \hfill & {6.8073} \hfill & 0 \hfill \\ \end{array} } \right]\,\left[ {\begin{array}{*{20}c} x \\ {\dot{x}} \\ {\begin{array}{*{20}c} \theta \\ {\dot{\theta }} \\ \end{array} } \\ \end{array} } \right] + \left[ {\begin{array}{*{20}c} 0 \\ {0.3894} \\ {\begin{array}{*{20}c} 0 \\ {0.2638} \\ \end{array} } \\ \end{array} } \right]F,{\text{y}} = \left[ {\begin{array}{*{20}c} 1 & 0 & {\begin{array}{*{20}c} 0 & 0 \\ \end{array} } \\ 0 & 0 & {\begin{array}{*{20}c} 1 & 0 \\ \end{array} } \\ \end{array} } \right]\,\left[ {\begin{array}{*{20}c} x \\ {\dot{x}} \\ {\begin{array}{*{20}c} \theta \\ {\dot{\theta }} \\ \end{array} } \\ \end{array}} \right] $$
(4)

where \( x,\dot{x},\theta ,\dot{\theta } \) are the states and y is the output vector. A DC motor is used to convert control voltage U to force F and represented by a single block with gain taken as unity, i.e., U = F. For U = F, from this state space representation, the transfer function can be derived as [9]:

$$ \frac{X(s)}{F(s)} = \frac{X(s)}{U(s)} = P1 = \frac{0.3894}{{s^{2} }} , \frac{\theta (s) }{F(s)} = \frac{\theta (s)}{U(s)} = P2 = \frac{0.2638}{{s^{2} - 6.807}} $$
(5)

3 Dominant Pole Calculation

The design specifications for this study have been taken as

$$ {\text{Maximum}}\,{\text{overshoot}}\,\left( {M_{p} } \right)\; \le \, 8\% \,{\text{and}}\,{\text{Settling}}\,{\text{time}}\,t_{s} \, \le \, 3\,{\text{s}} $$

According to these specifications, dominant poles have been found to be at \( s_{1,2} = - 1.33335 \pm 1.65845i. \)

4 Cart-Pendulum System with Two-Loop PID Controller

The cart-pendulum system with two-loop PID Controller is shown in the following Fig. 2

Fig. 2
figure 2

Cart-Pendulum system with two-loop PID controller

The characteristics equation for the system given in Fig. 2 becomes

$$ 1 - P_{1} C_{1} + P_{2} C_{2} = 0 $$
(6)

And the PID controllers are represented by

$$ C_{1} = k_{p1} + \frac{{k_{i1} }}{s} + k_{d1} s\,,\,C_{2} = k_{p2} + \frac{{k_{i2} }}{s} + k_{d2} s $$
(7)

After substituting s = −1.33335 + j1.65845 in Eq. (6) and separating the real (R) and imaginary (I) part, R and I will be

$$ R = 1 + 0.0184k_{p1} -0.036k_{i1} + 0.1145k_{d1} - 0.0256k_{p2} + 0.0127k_{i2} + 0.01k_{d2} $$
(8)
$$ I = - 0.0839k_{p1} + 0.0179k_{i1} + 0.1424k_{d1} + 0.0145k_{p2} + 0.005k_{i2} - 0.0617k_{d2} $$
(9)

where kp1, ki1 and kd1 denote the coefficient for the proportional, integral and derivative terms, respectively, for Controller 1 (C1) and kp2, ki2 and kd2 denote the same for Controller 2 (C2).

The objective function ‘f’ considered for obtaining the value of kp1, ki1, kd1, kp2, ki2 and kd2 has the following format:

$$ f = \left| R \right| + \left| I \right| + \left| \theta \right|,{\text{where}} \,\theta = { \tan }^{ - 1} \left( {\frac{|I|}{|R|}} \right) $$
(10)

5 Objective Function Optimization Using Modified GA

In this paper, we have proposed modified genetic algorithm (GA) where best solution in each iteration does not take part in the process of crossover and mutation, rather its cloned one is used for that purpose. In the next stage, best solution along with off springs created is taken into consideration. It could be useful for optimizing those multimodal functions where there are number of maxima and minima having close value, due to which there is a chance of the solution to be trapped in local optima while solving directly through normal GA. The specifications taken for writing MATLAB code are as follows:

Population size, bit size, crossover probability, mutation probability and number of iteration are taken as 100, 10, 0.8, 0.125 and 25, respectively.

The objective function considered over here has six unknowns, i.e., \( k_{p1} ,k_{i1} ,k_{d1} ,k_{p2} ,k_{i2} \,{\text{and}}\,k_{d2} \). The range of these parameters taken for writing the code is: \( 3 \le k_{p1} \le 5, 0 \le k_{i1} \le 0.002, 2 \le k_{d1} \le 4, 220 \le k_{p2} \le 222, 120 \le k_{i2} \le 122\,{\text{and}}\,59 \le k_{d2} \le 61 \), respectively, and it has been decided after a number of trial runs.

After optimizing the objective function through modified GA one obtains the values of \( k_{p1} ,k_{i1} ,k_{d1} ,k_{p2} ,k_{i2} {\text{and }}k_{d2} \) as 4.5213, 0.0012, 2.5712, 220.3164, 120.9867 and 60.7956, respectively.

It should be noted that the objective function value for these set of parametric values is not exactly zero as expected because of approximate linearization of nonlinear system around the equilibrium point.

6 Simulation Diagram and Result

6.1 With Two-Loop PID Controller

The simulation diagram for the cart-pendulum system with two-loop PID is shown in Fig. 3.

Fig. 3
figure 3

Cart-pendulum system with two-loop PID simulation diagram

Unit step signal has been taken as reference signal for this study and the closed loop simulation is carried out for 100 s. The output response in terms of position and angle is shown in Fig. 4.

Fig. 4
figure 4

Position of cart and angle of pendulum with two-loop PID control

6.2 With LQR Control

For LQR design,

$$ u = r - kx, \dot{x} = Ax + Bu, y = Cx + Du $$
(11)

The gain matrix ‘k’ has been identified by optimizing the cost function

$$ J(u) = \mathop \smallint \limits_{0}^{\infty } (x^{T} Qx + u^{T} Ru + 2x^{T} Nu){\text{d}}t $$
(12)

where Q is the semi positive definite, R is the positive definite and N is the state reference gain matrix and all the notations are conventional.

The state feedback gain matrix ‘k’ required for LQR control is given by

$$ k = \left[ {\begin{array}{*{20}c} { - 1} & { - 3.0620} & {\begin{array}{*{20}c} {71.7899} & {27.6065} \\ \end{array} } \\ \end{array} } \right] $$

The simulation diagram for the cart-pendulum system with LQR control is shown in Fig. 5.

Fig. 5
figure 5

Cart-pendulum system with LQR control simulation diagram

The output response of LQR control in terms of position and angle is shown in Fig. 6.

Fig. 6
figure 6

Position of cart and angle of pendulum with LQR control

6.3 With LQG Control

For LQG design

$$ \dot{\hat{x}} = A\hat{x} + Bu + L\left( {y - \hat{y}} \right),\,y = Cx + Du $$
(13)

The cost function that to be minimized in LQG control is given by

$$ J = E\left\{ {\mathop {\lim }\limits_{\tau \to \infty } \frac{1}{\tau }\mathop \smallint \limits_{0}^{\tau } \left[ {x^{T} ,u^{T} } \right]Q_{xn} \left[ {\begin{array}{*{20}c} x \\ u \\ \end{array} } \right]dt} \right\} $$
(14)

The simulation diagram for the cart-pendulum system with LQG control is shown in Fig. 7.

Fig. 7
figure 7

Cart-pendulum system with LQG control simulation diagram

The matrix L required for LQG control is mathematically represented as

$$ L = \left[ {\begin{array}{*{20}c} {42.8514} & {1.0395} \\ {458.3565} & {22.6295} \\ {\begin{array}{*{20}c} {0.9384} \\ {20.1527} \\ \end{array} } & {\begin{array}{*{20}c} {43.1486} \\ {471.4483} \\ \end{array} } \\ \end{array} } \right] $$

The output response of LQG control in terms of position and angle is shown in Fig. 8.

Fig. 8
figure 8

Position of cart and angle of pendulum with LQG control

In this study, pre-compensation technique has been used for both LQR and LQG and it has been shown as a gain block after the reference step input. The value of the gain is taken as −1 and has been confirmed from MATLAB code written for the LQR and LQG control of cart-pendulum system.

7 Performance Comparisons Between Two-Loop, LQR and LQG Control

The performance of different control techniques is provided in the Table 1 which clearly indicates the superiority of two-loop PID controller as compared to LQR and LQG control.

Table 1 Performance comparison between different control techniques

8 Conclusion

In this study, two-loop PID, LQR and LQG controllers have been designed for the cart-pendulum system and the performance of these controllers has been compared. It has been found that two-loop PID controller along with modified GA provides better response than LQR and LQG controller in terms of both overshoot and settling time. For improving time domain response and robustness, this particular approach of using two-loop PID along with proposed modified GA can be extended to the other class of MIMO plants. A comprehensive analysis of robustness to model uncertainties for inverted cart-pendulum system will be incorporated in the future work.