Firefly algorithm tuning of PID position control of DC motor using parameter estimator toolbox

ABSTRACT


INTRODUCTION
Nowadays, direct current (DC) motors are widely used in industries, and robotics due to there's excellent speed control characteristics, dependability, and affordability [1].The speed of a DC motor can be adjusted by changing the voltage at its terminals.However, position control is not possible.The precision position control of a DC motor is considered among the top important application control systems [2], [3].Therefore, the position controller of these motors is required to capture the target angle needed to achieve that position [4].Therefore, understanding the mathematical model of a DC motor is crucial for designing controllers and meeting performance requirements [5].However, obtaining precise electrical and mechanical parameters for control is very important [6].To find these parameters, parameter estimator may need to be performed, even if they are already documented in the user's manual.However, the system's ageing and wear and tear can cause these parameters to change over time, especially if the system has been in use for several years [7].To realize these parameters some tools are used such as backpropagation network [8], fuzzy techniques [9], least squares [10], and metaheuristic methods [11], [12].This study uses the MATLAB/Simulink parameter identification tool to find motor armature-winding resistance, inductance, Bulletin of Electr Eng & Inf ISSN: 2302-9285  Firefly algorithm tuning of PID position control of DC motor using … (Jafar Jallad) 917 back electrical motive force constant, moment of inertia, motor torque constant, and the viscous friction coefficient.This tool enables the estimation of nonlinear system dynamics by employing machine learning techniques, including gaussian processes (GP) and support vector machines (SVM), within hammersteinwiener and nonlinear ARX models.Thus, an accurate DC motor model will give matching in real-time response when a closed-loop control technique is applied.
A control loop system known as a PID controller is extensively utilized in industrial control systems.It incorporates feedback to minimize the disparity between a measured process variable and a specified set point.The PID controller calculates an appropriate action and applies it to enhance the process automatically.Incorporating the PID controller into the DC motor enables the rectification of any errors made by the motor, leading to the regulation of the motor's position to the desired angle.Hence, achieving the optimal values for the proportional constant (Kp), integral constant (Ki), and derivative constant (Kd) to fine-tune the PID controller is widely regarded as the primary challenge.Trial-error conventional control [24] is one of the methods that is often used for tuning the coefficient parameter of the PID controller.However, this method poses challenges in adjusting the parameters, leading to lengthy parameter search times, suboptimal parameter selection, and inadequate control accuracy.
Optimization plays a role, in the fields of mathematics and computer science.Its main objective is to find solutions to problems by minimizing or maximizing objective functions through different optimization variables.Researchers have been exploring the firefly algorithm (FA) within the sensor networks domain to tackle battery life challenges.This algorithm helps identify the cluster head offering solutions that can enhance energy consumption and overall lifespan [25].Moreover, studies focusing on linear antenna array designs have utilized optimization algorithms such as grasshopper optimization algorithms, ant lion optimization and hybrid approaches.These algorithms aim to achieve objectives, like reducing sidelobe radiation and controlling beamwidth [26], [27].
Various optimization techniques have been explored and evaluated in data clustering and forecasting.For instance, the harris hawk-SVM hybrid is introduced to enhance biomedical data analysis accuracy [28].In demand forecasting, FA-based gated recurrent unit model outperforms standard gated recurrent unit (GRU) and long short-term memory models (LSTM) in accuracy, especially for a concrete block manufacturing company in Iraq [29].The antlion optimization (ALO) algorithm proves highly efficient for estimating parameters in modified constructive cost models (COCOMO), surpassing other algorithms in various scenarios and datasets [30].For text clustering, the medoid grey wolf optimization (M-GWO) algorithm excels at handling outlier and noise data, showing superior performance compared to genetic, firefly, GWO, and k-means algorithms in achieving high-quality document clustering [31].Regarding the software project scheduling problem (SPSP), GWO is generally more effective than other algorithms, except for one instance where the FA performs better than GWO [32].
In image processing, a multi-objective optimized hybrid watermarking technique using wavelet transform and singular value decomposition is presented, demonstrating improved robustness, invisibility, and security in embedding watermarks [33].For face recognition, metaheuristic optimization algorithms like PSO and firefly optimization are employed to form feature vectors for face images, revealing the impact of selected features on performance [34].The mayfly optimization algorithm proves superior in image multilevel thresholding compared to other algorithms [35].In the field of mathematics, the shooting swarm algorithm based on PSO and FA is introduced to solve boundary value problems, yielding accurate results and significantly reducing required iterations for problem solutions [36].For PV system optimization, different algorithms are used to demonstrate quick and efficient maximum power point operation of PV system such as the hybrid FA-perturb and observe (P&O) algorithm [37], improved Seagull optimizer (SO) with modified variable step sizes perturb [38] and observe and evolutionary algorithms (genetic algorithm, FA, and fruit fly optimization) [39].Moreover, the optimization also aims to optimize power systems by improving efficiency, reducing power loss, enhancing the stability index, controlling power flow and supporting voltage stability.They use different optimization approaches such as particle swarm optimization (PSO), FA, and backtracking search algorithm (BSA) to solve complex problems related to power systems optimization [40]- [44].Hybrid optimization techniques are also explored, combining FA and ACO to solve multi-depot multiple travelling salesman problems, achieving faster convergence and superior performance in optimizing sea transportation routes [45].A hybrid method for solving non-smooth cost function economic dispatch problems combines incremental cost rates and bee colony optimization, providing higher quality solutions compared to other algorithms [46].
Optimization techniques offer several compelling advantages over fuzzy logic and neural networks.One key benefit is their explicit solution for PID coefficient values, ensuring they meet the defined optimization criteria.In contrast, fuzzy logic and neural networks often offer implicit, black-box solutions, which can obscure the reasons behind the selected coefficients, making it harder to interpret and analyze the control system.Another advantage of optimization technique is their reduced data-intensive nature compared to neural networks.Optimization methods require less data for training and parameter tuning, in contrast to neural networks that rely on large datasets for effective generalization.This makes optimization techniques more suitable for situations where data collection might be limited or costly.Furthermore, optimization techniques excel in not requiring expert knowledge for rule-based design, which is a common requirement in fuzzy logic systems.By eliminating the need for explicit prior knowledge of the system, optimization techniques become more accessible and easier to implement in various applications.This accessibility enables users without specialized expertise in rule-based systems to effectively utilize optimization methods to address control or decision-making challenges, widening the scope of potential applications.
Optimization techniques can be employed to optimize the coefficient parameter of the PID controller.Darmansyah and Robandi [47] propose an intelligent voltage controller for the DC-DC boost converter in a PV power plant using the FA algorithm to optimize the PI controller, providing better control performance under uncertainties in PV output.In the context of PV module tracking, the authors in [48] explore the use of different optimization algorithms to optimize PID controllers in a sun tracking system.Experimental results indicate that PID-BA achieves the best performance in terms of settling time and overshooting.Therefore, numerous intelligent techniques have been employed by researchers to fine-tune the PID parameters.These include the genetic algorithm [49], teaching learning based optimization [50], artificial bee colony algorithm [51], [52], and GWO [53].
As one of the intelligent methods, the FA will be employed in this study to optimize the PID parameters of a DC motor.The FA possesses a myriad of advantages that make it a compelling choice for optimization tasks.Firstly, FA excels in global optimization, making it highly effective in searching for the best solution across a wide search space, while adeptly avoiding local optima and pursuing superior global solutions.Additionally, FA's simplicity renders it easily understandable and implementable, making it accessible to a diverse user base without the need for extensive optimization or mathematical expertise.Its reduced number of control parameters further streamlines the tuning process and mitigates the risks associated with parameter sensitivity.The algorithm's robustness shines through, as it maintains consistent performance even amidst noise or uncertainty in the objective function, adeptly navigating noisy fitness landscapes to converge to satisfactory solutions.Moreover, FA's capability to handle optimization problems without requiring constraints proves advantageous for addressing complex constraints or those that are challenging to define mathematically.Furthermore, the algorithm operates without imposing specific assumptions about the problem or objective function, thus applying to a broad spectrum of optimization scenarios without necessitating problem-specific customization.Inspired by natural phenomena, FA's biological roots bestow it with unique exploration and exploitation characteristics, fostering innovative solutions and invaluable insights in the optimization process.
Previous studies proposed various control methods for DC motors, but some of their evaluation was limited to simulation systems [54], [55].Consequently, the need for further validation remains crucial to ascertain the efficacy of these methods in real-time applications.Nevertheless, the present study extended its evaluation beyond simulations by implementing the proposed control method on physical hardware, offering additional substantiation of its performance in practical environments.In contrast, the other studies focused solely on utilizing a particular controller to find the optimal angular position in real time [56], [57].However, in industrial applications, the controller serves multiple functions, including determining the desired angular position by incorporating the programmed PID coefficients' values.The utilized controller allows for the manipulation of the PID coefficients' values but often does not include any built-in optimization techniques within its programming.
The proposed approach intends to readjust the PID controller for the angular position of the DC motor at the worksite.This scenario arises from the fact that the parameters of the DC motors may undergo alterations during prolonged periods of operation.Furthermore, to address the challenge of fine-tuning the PID coefficients on-site without employing any optimization techniques on the current controller.Using MATLAB/Simulink, it is possible to estimate the DC motor parameters and then determine optimized PID coefficients by using the FA in an offline (simulation).After that, the optimized values of PID coefficients are applied to the currently connected controller to the real DC motor.
This study discusses the position control of DC motor response of input positions in real time.The PID controller is used to achieve a desired position without overshooting and less settling time.The real DC motor parameters are estimated by parameter estimator toolbox in MATLAB to find the optimized PID coefficients using the FA.These values were validated using the step input signal to investigate the performance of the angular position controller for the DC motor in real time.The estimation technique that is used in this paper is the MATLAB parameter estimator toolbox.This toolbox provides various tools for estimating the DC motor parameters based on input and output data that has been measured.The graphical user interface (GUI) of the MATLAB parameter estimator toolbox is depicted in Figure 3, and it is useful for organizing models and data.The technique involves a series of steps such as importing the data columns X and Y into the MATLAB workspace, importing the data columns into the parameter estimator toolbox processing and plotting data for estimation, the armature resistance (R), armature inductance (L), the rotor moment of inertia (J), viscous friction (b), and motor torque constant (K).To determine the parameters of a DC motor, it is necessary to apply a step input voltage and measure the resulting speed response using a sensor such as a tacho generator, which converts the speed to voltage.The measured speed values are recorded and saved in two columns X and Y, representing the input and output data, respectively.This data is then processed using system identification techniques to obtain the actual motor parameters.The block diagram presented in Figure 3 depicts the experimental arrangement utilized to evaluate the open-loop behaviour of the DC motor in response to step inputs.This data will be employed for identifying and estimating the parameters of the DC motor.The equipment employed for this experiment comprises the DC motor, tacho-generator and Arduino Mega 2560.The power supply delivers to the motor and control system, respectively.The DC motor and tacho-generator unit are mounted on a shared shaft.By providing an analog input signal to the motor circuit, it is possible to achieve variable shaft rotation speed.The tacho-generator unit output supplies an analog voltage signal proportional to the speed.For the acquisition of analog signals into a computer, an Arduino Mega 2560 was utilized.The Arduino Mega 2560 was linked to the computer via a USB port, drawing power (5 V) from the USB port of the computer.The signal information was transmitted serially to the computer via the USB port.A Simulink was developed to gather the signals from the USB acquisition device.The Simulink program is employed to gather the data sets as illustrated in Figure 4.  Once the experiment was arranged, a step input was applied to the DC motor, and a set of speed measurements were conducted to record the output speed response.Figure 5 displays the voltage step input and output speed response of the motor.The recorded data for input and output has been saved in two columns labelled X and Y respectively.These data columns will be utilized later for processing using system identification techniques.For estimating the DC motor parameters', the MATLAB parameter estimator toolbox is used as shown in Figure 6.
The DC motor parameters are estimated through this method.The optimization technique employed is simplex search because it is simple and robust, with a maximum of 300 iterations, and the cost function used is the sum of squared errors.
After the parameters have been identified, the subsequent stage involves creating the Simulink software using MATLAB.This software facilitates the observation of the response to the data gathered on the previously established DC motor modelling block with a PID controller.By using Simulink, the coefficient parameters of the PID controller are determined to reach the desired angular position of the DC motor without overshooting.The methods of determining the coefficient parameters of the PID controller will be discussed in the next section.

