Genetic Algorithm-Based Parametrization of a PI Controller for DC Motor Control

This paper analyses the application of a genetic algorithm (GA) for the purpose of designing the control system with separately excited DC motor controlled according to the rotor angle. The presented research is based on the utilization of a mathematical model designed with separate electrical and mechanical sub-systems. Such an approach allows fine-tuning of PID controllers by using an evolutionary procedure, mainly GA. For purpose of PID tuning, the new fitness function which combines several step response parameters with the aim of forming a unique surface which is then minimized with a genetic algorithm. From the results, it can be seen that the elitism-based algorithm achieved better results compared to the eligibility-based selection. Such an algorithm achieved a fitness value of 0.999982 resulting in a steady-state error of 0.000584 rad. The obtained results indicate the possibility of applying a GA in the parameterization of the PID controller for DC motor control.


INTRODUCTION
Automatic control represents one of the key elements of modern society. Feedback regulation represents a standard procedure in automatic control [1,2]. Such a configuration is characterized by controller utilization [3]. In most practical applications, a simple PID controller represents an optimal solution [4]. PID controller parametrization, alongside mathematical modelling, represents one of the key challenges in the design of an automatic control system [5]. The classical approach used for PID parametrization and tuning is based on experimental design and mathematical modelling [6]. Such an approach requires expertise in the field of automatic control and electric drives [7]. In addition, such an approach can be time-consuming and error-prone [8].
Another approach to PID parametrization is the utilization of evolutionary algorithms, mainly GA. Evolutionary computation, alongside artificial intelligence (AI) and machine learning (ML) represents one of the most propulsive fields of science and technology with application in various fields ranging from propulsion systems [9,10], through medicine [11][12][13] to satellite surveillance [14].
GA represents a meta-heuristic algorithm that is based on Darwin evolution theory [15]. This algorithm has a long history of utilization in various fields of science and engineering, ranging from robotics [16], through modelling of energy systems [17] to maritime affairs [18]. Such an approach can offer a simpler and more effective method for PID parametrization.
Following the presented facts, the aim of this paper is to present a GA-based method for PID controller parametrization that will be used for parametrization of 3 PI controllers used in the control of separately excited DC motor according to the rotor angle. Controllers will be parametrized by using different variations of GA. Results achieved with each of these GA methodologies will be used in the evaluation of, not only GA but also the PID regulation itself.

DESCRIPTION OF THE CONTROL SYSTEM
The mechanical sub-system defines the rotor angle in dependency of motor and load torques. The rotor angle can be defined by the angular speed of the rotor as its integral. By using presented formalism, the mechanical relation can be defined as [19]: where J u represents the total moment of inertia defined as a sum of motor and load inertia, M t represents a load torque including friction, and M m represents the shaft torque. Shaft torque can be defined as [20]: where k m represents the motor constant, ψ ex represents the flux linkage and i a represents the armature current. For motor operation at rated values, flux linkage can be defined as a constant [21]. For this reason, Eq. (2) can be rewritten as a linear equation, yielding [22]: Such a mathematical model can be represented with its block scheme used for simulation in Simulink, presented in Fig. 1. It must be noticed that such a model is constructed by using the absolute value of rotor angular speed. This property is introduced in order to annul the influence of rotation direction (clockwise or counterclockwise) on the control system and its mathematical behavior.
The differential equation that describes the behavior of the electrical subsystem of a DC motor can be defined as: where U a represents armature voltage, L a represents armature inductance, R a represents armature resistance and e represents an induced voltage. Such a voltage can be defined with [21]: where ψ uz represents the excitation flux linkage. It should be noted that, as it is in the case of armature flux linkage, in this case, voltage equation can be derived to linear, yielding: It should be noticed that the constant K is the same constant as it is in the case of Eq. (3).
As it is in the case of the mechanical sub-system, the electrical sub-system is also designed and simulated in Simulink. A block-diagram used for the simulation of the mechanical sub-system is presented in Fig. 2. The control system used in the control of DC motor rotor angle is based on three control loops: • loop for armature current control, • loop for rotational speed control and • loop for rotor angle control.
Each of the aforementioned control loops must be designed by using a separate controller. In the case of motor control, due to the derivative nature of its behavior, it is necessary to include only proportional and integrational components of the PID controller (PI controller). The output value of such PI controller can be defined as: where K p represents the proportional coefficient and K i represents the integrational coefficient of a PI controller. The whole system for DC motor control composed of mechanical sub-system, electrical sub-system and PI controllers is presented in Fig. 3. This block diagram is used for simulation of the control system in Simulink. For purposes of this research, the control system was simulated and parametrized in Simulink and by using custom Python program. In both cases, DC motor model is designed by following the above presented mathematical formalism and by using parameters presented in Tab. 1.

