Optimized PID and NN-based Speed Control of a Load-coupled DC Motor

In this work, three control strategies are presented, compared, and discussed, applied on a load-coupled DC motor. The purpose is to control in an optimal way the motor speed in terms of the armature voltage. Two strategies are based on PID control, working on the classical PID controller and the optimized one by using particle swarm optimization (PSO) to tune the PID controller parameters. The other strategy is based on neural networks (NNs) where two NNs are built to model and control the system. Based on the results, all the strategies reach excellent performances, however, in terms of system response characteristics like rising time or settling time the PID-based controllers show faster responses than the NN controller. Moreover, by comparing these results with other studies that are working with an unloaded DC motor and even when the working system is more complex, the obtained results have a better performance.


Introduction
In most industrial applications, such as rolling mills, belt conveyors, the automotive industry, servo drives, or robotics applications, mechanical resonance occurs leading to a need for a robust control systems.[1,2,3] Stresses on the mechanical coupling shaft are caused by mechanical resonance, particularly in high-performance speed and torque regulation.On the other hand, the majority of servo systems only offer direct measurement of motor variables, not load variables, making the design and adjustment of a two-inertia system challenging [4].As a result, this shaft stress may result in unfavorable conditions for mechanical coupling and may also reduce the system's quality.Additionally, some modes have an impact on how well a drive performs, and in some circumstances, this failure can affect the entire drive system.[5,6] Several control methods, including Proportional-Integral-Derivative (PID), have been proposed to control twomass drive systems to handle torsional vibrations with a feedback loop, sliding mode, adaptive, predictive, and intelligent control, etc.A straightforward, easily adjustable controller is highly desired for industrial motor drive systems.The most fundamental control structure for a speed servo system is known as PI control.[7] There are, however, not many reports on the system's systematic analysis and design.This is primarily because 1) the number of state variables is greater than the number of feedback parameters, making it difficult to achieve an analytical design, and 2) the dynamic behaviors are complex.Creating a unified approach to handle various characteristics is challenging.[8] By adjusting the control parameters using various optimization techniques, PID control is still preferred in conventional control methods to control various systems [8,9].Mathematical approaches to optimize problems have some drawbacks, such as their lack of adaptability and the requirement for mathematical functions to define them.This prompts researchers to use heuristic techniques motivated by natural phenomena.Genetic, Differential Evolution, Particle Swarm Optimization (PSO) algorithms, and others are common heuristic optimization techniques.PSO is a method that is highly preferred and is driven by swarm behavior.[10] With its simplicity, low cost of calculation, and strong performance, it is very promising for adjusting PID control parameters, [9].This study models a two-mass drive system with the goal of implementing motor and load speed control to create a reliable control while reducing torsional vibrations.PSO-based PID controller and NN-based intelligent controller are both used in the control system.The PSO technique is utilized to adjust the PID control parameters, and an online back-propagation learning approach is employed to create the NN controller.To verify the robust control structure, the optimised PID control is compared to the NN control approach and classical PID.Additionally, simulations are carried out both with and without load torque.
The following is how the rest of the article is structured.Section II provides a brief description of the load-coupled DC motor mathematical modeling.Following this, the control strategies used in this work are introduced in Section III.Section IV discusses the suggested methodology to compute the objective function and input parameters during the PID controller optimization process.The findings and discussion in Section V are used to analyze and convey the performance of the stated strategy.Finally, conclusions are drawn and recommendations for future works are presented in Section VI.

