Keywords

1 Introduction

The controllers are placing major in the automated industry due to its efficient operation of system. In this PID, controller is extensively used in industry due to its simplicity and effectiveness. To realize any controller, the gains of controller must be determined effectively. To determine the gains of PID controller, more efforts has been devoted to reduce the required time and to optimize the PID parameter values. There are numerous tuning techniques are available based on the implementation methods [1]. Tuning methods are mainly classified as: (i) empirical methods (Zā€“N) (ii) analytical method such as rootā€“locus-based design, and (iii) Optimization methods such as iterative feedback tuning. For the extensive range of industrial applications, Zā€“N fine-tuning technique suits well, but the main shortcoming of this process is that the operator needs to have clear awareness about plant model [2]. Once it is tuned by Zā€“N technique, it gives good response, but it is not optimum. If there exists any change in the plant dynamics, then the transient response of the system will vary drastically. To guarantee an independent performance, the controller must have the capability of adapting to the changes in the plant dynamics [3]. Current years, artificial intelligent methods such as fuzzy logic, genetic algorithms (GA), and neural networks are rigorously used due to various features.

Advancements in digital technology have made the controllers automatic. The automatic control system facilitates a wide range of options for control schemes, despite the fact that more than 90% of industrial controllers are still employed based on the PID algorithms, mostly at the low levels, since none of the controller will facilitate the advantages like PID controller. The main features of PID controller are applicability, clear functionality, and simplicity in structure. There are numerous optimization and optimal control procedures available for linear and nonlinear dynamic systems [4,5,6] to meet the performance optimization requirements of dynamic systems.

The authors in [7] tuned controller constants in a trial-and-error technique, which was time consuming and increased the complexity, and the system response is not satisfactory. More efficient ways to optimize PID gains has been proposed by the authors in [8,9,10]; in these methods, authors implemented the deterministic optimization procedures based on the integrated absolute error (IAE) standards are used, but these techniques use the predefined MATLAB toolbox and their tuned gains are optimum in only certain operative regions and these techniques are not robust. To bring the inverted pendulum to be stable in vertical position and to control the cart at the preferred position, two PID controllers are required. One can be used for the rod angle control known as angle PID controller, and another for the cart position, and it is referred as cart PID controller [1]. This method increases the complexity of the system. To overcome the drawbacks of existing systems, optimization techniques were widely used for effective operation of system.

Genetic algorithms (GAā€™s) are search techniques motivated by the laws of a genetics and natural selection. The GA is first implemented by Holland based on the Darwinā€™s principal. This can be seen as an optimization technique and is applied to search, machine learning, and optimization tasks [11,12,13]. GA was effectively adapted to the system dynamics [14]. In this article, gains of PID controller are tuned via GA method for a linear inverted pendulum. To illustrate the effectiveness of genetic algorithm-tuned PID controller, the impulse and step* responses are plotted and are compared with that of the conventional (Zā€“N) method.

2 Mathematical Model

In this analysis, an inverted pendulum on a moving cart is explored. A pendulum rod is moved around a rigid pivot point fixed to the cart, driven by the stepper motor which is forced to move on the horizontal platform. The rod is set in the vertical position, which is known as an equilibrium point. Main intention is to apply a force to move the cart so that the pendulum stays in the vertical position. The system is shown in Fig.Ā 1, where F is the force in Newton, m is the mass of the pendulum rod in kilogram, M is the mass of the moving cart in kilogram, FV is the force applied to the cart in Newton, \(F_{f}\) is the force due to friction in Newton, g is the acceleration due to gravity in \(m^{*} s^{ - 2}\), and Īø is the angle of the inverted pendulum measured from the vertical y-axis in radians.

Fig.Ā 1
figure 1

Representation of the inverted pendulum system

Consider the free-body diagrams shown in Fig.Ā 2. In addition, assume that the coordinates of the center of gravity of the pendulum, (\(x_{G}\), \(y_{G}\)), are given by:

Fig.Ā 2
figure 2

Free-body schematic of a cart b pendulum c formative the required distances

