Tuning PID Controller Bases on Random Search Algorithms

DOI : 10.17577/IJERTV10IS010038

Download Full-Text PDF Cite this Publication

Text Only Version

Tuning PID Controller Bases on Random Search Algorithms

Dung Vuong Quoc*

Center of Information Technology Hanoi University of Industry Hanoi, Vietnam

Thuy Tran Thi

Center of Information Technology Hanoi university of Industry Hanoi, Vietnam

Loi Nguyen Tien

Center of Information Technology Hanoi university of Industry Hanoi, Vietnam

Nguyet Do Thi Minh

Center of Information Technology Hanoi University of Industry Hanoi, Vietnam

Minh Nguyen Quang

Center of Information Technology Hanoi university of Industry Hanoi, Vietnam

Binh Nguyen Thi Thanh

Center of Information Technology Hanoi university of Industry Hanoi, Vietnam

AbstractIn this paper, we present two well known random search algorithms which are Genetic algorithm (GA) and Particle Swarm optimization (PSO) to find optimal parameters for PID controller for a model of DC motor is used as a plant. To test performance of GA and PSO algorithms, we compare them with the traditional Ziegler-Nichols method in term of performance indices. The simulation results show that Proportional Integral and Derivative controller (PID) designed by GA and PSO algorithms yields better results than the traditional method in terms of the performance index.