DESCRIPTION OF GA USED FOR PID PARAMETRIZATION
In this chapter of the article, a brief description of used GA will be presented. The description will include a description of population initialization, variation procedures, and fitness determination. All three parts will be enriched with block diagrams.
The goal of each GA is to generate generations of quality individuals from a set of randomly generated solutions [23]. New generations are generated from selected individuals on which variation procedures are performed. Solution quality is determined by using the fitness function [24].

Population Initialization
The initial phase of the genetic algorithm is population initialization. Depending on the default size population, the genetic algorithm generates a series of solutions with random parameters. At this stage, it is possible to use heuristic methods of creating solutions to obtain a better initial population. The flowchart of the population initialization procedure is presented in Fig. 4. Population created by the heuristic method will have a higher average of the suitability ratings of the individuals than the one created randomly, but there is a risk of premature convergence of the algorithm, less diversity of results due to favoring certain individuals from the beginning of the algorithm execution. TECHNICAL JOURNAL 16, 1(2022), 16-22

Variation Procedures
Population initialization is followed by the application of selection, recombination, and mutation to create new generations of the initial population. Each new individual is assigned an appropriate fitness score, and depending on the stopping conditions, the mean fitness score of the population is calculated. If the new generation meets the stop conditions, the algorithm lists it as the optimal solution and stops it. Additional checks on solutions can determine whether the set of algorithm solutions is of appropriate quality. The low quality can be ascribed to premature convergence of the algorithm or a poorly defined fitness function. The flowchart of the genetic algorithm is shown in Fig. 5.

Fitness Function Definition
In this paper, as a quality measure of the DC motor control system, step response quality indicators such as: • Rise time, • Peak time, • Settling time, • Overshoot and • Steady-state error will be used during the definition of the fitness function. The goal of the GA is to minimize all above-presented indicators.
Such an approach will result in a step response that closely follows the reference signal. The fitness function used in this research is designed to reduce several goals to only one goal. This approach is achieved by defining the area between the reference value and step response signal. In this way, a minimization of above-presented quality indicators is achieved. An example of such an area is presented in Fig. 6. Depending on the fitness function and the system model used for the determination fitness of the individual, the algorithm needs to be optimized to minimize run time without affecting its functionality. The chromosome save function returns the parameters of an individual to a string record, and the fitness function uses this record to compare the genetic code of an individual with an already calculated fitness. The calculated fitness values are stored in a variable.
In this case, the keys are variable correspond to the genetic code of individuals, and their values correspond to calculated fitness values. The optimized fitness determination process is shown in Fig. 7.

RESEARCH METHODOLOGY
In order to define GA parameters that will produce the best performances, from both GA and control system standpoints, multiple GAs will be executed and compared. For all GAs, fitness values (individual and average) will be presented alongside control system quality indicators. The aforementioned measures will be used for the evaluation of different GA methodologies.
A comparison of the two different GAs will be based on: • population size, • mutation probability, • selection method, and • relative tolerance of the fitness function.
For each comparison, statistics related to response quality indicators, algorithm execution time, and success rate will be presented. The algorithm is considered successful if the rotor angle in the steady-state is the inside limit of 2% of the rotor angle reference value. From this rule, a success rate will be calculated for each variation of GA.