The control method
A PID controller is a widely used control mechanism in industrial systems that uses a feedback loop to continuously calculate the difference (error) between a desired set point and a measured process variable.The controller aims to reduce the difference value by adjusting the process control inputs.Therefore, the implemented PID controller could manage to drive the motor to the preset position at the lowest possible error.The general form of the output PID controller is shown in (1): Figure 7 shows the block diagram of the PID controller design for this control system.The control signal is determined the by PID equation in (1) to drive the DC motor to achieve a minimum error between a desired angle and an actual angle.In Figure 8, the PWM signal for the DC motor is denoted as u(t), while the actual angle is represented as y(t).The PWM signal execution programming code is calculated through the steps in Figure 8.
Based on the previous code in Figure 8, The proportional gain (Kp) in the code evaluates the error magnitude and reacts proportionally.Large errors result in large responses in motor position.The Ki aims to minimize steady-state error, while the Kd evaluates the error signal's rate of change to reduce overshoot and produce a more responsive system response curve for rapid error changes.The controller calculates the PWM signal based on the DC motor's signal variations, using PID gain values to enhance system performance.Figure 9 shows the flow chart of the PID controller for the angular position of the DC motor.  1 demonstrates the distinct impact of adjusting the parameter value in PID control independently.Specifically, if Ki and Kd remain unchanged, raising Kp alone has the potential to reduce rise time, elevate overshoot, cause a minor increase in settling time, and lower steady-state error.According to Table 1, it could be tuned PID controller parameters' using the trial-and-error method.Firefly algorithm tuning of PID position control of DC motor using … (Jafar Jallad) 923

