Comparison between butterfly optimization algorithm and particle swarm optimization for tuning cascade PID control system of PMDC motor

Received Jan 21, 2021 Revised Apr 3, 2021 Accepted Apr 11, 2021 In this paper, two optimization methods are used to adjust the gain values for the cascade PID controller. These algorithms are the butterfly optimization algorithm (BOA), which is a modern method based on tracking the movement of butterflies to the scent of a fragrance to reach the best position and the second method is particle swarm optimization (PSO). The PID controllers in this system are used to control the position, velocity, and current of a permanent magnet DC motor (PMDC) with an accurate tracking trajectory to reach the desired position. The simulation results using the MATLAB environment showed that the butterfly optimization algorithm is better than the particle swarming optimization (PSO) in terms of performance and overshoot or any deviation in tracking the path to reach the desired position. While an overshoot of 2.557% was observed when using the PSO algorithm, and a position deviation of 7.82 degrees was observed from the reference position.


INTRODUCTION
A permanent magnet DC motor (PMDC) is a simple structure type of DC motor in which the field windings have been replaced by permanent magnets and have many applications so It operates as the same basic principle as a shunt connected motor but the difference is that the permanent magnet generates the required flux instead of field windings [1], [2].
Permanent magnet DC motors provide less output power than DC shunt motor because the flux generated from permanent magnets is less than what can be achieved with field windings so most types of small DC motors are permanent magnet DC motors and these motors usually operate at high velocity and little torque [1], [3]. This motor has many applications such as its use in car front wipers and moving windows for cars and household appliances such as food mixers and others [4], [5] .in addition to the importance of using it in CNC machines, robotics, and electric vehicles [6], [7].
The main problem statement in this paper is how to get the best parameter values for cascade PID controller which gives the best accurate results for tracking trajectory the reference position and reaching the desired position at a regular velocity. To address this problem statement, a comparison was made between the BOA and PSO methods for extracting the parameters of the cascade PID controller, in addition to using one of the performance criteria which is integral time absolute error (ITAE) to reduce the error between input and output for this system. The cascade PID controller which is used in this paper consists of three controllers, the current controller is designed as an inner loop, and both position and velocity are outer controllers [8]. P, PI, and PI controllers are used instead of a PID controller for position, velocity, and current respectively [9].
The purpose of using the cascade control unit is due to several reasons, the most important of which is to reduce or reject disturbance and return to the steady-state [10]- [12]. There are several methods to tuning the parameters of PID and use it in PMDC motor such as Ziegler-Nichols Method (Z-N), Cohen-Coon method, artificial neural, network fuzzy logic [13], [14], particle swarm optimization (PSO) [15], [16], genetic algorithm [17], and butterfly optimization algorithm (BOA) [18].
To compare this work with similar works, a literature review was made. In 2014 Md Mustafa et al introduced a BLDC speed control system using GA [19]. In 2015, Taha et. al. used three methods to control the cascade control system [9]. In 2018, Wisam et. al. introduced a system for controlling PMDC velocity using the GA and DS methods [20]. in 2019, Fadhil et. al. used a fractional PID controller to control PMDC speed based on PSO [21]. In 2021, Ahmed et al introduced a system to control the speed and position of the servo motor [22]. This paper is organized as follows: In the second section, the mathematical model of the PMDC motor is represented and explain the general structure of the system, in the third section, the two tuning methods are explained which are PSO and BOA in addition to the use of ITAE. The fourth section includes the results and comparison, while the final section includes a conclusion.

MATHEMATICAL MODEL OF PMDC MOTOR AND GENERAL STRUCTURE 2.1. Mathematical Model of PMDC Motor
The equivalent circuit for a PMDC motor shown in Figure 1 consists of an armature circuit consisting of inductance (L a ) and resistance (R a ) connected on series. An electromotive force (E a ) is generated as a result of cutting the lines of flux generated by the permanent magnet, and it has a direction opposite to the direction of the source voltage. The mechanical part consists of moment inertia (J m ) and friction coefficient (B m ). The other parameters are torque constant (K t ) and back emf constant (K v ). The block diagram of PMDC motor with the position output showed in Figure 2.  (1) to (4) [23].
By using Laplace transformation for the (1) to (4) we obtain.
V a (s) = E a (s) + R a I a (s) + SL a I a (s) T m (s) = K t I a (s) The overall transfer functions are defined for velocity and position control of the PMDC motor, respectively.
Where k e equal to K t [24]. Table 1 lists the main components and their values of PMDC motor Parameters.  Figure 3 represents the general structure of the system, which consists of three controllers for current, velocity, and position. The output from the position controller represents the reference velocity, the output from the velocity controller represents the reference current, while the output from the current controller represents the control voltage (vc) and it is compared with a triangular waveform signal that is generated internally in the PWM circuit, producing a KPWM gain that simply represents the PWM controller and the dc-dc switching mode converter (i.e. H bridge). KPWM can be represented by the following equation in Laplace transform after making linearized of the dc-dc converter [24].

General structure of system
One of the benefits of the cascade control system, in addition to the benefits mentioned previously, is the ability to put limits on the reference signals for the system in order to protect the PMDC motor and the power electronic converter. In this paper, limits were placed on the velocity reference by an amount that does not exceed the rated motor velocity, as well as limit, was placed on the reference voltage coming out of the PI 739 current by 5v, which represents the control voltage (vc) and is compared with a triangular voltage as explained [24].