Modeling
In this section, the mathematical modeling for the DC motor is detailed and described from physical and electrical perspectives.In this work, it is analyzed a DC motor [11] coupled with a load by a long shaft, as it is shown in Figure 1.The most important system variables described in Table 1 and shown in Figure 1 are used to define the mathematical model.
The armature-controlled DC motor integrates two important aspects: the armature current and the mechanical response of the motor.Regarding the first one, the electrical part can be The mechanical response of the DC motor is given by: Where, T m (t) = K t I a (t) is the motor driving torque, where K t is the motor torque constant, and T s is the shaft torque.Respect to this last variable, the shaft torque's through-time variation is directly proportional to the motor (ω m ) and load (ω l ) speeds through the shaft stiffness coefficient (K s ) as follows: On the other hand, the back EMF given in Equation 1 is proportional to the motor speed through a constant called back EMF constant: Regarding the motor's load, the load speed's through-time variation is directly proportional to the shaft and load torques by the load inertia (J l ): In a nutshell, the analyzed system can be considered as MIMO (multiple inputs and multiple outputs) [8] since ω m and ω l are the outputs (to be controlled) while E a and T l are the inputs (the references for the system).However, as systems get more complex, representing them with differential equations get cumbersome.Then, a suitable way to represent a MIMO system is by using the below state-space system which is basically given by two equations: where x(t) is the state vector, A is the state matrix, B is the input matrix, u(t) is the input vector, y(t) is the output vector, C is the output matrix, and D is the direct transition or feed-through matrix.
Based on Equations 1, 2, 3, and 5, the state-space equations are given, taking I a , ω m , ω l , and T s as state variables.Then, the state-space system is shown in Equation 8 and 9. [8] Figures 2  and ?? show the block diagram for the complete system and the DC motor as such, respectively.
In this particular work, the purpose is controlling the motor speed (ω m ) through the armature voltage (E a ), then it is a need to obtain the respective transfer function for the system.From the state space perspective, it is possible to obtain the system's transfer function by using Equation 10.
Then, based on Equation 8 and 9 it is possible to calculate the transfer function for the system to be controlled, as follows: Figure 3 shows the response of the system for a unit-step function where it is observable that the system is critically damped, with 1.28 s rising time and 2.09 s setting time, and 0.099 static gain.

Control Strategies
In this section, both the OA-based optimized PID and NN-based control strategies are outlined.For the first one, the classical PID control is introduced and then the strategy based on OAs is presented as an optimization technique.For the second one, Model Reference Adaptive Control (MRAC) based on NNs is outlined and described on its main foundations.

Optimized PID Control
The well-known and classical PID controller is defined as: where K p , K i , and K d are the controller parameters to be designed and optimized later, in this case, by using PSO approach.
Optimization aims to search for a decision space supported by a group of decision variables or parameters that produce the maximum acceptability considering the defined goal, which is generally set by the minimization of any objective function (OF).OAs are centered around different inspiration sources.For instance, nature-inspired algorithms are novel problem-solving techniques that come from natural processes.Among those ones are PSO, genetic algorithm (GA), cukcoo search algorithm (CSA), ant colony optimization (ACO), and so on.
PSO is a classical and population-based optimization method that provides robust control performances in optimization problems by taking swarm behaviors as foundations.For understanding how PSO works, let the actual position of h th particle of the swarm be denoted as P h , which is considered in the search space of S D .The best particle and swarm positions can be denoted as P best and G best , respectively.At any step k, the h th particle's velocity is expressed as follows: where C 1 and C 2 are the acceleration coefficients (greater than zero), and rand 1 and rand 2 are random values in a range from 0 to 1.With V h (k) defined, it is possible to compute the particle's position as follows:

NN-based Control
Several times in industrial applications system identification is a tough task due to many reasons like complex nonlinear systems, involving large costs or a long time, etc. Machine learning, specifically NNs have the advantages of efficient learning, adaptation, and nonlinear mapping skills for modeling and learning from complex systems.Usually, system identification by using novel methods like NNs is suitable for unknown systems where the transfer function is not defined.In other cases, even when the transfer function is known using NNs to model the system is suitable to have an alternative system for testing (controller design and tunning) and not using the real one.In this work, the transfer function is known and defined, so a NN is employed to build a model capable of learning from that system to be able to control it later.The MRAC shown in figure 4) employs two NNs: a model network and a controller network.The first one is offline trained using historical plant measurements.Then, the controller network is adaptively trained to force the plant output to track a reference model output.In this point, it is noteworthy to say that the model network is used to forecast the control changes' effect on the plant output, which lets to update the controller parameters.