Firefly algorithm
The FA is a recent optimization technique that draws inspiration from nature, specifically the behaviour of fireflies.Developed in 2007 by Yang, the algorithm mimics the flashing light signals used by fireflies to attract one another.The relationship between the light intensity attraction (I) and distance (r) of fireflies is inverse, so they are visible only within a limited range.The fitness function in FA is modelled after the fluorescence light behaviour of fireflies, with the brightness (I) of a firefly representing its fitness.The main concept behind FA is based on the flashing characteristics of fireflies, with the brightness (I) proportional to the fitness for maximization problems.So, the Ir varies according to the well-known inverse square law as shown in (2): where IS is the intensity at the source r.The brightness (I) of a firefly affects its attraction (β), with an increase in brightness leading to an increase in attraction and vice versa.The attraction of fireflies is directly proportional to their brightness.Fireflies' attractiveness, β, can be defined as: The attraction (β) of fireflies is determined by the parameters β0, γ, and the distance (r) between two fireflies (fy and fz).β0 represents the attraction at a distance of 0, γ is the coefficient for light absorption, and r is the distance between fireflies y and z.The Cartesian distance between two points can be calculated using (4): The movement of fireflies is based on the attraction between two fireflies, y and z, where the kth component f(y,k) and f(z,k) of their spatial coordinates are used in the calculation.The dimensionality of problem (d) also plays a role in determining the movement.The new firefly (y,k) is attracted to the previous firefly (z,k).
, +1 =  ,  +  0  −  2 ( ,  −  ,  ) + ( − 0.5) The second term is due to attraction and the third term, controlled by the randomization factor α, adds a random element to the firefly's path.The value of rand is a random number between 0 and 1.The objective value of each PID parameter (fireflies) is assessed and the optimal fitness function is saved.The fireflies are then modified based on attraction and new ones are generated.If a better fitness function is discovered, the PID parameters are updated.This repeats until the maximum number of iterations is reached.Figure 10 shows the design of the PID controller using the FA.The absolute value of the error between the actual and desired position value is the objective function which is used in this study.Figure 11 shows the flowchart of the proposed FA-based PID controller.