TUNING METHOD 3.1. Particle swarm optimization (PSO)
Particle swarm algorithm (PSO) is proposed by Kennedy and Eberhart and it was modified to improve its performance by adding a new parameter called inertia weight [25]. It which bases on a swarm base for using an observation of social behavior of moving organisms Such as a gathering of fish or a flock of birds.
The algorithm is related to the computational method that optimizes the problem Where flocks of birds aim to find eating behaviors and it uses repeated steps to reach the best solutions. This means that the candidate solutions are particles that move in the search space based on a specific formula above the particle position. Each particle's movement is affected by its local value, and its objective is to reach the best-known positions in the search-space by updating better positions found by other particles.
The algorithm is begun by establishing the starting position and velocity vectors. And each iteration is tried to find the best value by evaluating position and velocity vectors. Every particle has variables and dimensions, and these variables are problems that need to be solved. If the problem consists of five different variables, the particles' dimension should be chosen as five. This algorithm depends mainly on finding the position of each particle with the best local value, as well as finding the best general swarm position in each iteration. The position and speed are updated at each iteration based on (12) and (13) , ( + 1) = , ( + 1) + , ( ) Where, i=particle index, t=iteration, V (i,j) (t+1)=velocity updated or new velocity, j=dimesion number, W=weighted inertia its value between [0-1], V (i,j) (t)=Current velocity, r 1 , r (2) Figure 4 and Table 2 represents the parameters of the PSO that were used in this work. Figure 5 shows the flowchart of the particle swarm optimization algorithm.

Butterfly optimization algorithm (BOA)
In this paper, a new metaheuristic algorithm inspired by nature called the Butterfly Improvement Algorithm (BOA for short) has been proposed. This algorithm adopts the strategy of searching for food or mating between butterflies from a biological point of view. Butterflies use sense receptors to find the source of food by sensing the scent of the fragrance (nectar) [18], [28].
These receptors are spread over the body parts of the butterfly, such as the antennae and the legs, and they are nerve cells that are found on the surface of the butterfly's body and are called chemical receptors. The butterfly generates a scent of different intensity according to its fitness, meaning that when the butterfly moves or moves from one place to another, the fragrance spreads across these distances, and other butterflies can sense it, and this is the method of communication between butterflies [18], [28].
The entire concept of sensing and odor processing is based on three important terms, a) the sensory modality, denoted by the symbol c, and its value between [0-1], b) stimulus intensity, symbolized by the symbol I, and c) the size of the stimulus or force on which the butterfly depends. It is known as power exponent and It is denoted by the symbol a and its value is between [0-1].
The natural phenomenon of butterflies is based on two important issues, which are the formulation of the fragrance function and the variation in the intensity of the fragrance. The fragrance function can be formulated as a function of physical density and according to (14).
where f is the perceived magnitude of the fragrance, i.e., how stronger the fragrance is perceived by other butterflies. c, I and a are explained by (14). When the butterfly can sense the smell emanating from another butterfly, it will move towards it, and this stage is known as the global search and can be represented by (15), and when the butterfly is unable to sense the smell emanating from any other butterfly, it will move randomly and this stage is called the local search and It can be represented by (16).
Comparison between butterfly optimization algorithm and particle swarm … (Kareem G. Abdulhussein)

741
Where, X i (t+1) =new solution vector, X i t =solution vector, r=rondom number (n) between [0,1], g=current best solution, t=iteration number, i=butterfly, X j t and X k t are jth and kth butterflies from the solution space, and f i =the perceived magnitude of the fragrance. The butterflies' search for food or mating can occur on both local and global searches. The butterfly can switch between local search and global search, meaning that it has the decision to move towards the best butterfly or move randomly. The mode to switch between local and global search is called a switch Probability and denoted by the symbol ρ. Table 3 represents the parameters of the BOA that were used in this work.
The butterfly optimization algorithm can be represented in the approximate flowchart shown in Figure 6. The design of any complex system requires the selection of certain criteria that give the best performance. These functions are known as performance indices. In this paper, ITAE was used and it can be represented by (17).

RESULTS AND COMPARISON
Simulation was performed on the system using both the BOA and PSO methods. The system was tested in cases of loading and non-loading, as well as in the case of a single input or multiple inputs to ensure that the PMDC motor rotates a full rotation, 360 degrees or a half rotation. Table 4 represents the cascade PID parameters extracted by both the BOA and PSO methods, while Table 5 represents the performance parameter values obtained from these two methods.
For the purpose of comparison between BOA and PSO: a. An overshoot was observed when using the PSO method and its value was 2.557%. This indicates a deviation of the position of 7.82 degrees from the reference position while no deviation of the position occurred when using the BOA method see Figure 7(a). b. An overshoot and velocity deviation of about 18rad/sec were observed when using the PSO, while no velocity deviation occurred when using the BOA method see Figure 8(a). c. When applying full load (17.6N.m) on the system at the fifth second, it was noticed that the system was not affected when using both methods, or was affected imperceptibly, and this indicates the durability of the cascade controller in rejecting the disturbance see Figure 7(b) and Figure 8    The simulation results showed that there was no position deviation or overshoot in velocity or position when using the parameters extracted by the BOA in addition to accurate tracking of the path. On the other hand, when using the PSO, a position deviation of 7.82 degrees and an overshoot of 2.557% were observed, in addition to an overshoot in the velocity. The simulation results and the comparison mentioned above showed that the BOA algorithm gave better results than the PSO algorithm.

CONCLUSION
In this paper, two optimization algorithms are used to extract the PID gains for the cascade controller of a PMDC motor. These algorithms are PSO and BOA. The simulation results in the case of using PSO showed a clear deviation of the position from the reference position about 7.82 degrees, in addition, an overshoot of 2.557%. On the other hand, no position deviation or overshoot occurred when using the BOA algorithm. Also, there is no overshoot in the velocity when using the BOA algorithm, which led to an accurate tracking of the path. As a result, the BOA algorithm is better than the PSO algorithm.