KeywordsTuning PID; GA algorithm; PSO algorithm; Ziegler-Nichols method; performance index; optimization.


    Proportional Integral and Derivative (PID) controllers have been used in industrial control applications for a long time. This is due to its simplicity, low-cost design and robust performance in a wide range of operating conditions. According to a survey in 1998, nearly 90% of the controllers used in industries are PID controllers [1]. By adding a derivative term into Proportional Integral (PI) controller, it improves the stability of control loop. The combined effect of Proportional and Derivative (D) controllers introduces a predictive capability in the controller since D term is able to react to foreseeable future control errors. The proportional term works as a fast-acting correction which will produce a change in the output as quickly as the error arises. The integral action takes a period of finite time to act but has the capability to make the steady zero state error. Unfortunately, tuning the PID controllers is tedious and it might be difficult to tune the PID gains properly due to the nonlinearity and the high complexity of the system [2]. Therefore, beside traditional tuning method we need heuristic methods for tuning parameters of controller. Recently, random search algorithms are widely chosen to solve nonlinear optimization problems. The categories of these algorithms do not require differentiable and continuous objective functions. Some random search algorithms are used for tuning PID controller such as GA [3-4], PSO [2], CRO [8].

    In this paper, we use GA and PSO algorithm to find global optimization for parameters of PID controller and compare result with traditional Ziegler-Nichols tuning method with respect to integral performance indices.

    This paper is organized as follows: In the next section, PID controller is presented. Section 3 discusses GA and PSO algorithms. Next section presents the tuning PID controller. Section 5 demonstrates the performance of the various methods by experiment. Final section presents the conclusion and future studies.


    Proportional Integral Derivative (PID) controller is widely used in industry and practice. PID is often used in close loop control system presented in figure 1.

    Fig. 1. Block diagram of close loop control system with PID controller.

    PID controller combines three features of P, I and D controllers. P element instantaneously adjusts proportional control variable to the error signal. This is quite logical and it may be compared to the natural reaction of a process operator. The larger the error signal is, the larger the proportional control variable should be adjusted. One drawback of P term is any change in the operating conditions which will result into an offset, which is a steady state deviation of controlled variable from the set point. To overcome this drawback, the I term is added to form PI controller. Meanwhile, D term is added to PI controller to form PID because this element considers change rate of the error. Therefore, using the derivative element in

    controller allows the control variable to anticipate and counteract the cause of the error signal before it can take significant values. In PID controller, the control variable is related to the error signal by equation (1).

    particular and evolutionary algorithms in general simulate natural evolution through four basic operations: crossover, mutation, reproduction and natural selection.

    Genetic algorithms are often used to solve optimization

    () = × () + × () × +

    × ()


    problems and then the solution of the problem is represented by


    individuals, also known as chromosomes, sets of individuals is

    This expression often writes in other form.



    () = × (() + × () × () +

    called a population. A chromosome is made up of genes, the value of genes can be decimal numbers, binary numbers, symbols or letters depending on the problem to be solved. To




    ) =

    × (() + 1 × () × () +

    evaluate the individuals in a population, the genetic algorithm







    uses the fitness function, this value is to measure the suitability of each solution to the problem. Some individuals in the


    = is referred as the integral time constant or

    population are selected for crossover to create new offspring and these offspring will inherit part of the father's genes and

    reset time of controller. part of the mother's genes. Some individuals are selected to


    is derivative time constant.

    mutate, through mutation that changes their genes in one or more specific locations. The number of individuals to be

    The transfer function of PID controller can be written as

    flowing form:

    crossover and mutation was controlled by parameters of the crossover probability (pc) and the mutation probability (pm).

    () = () = + + × = × (1 + 1 +





    Individuals selected for the new population follow the Darwin

    × ) =

    × 1+×+××



    theory of evolution, those individuals with a larger fitness function value will have more chances of being selected into

    Where KP, KI, KD are proportional gain, integral gain and derivative gain respectively.

    By tuning three parameters in the PID controller algorithm, the controller can provide control action designed for specific process requirements. There are some traditional methods to determine KP, KI, KD such as Ziegler – Nichols, CHR modification of the Ziegler Nichols settings, Cohen-Coon controller settings, Lambda Tuning Technique, Haalman Controller Settings. In addition, there are some optimization methods widely used for tuning controller. In these methods, the controller parameters are determined with a view to the minimization of a given integral performance criteria such as integral of the absolute error (IAE), integral of the square error

    1. are listed below:

      the new population. Aftersome evolution we choose the individual with the largest fitness function value and it will be the best solution to the given problem to be solved.

      Thus, to solve the problem with genetic algorithms, we usually proceed through the following steps:

      • Step 1: Specify the parameters of algorithm which includes: population size, max iteration (generation), crossover probability and mutation probability.

      • Step 2: Create initial population.

      • Step 3: Repeat step 4 to 7 until stop criterion is satisfied.

      • Step 4: Calculate fitness value for each individual in population base on fitness function.

      • Step 5: Perform natural selection and crossover.

      • Step 6: Perform mutation.



        = 0 |()|

        = ()2

        = ()2





        = 0 |()|




        • Step 7: Create a new population.

        • Step 8: Select best individual which is the solution for given problem.

    B. Particle Swarm Optimization

    = ()2

    = ()2



    + (7)

    In case of PID controller, error signal e(t) is function of KP, KI, KD. We can choose one of integrals above as objective function for modern heuristic random search algorithms.


    A. Genetic Algorithm

    The genetic algorithm is formed based on the concept that natural evolution is the most perfect, the most logical and optimal process in itself. This concept is considered to be a true and unprovable axiom, but it is consistent with objective reality and was discovered by the scientist Darwin in his theory of evolution. The evolutionary process is optimally shown that the next generation is always more developed and perfect than the previous generation. Natural evolution is maintained by two natural processes of reproduction and selection. During natural evolution new individuals are born to supplement the old one.

    Particle swarm optimization was developed in 1995 by the authors Kennedy and Eberhart, inspired by the behavior of social organisms in groups, such as bird and fish schooling or ant colonies. This algorithm emulates the interaction between members to share information. Particle swarm optimization has been applied to numerous areas in optimization and in combination with other existing algorithms. This method performs the search of the optimal solution through agents, referred to as particles, whose trajectories are adjusted by a stochastic and a deterministic component. Each particle is influenced by its best achieved position and the group best position, but tends to move randomly. A particle is defined by its position vector, Pi, and its velocity vector, Vi. Every iteration, each particle changes its position according to the new velocity. To seek the optimal solution, each particle moves in the direction to its previously best (Pbest) position and the global best (Gbest) position in the swarm [9].

    Natural selection will retain more developed and

    environmentally adaptable individuals, and discard those less adapted to the environment. Thus, genetic algorithms in

    (, ) = min


    [( ()], {1, 2, , }

    () = min



    [( ())] (8)

    effective PID tuning method. Ziegler and Nathaniel Nichols proposed two methods for tuning PID controller. The first

    where i denotes particle index, Np is total number of particles, t is the current iteration number, f is the fitness function, P is the position. Velocity V and position P of the particles are updated by the following equations:

    ( + 1) = () + 11[ (, ) ()] +

    22[ (, ) ()] (9)

    ( + 1) = () + ( + 1) (10) where is the inertia weight used to balance the global exploration and local exploitation, 1 and 2 are uniformly distributed random variables within range [0, 1], and 1 and 2

    are positive constant parameters called acceleration coefficients.

    In summary, the PSO algorithm is illustrated with pseudo- code as follows:

    Step 1: Initialization

    • Choose constant parameters c1, c2, population size Np

    • FOR EACH ith particle in population DO

      method applies for process model type of first order system with transport lag. Which has step response likes figure 2 [6].

      Fig. 2. Step response of plant for first ZN method.

      From this response we can estimate delay time L, constant time T and state value K. Then KP, KI and KD of PID controller can be calculated by equations (11) – (16) following:

      • Initialize the particles position with a uniform random number in range of the lower bound (LB) and

        = 1.2 ×

        = 0.5 × = 0.6 ×



        upper bound (UB) of the search


        space. Pi(0)~U(LB,UB)

      • Initialize Pbest(i,0) = Pi(0)

      • Initialize Vi(0)~U(-|UB-LB|,|UB-

      LB|) END_FOR

    • Find Gbest(0) = min[Pbest(i,0)],


      Step 2: Iteration until stop criteria is met.

    • Create random number r1, r2 ~U(0,1)

      = 0.5 × × = 0.6 × (13)

      The second of NN method for tuning PID controller as

      flowing steps:

      Decrease integral and derivative gain to zero (disable integral and derivative effect)

      Increase proportional gain from zero to ultimate value Ku at which oscillations occur with period Tu.

      From estimated Ku and Tu, we can calculate parameters of PID controller as:

      = 0.6 × (14)

      = 2 × = 1.2 ×


    • Update the each particles velocity

      according to the formular (5).


      = = 0.6 ×

      = = 0.6 ×

    • Update the each particles position

      according to the formular (6).

    • IF f[Pi(t)]<f[Pbest(i,t) THEN Pbest(i,t) = Pi(t)


    • IF f[Pi(t)]<f[Gbest(t) THEN Gbest(t) = Pi(t)


    t = t + 1

    Step 3: OUTPUT Gbest(t)is optimal solution.


    In this article, we apply oldest traditional Ziegler Nichols (NN) method for tuning PID controller and our proposal method using GA and PSO algorithms for finding optimal parameters of PID controller so that minimum integral performance indices. NN method was proposed by John Ziegler and Nathaniel Nichols in 1942 and is still a simple and fairly

    8 8

    To apply PSO and GA for finding optimization of PID

    controller, we can choose one of integral performance index listed in (4) (7) as objective function. In our case we choose integral of time absolute error (ITAE) as objective function. We encode KP, KI and KD as chromosome in GA and position of particle (solution) in PSO and then we run PSO and GA algorithm to search global min of ITAE. When stopping criterion is satisfied, we obtain optimal parameters of PID controller.


    To test our proposal method, we consider model of DC motor is described by figure 3:

    Fig. 3. Diagram of the DC motor.

    And model can be expressed by system equation (17) below:



    × () + × () = × ()








    Traditional tuning method





    GA tuning method





    PSO tuning method





    { 2


    × () + × () = × ()

    Substitute () = () is angular velocity of the motor to

    system equations (17) we obtain:

    × () + × () = × ()


    × () + × () = × ()


    Fig. 5. Convergence of the GA algorithm.


    J is the moment of inertia of the rotor: 0.01 kg.N2 b is the motor viscous friction constant: 0.1 N.m.s Ke is the electromotive force constant: 0.01 V/rad/s Kt is the motor torque constant: 0.01 N.m/A

    R is the electric resistance: 1

    L is the electric inductance: 0.5 H K = Ke = Kt

    We perform Laplace transform two sides of system equation (19). Finally, we obtain transfer function of system as:

    () = () =




    We apply PID controller to the system so that get the best step response presented on figure 4.

    Fig. 4. Schema of the system with a PID controller.

    We use ZN method 2 and PSO, GA methods to specify KP, KI and KD of PID controller for the model and we obtain results are described in table 1. To compare performance of tradition and two random search methods, we use unit step change of rotor speed. Figures 5, 6 illustrate the convergence of GA and PSO algorithms. Figures 7 to 9 show unit step response of system with PID controller tuned by traditional and heuristic search methods.

    Fig. 6. Convergence of the PSO algorithm.

    Fig. 7. Step response of the system with ZN tuning method.

    Fig. 8. Step response of the system with GA tuning method.

    Fig. 9. Step response of the system with PSO tuning method.


In this paper, we present traditional rules and meta-heuristic random search algorithms PSO, GA for tuning PID controller. PSO and GA use the random search approach to find global optimal solution for given problem. To test performance of

applying PSO, GA for tuning PID controller, we perform simulation on DC motor model. The simulated results show that heuristic random search methods are better than traditional rules with respect to performance integral indices. In the future, we will study to solve multi-objective optimization problems using PSO and GA algorithm.


This work is supported by the Hanoi University of Industry.


  1. M. Araki, PID Control in Control systems, Robotics and Automation, vol II, edited by Heinz Unbehauen, Encyclopedia of Life Support Systems (EOLSS), Developed under the Auspices of the UNESCO, Eolss Publishers, Oxford ,UK.

  2. Qiao W, Venayagamoorthy GK, Harley RG (2006), Design of optimal PI controllers for doubly fed induction generators driven by wind turbines using particle swarm optimization. In: IEEE 2006 international joint conference on neural networks (IJCNN 06), Georgia Institute of Technology, Atlanta, pp. 19821987.

  3. Ioan Constantin Tarca, Komal Khuwaja D/O Shoukat Ali Khuwaja, PID Controller Tuning Optimization with Genetic Algorithms for a Quadcopter, Recent Innovations in Mechatronics (RIiM) Vol. 5. (2018).

  4. Ian Griffin, On-line PID Controller Tuning using Genetic Algorithms, Dublin City University, 2003.

  5. Allaoua B, Gasbaoui B, Mebarki B, Setting up PID DC Motor speed control alteration parameters using particle swarm optimization strategy, Leonardo Electron J Pract Technol 4:1932.

  6. Brian R Copeland, The Design of PID Controllers using Ziegler Nichols Tuning, March 2008.

  7. Fatiha Loucif, dc motor speed control using pid controller, ICCAS2005 June 2-5, KINTEX, Gyeonggi-Do, Korea.

  8. Cuong Nguyen Cong, Ricardo Rodriguez-Jorge, Nghien Nguyen Ba, Chuong Trinh Trong, Nghia Nguyen Anh, Design of Optimal PI Controllers using the Chemical Reaction Optimization Algorithm for Indirect Power Control of a DFIG model with MPPT, Web, Artificial Intelligence and Network Applications. WAINA 2020. Advances in Intelligent Systems and Computing, vol 1150. Springer, Cham. https://doi.org/10.1007/978-3-030-44038-1_114 .

  9. Zhang, S. Balochian, P. Agarwal, V. Bhatnagar, and O. J. Housheya, Artificial intelligence and its applications, Mathematical Problems in Engineering, vol. 2014, Article ID 840491,10 pages, 2014.

Leave a Reply