Brief Introduction to NNs
A NN in general is capable to learn a nonlinear function, recall and generalize from training data.Figure 5 shows the general structure of a NN with input layers, hidden layers, and output layers.The output of a single hidden layer NN can be expressed as: where I is the input array considering the bias term, U is the network output array, w 1 and w 2 are the weights for the input and output layers, respectively.Moreover, f (.) and ϵ(.) are the hidden layer and output layer activation functions, respectively.Now, it is necessary to update the NN weights.To accomplish this task back-propagation technique is the most widely used one [12] as learning rule to perform the update of weights in NNs.Into the back-propagation process there are many learning functions can be used to control the update of weights like gradient descent (GD), Levenberg-Marquardt (LM), among others.In this work, LM algorithm is used as learning function; actually, this algorithm interpolates between the Gauss-Newton algorithm (GNA) and the gradient descent.LM method is more robust than the GNA, which means that in several scenarios it finds a solution even if it starts quite far from the final minimum.For this kind of application, it is seen than the LM method gets a better performance to train a NN than the typical gradient descent.[13] 3.2.2.Model Network The system model, (Equation 11), is implemented using MAT-LAB/Simulink environment, and the data collection is carried out.In order to have suitable datasets for training, validation, and testing, 50000 samples were collected with 0.1 s sampling time.The initial conditions for the data collection set the input for the system in a range from 0 to 5 V, while the maximum and minimum interval values are 2 and 1 s, respectively.Once the data are collected those ones are split into three datasets: 80% for training, 10% for validation, and 10% for testing.
The proposed NN architecture is based on four inputs (two regarding the delayed plant inputs and two regarding to the delayed plant outputs).Moreover, the built NN is based on a single hidden layer with five neurons in order to not set a quite complex model but a robust and well-performed one.To guarantee a good training period for the NN 3000 epochs is considered to train it.

Controller Network
For the controller network, the data used is the same that the model network.Actually, the NN architecture follows a similar structure that the model network but from the two inputs regarding the delayed plant outputs only one is considered while the other one is for controller delayed output.

Methodology 4.1. Objective Function for PID Controller Optimization
Before adjusting the controller parameters to produce an optimal controlled response it is essential to state what constitutes an optimal response.There are several measures that can be used to evaluate the quality of controlled responses like Integral Square Error (ISE) in Equation( 16), Integral Absolute Error (IAE) in Equation ( 17), and Integral Time-weighted Absolute Error (ITAE) in Equation ( 18) [14].ITAE and IAE are among the more commonly used measures.IAE integrates the absolute error (ϵ) over time by tending to produce a slower response than the ISE measure, but generally with less sustained oscillations.On the other hand, ITAE integrates the absolute error over time multiplied by the time like weights.ITAE settles much more quickly than the other methods, however, sometimes it produces sluggish initial responses.
In this work, IAE and ITAE are the metrics used to build the objective function.Moreover, the error is computed based on the comparison between the reference input (1 as it is a step input) and the controlled system output (y(t)) on a time range from 0 to 2 (the output is already stabilized), the objective function (OF) to be minimized finally is stated as follows: Generally, any OF is subjected to a group of inequality constraints that helps to adjust the search space over which the OA tries to find the optimal solution [10].In this work, the constraints correspond to the range of values for the PID controller parameters, i.e., K p , K i , and K d .The range is defined from 0 to 200 since the PID controller parameters can operate getting optimal performance.

Input Parameters for the PSO OA
Every OA is characterized for getting input parameters with which the optimization process is started.Among the common ones are the total population, the maximum number of iterations, the error tolerance, etc.Generally, the choice of parameters is reached based on trial and error, i.e., testing a good quantity of value combinations by observing the OA performance.For the PSO OA there are input parameters that need to be defined like the two acceleration coefficients (C 1 and C 2 ) at least.Then, the set input parameters for the PSO OA are detailed as follows: • The error tolerance set as 1 × 10 −12 .
• The maximum number of iterations set as 600, computed as 200*n variables .
• The swarm size or population set as 100, computed as min(100, 100*n variables ).
• C 1 and C 2 set both as 1.49, which is a default value.

Results and Discussion
This section discusses the results of the classical and PSO/NN PID controller.First, the results of the classical and PSO-based optimized PID controller are presented.Then, the results of the NN controller are introduced.Finally, a discussion about the obtained results is outlined by comparing them with previous studies.