$$x_{G} = x + 1\sin \theta ,\quad y_{G} = 1\cos \theta$$
(1)

where l is the distance along the pendulum to the center of gravity and x is the xĀ -coordinate of the cart.

$$M\frac{{{\text{d}}^{2} x}}{{{\text{d}}t^{2} }} = F_{v} - \left( {\frac{{{\text{d}}^{2} x}}{{{\text{d}}t^{2} }} - l\,\sin \theta \left( {\frac{{{\text{d}}\theta }}{{{\text{d}}t^{{}} }}} \right)^{2} + l\,\cos \theta \frac{{{\text{d}}^{2} \theta }}{{{\text{d}}t^{2} }}} \right) - b\frac{{{\text{d}}x}}{{{\text{d}}t}}$$
(2)
$$F_{y} = mg - m\left( {l\,\sin \theta \frac{{{\text{d}}^{2} \theta }}{{{\text{d}}t^{2} }} + l\,\cos \theta \left( {\frac{{{\text{d}}\theta }}{{{\text{d}}t}}} \right)^{2} } \right)$$

From the Newtonā€™s laws of motion, the force along horizontal and vertical axis is given as: For any object, the relationship between the moment applied and angular acceleration of the object is given by the following relationship.

$$\sum {\mathop M\limits^{ - } = I\frac{{{\text{d}}^{2} \theta }}{{{\text{d}}t^{2} }}}$$
(3)

For the inverted pendulum, moment is summed around its center of gravity, Eq.Ā (3) can be rewritten as

$$F_{y} \,l\,\sin \theta - F_{x} \,l\,\cos \theta = I\frac{{{\text{d}}^{2} \theta }}{{{\text{d}}t^{2} }}$$
(4)

The equations of motion for the inverted pendulum on a moving cart can be written as

$$\begin{aligned} M\frac{{{\text{d}}^{2} x}}{{{\text{d}}t^{2} }} &= F_{v} - m\left( {\frac{{{\text{d}}^{2} x}}{{{\text{d}}t^{2} }} - l\,\sin \theta \left( {\frac{{{\text{d}}\theta }}{{{\text{d}}t}}} \right)^{2} + l\,\cos \theta \frac{{{\text{d}}^{2} \theta }}{{{\text{d}}t^{2} }}} \right) \\ &\quad - b\frac{{{\text{d}}x}}{{{\text{d}}t}}\left( {I + ml^{2} } \right)\frac{{{\text{d}}^{2} \theta }}{{{\text{d}}t^{2} }} = mgl\,\sin \theta - ml\,\cos \theta \,\frac{{{\text{d}}^{2} x}}{{{\text{d}}t^{2} }} \\ \end{aligned}$$
(5)

The model of the pendulum system given in Eq.Ā (5) is nonlinear model and must be linearized in order to get a sensible model for control purposes. The parameter values selected for experimentation were mentioned in TableĀ 1. Linearization will be performed about the point \(x = 0\;{\text{m}}\) and \(\theta = 0\,{\text{radians}}\) (appx). Under these assumptions, Eq.Ā (5) can be rewritten as

TableĀ 1 Hardware specifications of LIP [3]
$$\begin{aligned} & \left( {M + m} \right)\frac{{{\text{d}}^{2} x}}{{{\text{d}}t^{2} }} = F_{v} - ml\frac{{{\text{d}}^{2} \theta }}{{{\text{d}}t^{2} }} - b\frac{{{\text{d}}x}}{{{\text{d}}t}} \\ & \left( {I + ml^{2} } \right)\frac{{{\text{d}}^{2} \theta }}{{{\text{d}}t^{2} }} = mgl\;\theta - ml\frac{{{\text{d}}^{2} x}}{{{\text{d}}t^{2} }} \\ \end{aligned}$$
(6)

By using Laplace transformation to the Eq.Ā (6), it can be written as:

$$\begin{aligned} & \left( {M + m} \right)X\left( s \right)S^{2} = U\left( s \right) - ml\theta \left( s \right)S^{2} - bX\left( s \right)S \\ & \left( {I + ml^{2} } \right)\,\theta \left( s \right)S^{2} = mgl\,\theta \left( s \right) - ml\,X\left( s \right)S^{2} \\ \end{aligned}$$
(7)

The output of the system can be written by solving the Eq.Ā (7)

$$\frac{\theta \left( s \right)}{X\left( s \right)} = \frac{{ml\,S^{s} }}{{\left( {I + ml^{2} } \right)S^{2} - mgl}}$$
(8)

3 PID Controller

Tuning of PID controller is a challenging task, even though there are only three parameters in the system, because it must satisfy several criteria within the limitations of PID control. Controller design and tuning seem to be theoretically intuitive; however, it can be tough in real time, if various objectives such as good stability and transient response are to be attained. PID controllers generally provide adequate control by default tunings by using the traditional methods, but performance can be enhanced by fine tuning, and poor tuning may lead to undesirable performance. Typically, initial designs need to be adjusted frequently through simulations until the closed-loop system performs as desired. The most common practice in industries is to utilize PID controller. The schematic of PID is shown in Fig.Ā 3. This set up is acknowledged as parallel form or non-interacting form.

Fig.Ā 3
figure 3

Schematic of the PID controller in parallel form

The output of a general PID controller in a parallel form is given as:

$$G_{c} \left(s \right) = K_{p} \,\left({1 + \frac{1}{{sT_{i}}} + T_{d} S} \right)$$
(9)

where \(K_{p}\),\(T_{i}\), and \(T_{d}\) are proportional gain, integral, differential time constants. \(K_{i} = K_{p} /T_{i}\), \(K_{d} = K_{p} T_{d} \,k_{p} \,k_{i}\) are derivative and integral gains, respectively.

The tuning of PID means generating the gains of individual controller in a system, for this conventional Zā€“N method is used. It is based on critical gain \(K_{c}\) and oscillation period \(T_{c}\). In this technique, the integral time T i is initially set to infinity, and the derivative time \(T_{d}\) is set to zero. This step is only for the proportional control. \(K_{p}\) will be varied until the system output is oscillatory, and the gain pertaining to this is called as critical gain. In case the output is not oscillatory which indicates Zā€“N method is not applied. The goal is to minimize the peak overshoot within the limit of 10%. In case the maximum overshoot is greater than 15%, gain adjustment has to be done to decrease it to less than 10%. The parameters tuned using Zieglerā€“Nichols frequency method [1]; the parameters of PID controller are tuned and shown in TableĀ 2.

TableĀ 2 Zā€“N method of tuning

4 Genetic Algorithm

Genetic algorithm is a population-based global search algorithm that follows Darwinā€™s principle of survival of the fittest was first proposed by John Holland and his students in the year 1970. The process of GA starts without any knowledge of the output, it will adapt to the environment in which it is working, and the optimization will take place with the help of its operators such as crossover, mutation, and reproduction to attain the global best solution. The method starts with random initial values and explore the search space parallelly. GAā€™s can be applied to complex problems irrespective of its dimensionality, compared to the other gradient techniques which depends on the order of derivative [14].

4.1 Characteristics of Genetic Algorithm

In GA method, solution to the problem is represented as chromosome, and groups of chromosomes form population. Chromosomes are individually awarded with fitness and compared with the other in the population and the success rate is determined. To attain the better solution, genetic algorithm uses the genetic procedures such as crossover and mutation for generating new set of population. This process is achieved by combining two chromosomes or by changing the bits in chromosomes. Selection of parental chromosomes will be based on the fitness of the parents. By this type of selection, the child chromosomes will have the better characteristics of both parents. Initialization of chromosomes is done with the set of 20ā€“100 chromosomes. In this article, chromosomes are represented in binary. The performance of individual chromosomes is evaluated by a function called objective function. The objective function value for the corresponding chromosome is called as fitness value. The evaluation is based on fitness value and the strongest chromosomes are survived for the next iteration.