RESULTS AND DISCUSSION
The experimental setup was employed to evaluate the open-loop behavior of the DC motor when subjected to step inputs.The resulting data was utilized to identify and estimate the parameters of the DC motor.The equipment used for the experiment included the DC motor, rotary position sensor, and Arduino Mega 2560.The motor and control system were powered by a +12 V voltage.The DC motor and position sensor was mounted on a shared shaft, allowing for variable shaft rotation position by providing an analog input signal within the range of 0 to +10 V.The rotary position sensor provided an analog voltage signal proportional to the angle within the range of 0 to +5 V.An Arduino Mega 2560 was used to acquire the analog signals into a computer via USB, and the data was transmitted serially.A Simulink was developed to gather the signals from the USB acquisition device.The block diagram of the experimental connection of the angular position control for the DC motor is illustrated in Figure 12. Figure 13 shows the actual connections with Arduino_Mega_2560 which is used for receiving data from the angular position sensor to MATLAB/Simulink via Arduino blocks.The serial monitor displays the actual value of the angular position.The MATLAB parameter estimator toolbox was used to estimate the parameters of the DC motor.The estimated DC motor parameters obtained using the simplex search optimization technique with a maximum of 300 iterations and the sum of squared errors as the cost function are presented in Table 2.After setting up the experiment, a 90o-angle step input was applied to the DC motor, and a set of position measurements were taken to record the output position response.The trial-and-error method for PID tuning involves iteratively adjusting the proportional, integral, and derivative gain parameters of a PID controller until satisfactory performance is achieved.This method involves manually adjusting the parameters, running simulations or experiments, and then analyzing the results to determine if the performance meets the desired criteria based on Table 1.The process is repeated many times to find the result of the step response from 0° to 90°.The trial-and-error method is simple to implement but can be time- consuming and may not always result in optimal PID tuning.On the other hand, the genetic algorithm (GA) which was used in [58] to find the PID coefficients is also implemented in this study to compare with a proposed method based on PID-FA.
Figure 15 shows a comparative step response for PID based on trial and error, PID based on the FA algorithm and GA-based PID controller system in real-time.The system's response to PID based on the trial-and-error method has a prolonged settling time and high overshoot values.Therefore, efforts are made to enhance the dc motor's response through a PID-based FA and GA controller.The system response based on the FA algorithm is highly improved compared to the GA-based PID controller.Figure 16 shows the conversion curve for FA ad GA algorithms.This curve represents the relegation between the cost function (absolute value between the desired ad actual angle) and the number of iterations.It can be noticed the FA reaches to minimum cost faster than GA as well as the FA finds the global optimum solution.Table 4 presents a comparison of performance response for the DC motor angular position.The proposed method has less rising time, settling time, and overshoot compared with the other methods.In future work, this proposed method can be applied to motors in industrial automation applications such as arm robots or conveyor belt motors to control position and speed in order to help in tuning PID parameters in an easy and efficient way.