Classical and PSO-based optimized PID Controller
First, the classical PID Controller is built by using the well-known PID Tuner App in MATLAB/Simulink environment.Then, by using the PSO OA the PID controller parameters are updated and tuned in order to get much better performance.
Regarding the PSO OA, the best-reached value during the optimization process is 40.254 at 200 iterations where the algorithm decided to stop.Based on that, Figure 6 shows the reference input, the uncontrolled system response, and the controlled system responses based on the classical and optimized PID controllers.Likewise, Table 2 shows the classical and optimized PID controller parameters as other important response characteristics like rising time and settling time.
Looking at these results, it is noteworthy to mention that the OA decides to simplify the PID controller to a PI one since the best found K d value is zero.Following this idea, actually better response characteristics are got, because the rising time decreased to 0.51 s and the settling time reached 0.83s, which indicates that the system achieves the reference input faster and even without overshooting.8 shows how the controller network fits very well the model reference output based on the given model reference input.
Once both the model and controller networks are built the NN controller is able to operate over the plant to control it.In order to compare the performance of the NN controller with the PID controllers, Figure 9 illustrates similar results to Figure 6 but by adding the NN controller response, where several reference inputs are triggered in order to evaluate the controlled systems' responses.

General Discussion
In order to open a general discussion about the obtained results and the comparison with the obtained ones by Koca et al. [13], Table 3 resumes the controlled system response characteristics for the three different controllers of this work and the two controllers proposed (PID and NN controllers) in [13].
Looking at the results it is necessary to mention that the system defined in this work is actually more complex than the one used in [13] where the authors represent the motor only as a moment of inertia but in this project, the motor is modeled as such with its respective transfer function as can be seen in Figure 2.
Following this idea, the settling times calculated are smaller than the ones computed by Koca  et al. [13].In their work, the performance of the NN is better than the PSO-PID controller, however, the system to be controlled is simple.In this current work, even when the system is more complex, the performance of the classical and optimized PID controllers is better than the NN controller in terms of rising and settling time.In this kind of application like the load-coupled DC motor, the PID-based controller performance is quite suitable.

Conclusions
In this paper, three control strategies are presented, based on PID control and one based on NN control for a load-coupled DC motor.Even when a DC motor model is sometimes complex to control in this case the system is coupled with an additional load by a shaft.Classical and optimized PID controllers are designed and proposed considering the PSO OA as the optimization technique to update and tune the PID controller parameters.On the other hand, following the idea of adaptive neural control, a NN controller is designed to face the same problem of controlling the system.
Based on the presented results, the performance of the classical and optimized PID controllers is quite suitable and fulfills the control requirements.Likewise, the NN controller has an excellent performance in terms of not presenting any kind of oscillations or overshooting.However, it is  necessary to mention that in the function of parameters like settling or rising time the PID and PSO-PID controllers help the system to reach the reference input in a faster way than the NN controller does.
As future work, it aims to explore the improvement of the reference model to enhance the NN controller and get more optimal system response characteristics.

Figure 1 :
Figure 1: Schematic diagram of the DC motor with an additional load.

Figure 2 :
Figure 2: Block diagram for the load-couple DC motor.

Figure 3 :
Figure 3: Unit Step response for the open loop system plant's transfer function.

Figure 4 :
Figure 4: Block diagram of NN adaptive control.

Figure 5 :
Figure 5: Basic structure of a NN with its input, hidden, output layers.

Figure 6 :
Figure 6: System responses for a unit step input.

Figure 7 :
Figure 7: Training (left), validation (middle), and testing (right) for the model controller based on the plant's historical data.

Figure 8 :
Figure 8: Reference model and controller network output based on the reference model input.

Figure 9 :
Figure 9: Reference model and controller network output based on the reference model input.

Table 1 :
Variables of the system.

Table 2 :
PID controller parameters and system response characteristics.As it was mentioned in Section 3, the neural adaptive control is based on two NNs, the model network and the controller network.As the first step, the model network was trained, validated, and tested in order to get the best model which fits the historical data of the plant or system.Figure7shows the results of training, validation, and testing where it is quite notable that the

Table 3 :
[13]arison between the system response characteristics obtained by the designed controllers and the proposed ones in[13].× 10 −4 which indicates that the model gets excellent learning for forecasting the system output.The next step is building the controller network based on the same plant's historical data.Figure