Here, each chromosome is having three parts as \(K_{p}\), \(K_{i}\), \(K_{d}\) with a length of 30 bit and 10 bit for each parameter.

Steps involved in development and implementation of GA.

  1. 1.

    Initialize the GA parameters.

  2. 2.

    Evaluate the chromosomes for best fitness.

  3. 3.

    Parents should be selected based on the fitness.

  4. 4.

    Reproduction is done by the roulette wheel method.

  5. 5.

    Crossover is introduced to the chromosomes after reproductions.

  6. 6.

    Mutation is done for the resulted chromosomes at lowest probability.

  7. 7.

    Iterate the process from step 2 to 6 until the performance criteria is met. The values of parameters used for the experimentation are given as, Population sizeĀ =Ā 20, Length of chromosomeĀ =Ā 30, Length \(K_{p} = 10\), Length of \(K_{i} = 10\), Length of \(K_{d} = 10\), Max. GenerationsĀ =Ā 50, \(0\, \le K_{p} \le 100\), \(0\, \le K_{i} \le 100\), \(0\, \le K_{d} \le 100 .\)

4.2 Objective Function Problem Formulation

Here, the objective function is framed to tune PID gains in such a way that it provides less peak over shoot, small rise time. Each chromosome is evolved, and chromosome having highest fitness considers to be the fittest chromosome. GA uses the fitness values of individuals to produce a new generation set of population comprising of the members with best fitness.

In the evaluation process, the chromosome is divided into 3 parts and it is used for tuning. The newly designed PID gains are placed in the LIP system with unity feedback. For faster evaluation, the Simulink model is designed in other file and is called during the process. The system is given with an impulse input and the error is estimated ITAE.

Integral of time multiplied by absolute error (ITAE)

$${\text{ITAE}} = \int\limits_{0}^{t} {t\left| {e\left( t \right)} \right|{\text{d}}t}$$

The ITAE evaluates the error with time and therefore minimizes the error values later on in the response.

5 Results

In this section, the simulations have been performed to evaluate the response of GA-tuned controller. Calculations are performed with 20 chromosomes. The tuned controller is characterized by minimum overshoot, less settling time, and rise time. The best response will then be chosen.

The parameters of GA are chosen as: probability of crossoverĀ =Ā 0.8, probability of mutationĀ =Ā 0.3, generationsĀ =Ā 50, crossover is single point crossover, and selection is roulette wheel selection. From the Fig.Ā 4, an impulse disturbance of 0.1 PID controller is giving a peak of 0.08, whereas GA-tuned controller is giving around 0.1. Settling time has drastic improvement in GA-tuned PID controller and it is around 0.15Ā s, whereas in traditional controller it is around 1Ā s.

Fig.Ā 4
figure 4

Comparison between proposed and conventional method for the population size of 20

Hardware plots are plotted without disturbance in pendulum angle and cart position because of complexity in providing same disturbance with same magnitude since the disturbance is given manually. The cases with disturbance are shown in the simulation results. Different sets of PID gains tuned by GA are verified on hardware, and the plots for both cart position and pendulum angle are plotted for all methods including conventional method. From the hardware response with the 2 types of PID tuning, conventional PID controller will make the pendulum oscillate around the 3.14, but ITAE-based gains provide less oscillations. The experimental setup is shown in Fig.Ā 5.

Fig.Ā 5
figure 5

Hardware implementation of inverter pendulum setup

The oscillation in the pendulum angle is because of the output collected from optical encoder. TableĀ 3 gives the details about the tuned parameters based on two methods (conventional and proposed method).

TableĀ 3 Comparison between PID tuning methods

6 Conclusion

From the experimentations, it can be conclude that GA-tuned PID controller will give the faster and good response compared to traditional PID controller tuning methods. These traditional methods will lead us to a starting value of PID controller gains but not the optimal one. Along with this, obtaining gain from classical techniques is more troublesome. It requires more steps, and sometimes trial-and-error procedure is to be followed for reaching the desired performance. With GA tuning, the sound knowledge about the system is not required. The tuning time also will be reduced with the help of GA tuning.