RESULTS AND DISCUSSION
Changing population size directly affects execution time, convergence rate, and in many cases also the quality of the final solutions, PI controllers. The impact on the quality of the ultimate solutions is the largest in GAs with selection by rank. The root of this property lays in the fact that small populations often die out before convergence due to the relatively high probability of not selecting population members for recombination.
For elitism, with an algorithm with a larger population, the settling time is somewhat shorter, and the overshoot is noticeably lower. This is also reflected in the fitness of the whole generation. It can be observed that the execution time is three times longer for the population with a double number of members. Similar results are achieved if the rank selection is utilized, as shown in Tab. 2. Increasing the probability of mutation indirectly increases the diversity of the population within the algorithm. Genetic algorithms whose population size is less than ten individuals often will not converge close to the optimal solution if the probability of mutation is not high enough. For these reasons, for GAs with rank selection and elitism for different values of mutation probabilities are 0.1 and 0.2. From Tab. 3 it can be seen that there are no significant differences between GAs. A difference can only be noticed for the case of overshoot, which is significantly lower when elitism is used. On the other hand, there is no significant difference in other relevant quality measures. The execution time of the algorithm is shorter for a higher mutation probability. Furthermore, it can be noticed that the algorithm with a higher probability of mutation converges much faster. Tab. 4 shows that GA without copies generally has better results. Furthermore, it is necessary to consider the fact that the diversity of the population, in this case is significantly lower, therefore the average fitness also depends on the size of the population. It can be seen that in the case of rank selection, the influence of duplicates is significantly higher. This property is a consequence of the premature convergence of GA. In the later stages of GA where the solutions approach locally optimal points, there is less and less room for improvement or the difference in average fitness between two generations is getting smaller. When the difference in fitness becomes smaller than defined relative tolerance, the stop condition is satisfied, and the genetic algorithm ends. With the smaller tolerance parameter, the genetic algorithm will have multiple generations or longer performance, but also more accurate results. Relative fitness tolerance has an impact solely on later stages of the genetic algorithm. Tab. 5 shows the differences between the solution quality of the algorithms of different relative tolerances. GA with less relative tolerance has a longer execution time, but also better results. Selection proportional to fitness, in this case, cannot be used in the initial steps of the algorithm since each individual would have an extremely low probability of recombination. Therefore, the parameter for proportional selections was introduced. A parameter of 0.5 was chosen since then the smallest number of individuals will have secured or disabled recombination. Since this type of selection favors better solutions, it often reduces the diversity population, and thus the quality of the end solutions.
Tab. 6 shows the difference between fitness and the end of algorithm execution. A small saving in performance time, caused by a selection that is proportional to fitness, can also be noticed. As in the case of selection by rank, at small population sizes, selection proportional to fitness did not bring great advantages. When all achieved results are compared, it can be noticed that the results higher of 0.95 are achieved in the majority of cases. It is interesting to notice that the majority of GA configurations that have achieved high fitness values are designed by using elitism. Furthermore, it can be noticed that no significant changes in fitness values when larger populations are used. This property can particularly be noticed in cases of configurations marked with M. All described facts are presented in Fig. 8. Similar results are achieved when population averages are compared. In this case, it can be noticed that the majority of the highest results are achieved with GA configurations designed with selection based on elitism. Furthermore, it can be noticed that there is no significant difference between best fitness and population averages. From this fact, it can be seen that by using such GA configurations, multiple individuals with high-quality performances are achieved. All abovementioned facts are presented in Fig. 9.  When execution times are compared, it can be noticed that GA configurations designed with larger populations are demanding a longer execution time. It can also be noticed that GA with lower tolerance is also demanding a longer time for execution. This property has its roots in the fact that configurations with lower tolerance will take more iterations to converge. When observing the influence of the selection method, it is interesting to notice that elitism-based GA will take a longer time to execute. All aforementioned facts are presented in Fig. 10.
According to the presented methodology, the optimal configuration is chosen. This configuration is chosen to balance the best fitness, average population fitness, and execution time. This configuration is presented in Tab. 7.

CONCLUSION
From the presented results it can be concluded that there is a possibility for utilization of GA for parametrization of the control system based on DC motor. It can be noticed that the highest performances were achieved if the selection procedure based on elitism is used. Furthermore, the performances with a fitness score up to 0.999982 were achieved if the GA with mutation probability of 0.2 and tolerance of 0.000002. Presented GA was executed by using a population of 26 individuals. GA configuration described above has resulted in a steady-state error of 0.000584 rad. It can be noticed that such a configuration did achieve high accuracy, and at the same time, lower oscillations of the step response.
A main advantage that such an approach offers is a possibility for utilization of such algorithm in design of control system. The GA-based approach can be used for designing a control system without knowledge of modeling and automatic control. Furthermore, such an approach can be used for automatic and autonomous design of control systems that can offer robust performance regardless of parameter change. Future work will be focused on the evolutionary approach for fine-tuning the controller parameters that will be used in order to annul the influence of system decay.

Aknowledgment
This research has been (partly) supported by the CEEPUS network CIII-HR-0108, European Regional Development Fund under the grant KK.01. 1