CONCLUSION
In this work, a microcontroller-based DC motor control system design is demonstrated to change the angular position of the DC motor.A PID gain tuning method based on trial and error ad PID-GA is used for reducing the oscillation according to the observed system response.On the other hand, the system is controlled by a PID with an FA algorithm which was found to be satisfactorily operated.The system with FA was found to be free from overshoot and oscillation.In addition, it has a minimal steady-state error.Results validate the effectiveness of the proposed angular position control system of the DC motor.The proposed controller could be applied to the robot arm taking into consideration the load and robustness to achieve the system's optimal performance and stability.

1 .
Bulletin of Electr Eng & InfISSN: 2302-9285 Firefly algorithm tuning of PID position control of DC motor using … (Jafar Jallad) Estimated DC motor parameters Figure1depicts the electrical and mechanical components of a DC motor.The electrical component is represented by an equivalent circuit comprising of the armature resistance Ra, armature inductance (La), and back electromotive force (EMF).On the other hand, the mechanical component includes the motor's developed torque (Tm), rotor moment of inertia (J), viscous friction (b), and load torque (T).

Figure 1 .
Figure 1.The schematic of the DC motor

Figure 2 .
Figure 2. Modelled DC motor in Simulink

Figure 3 .
Figure 3. Block diagram of experimental collection data

Figure 5 .Figure 6 .
Figure 5. Data collected from the experiment

Figure 15 .
Figure 15.Comparison of position response for DC motor based on FA, GA and trial and error in real-time

Figure 16 .
Figure 16.cost function versus iteration plot

Table 1 .
The effects of PID controller parameter

Table 2 .
The estimated DC motor parameters

Table 4 .
Comparison of results of PID based on trial and error and PID based on FA algorithm in real time