# Optimized linear regression control of DC motor under various disturbances

• Celal Onur Gökçe
From the journal Open Chemistry

## Abstract

In this study, an optimized linear regression controller is proposed for velocity control of DC motor. System is tested under disturbances of different types. Step, sinusoidal and trapezoidal functions are used as reference input. A linear single layer network of weights is used to calculate the necessary armature voltage by giving past measured velocity, past reference and certain amount of future reference as inputs. Training data are generated using Proportional Integral (PI) controller parameters which are optimized using particle swarm optimization (PSO). In this first phase of training, pseudo-inverse solution is used to find the coarse parameters of the network. These parameters give suboptimal results with low performance even lower than that of PSO-optimized PI controller. In the second phase of training, parameters of the network are fine-tuned using PSO algorithm again, this time for optimization of network parameters. Quite encouraging results including up to more than 1,500% increase in performance are obtained and reported.

## 1 Introduction

Automatic control systems play an important role mainly in autonomous systems and also in other kinds of machinery. Velocity control of DC motor is an important application of automatic control.

In this study, automatic control of DC motor velocity is done using two kinds of methods. The first method, namely, Proportional Integral (PI) control, is a widely adopted technique in industry and showed remarkable success in various control applications. The second method, optimized linear regression (LR) control, is a type of intelligent control method.

DC motor is modeled and simulated with second order dynamics for velocity control meaning that the inductance is also considered in the simulation. The schematic of the DC motor is given in Figure 1.

Figure 1

Schematic of DC motor.

Mathematical model of DC motor is derived as follows:

For the electrical part, using Kirchhoff’s voltage law:

(1) V a = R a i a + L a d i a d t + e b ,

where V a is the armature voltage, i a is the armature current, R a is the armature resistance, L a is the armature inductance, and e b is the back emf voltage.

From the principles of electromagnetics:

(2) e b = K b ω ,

where K b is the back emf constant and ω is the angular velocity of the rotor.

(3) T m = K m i a ,

where T m is the torque produced by the motor and K m is the torque constant.

For the mechanical part, using Newton’s second law of motion:

(4) T m T l T f = J d ω d t + b ω ,

where T l is the load torque, T f is the static friction, J is the inertia and b is the viscous friction coefficient.

Velocity control of DC motor is done using closed loop control. The diagrams for PI controller and LR controller in are given in Figures 2 and 3, respectively.

Figure 2

Diagram of PI controller.

Figure 3

Diagram of LR controller.

PI controller has the following mathematical form:

(5) V a = K p e + K i e d t ,

where V a is the armature voltage and K p and K i are the proportional and integral constants, respectively and e is the error between ω ref and ω:

(6) e = ω ref ω .

LR controller has form of LR function inputs which are of past velocity, past velocity reference and certain amount of future velocity reference.

(7) V a = w 0 + w 1 ω 0 + w 2 ω 1 + + w m 1 ω m 1 1 + w i ω ref 0 + w i + 1 ω ref 1 + + w i + k ω ref i + k ,

where V a is the armature voltage, w i is the weight of the network, ω i is the angular velocity at different time points and ω ref is the reference angular velocity at different time points.

For tuning the PI controller, particle swarm optimization (PSO) algorithm is used. PSO is an optimization technique using several particles to search for the parameter space. Each particle is initialized randomly and updated iteratively. In each iteration new position of each particle is found using the formula:

(8) x n = x n 1 + v n ,

where x n is the new position of the particle, x n−1 is the previous position of the particle and v n is the particle’s velocity calculated using the following formula:

(9) v n = c 1 v n 1 + c 2 ( p x n 1 ) + c 3 ( g x n 1 ) ,

where p is the particle’s best known point, g is the best known point for all particles and c 1, c 2, c 3 are constants.

LR controller is tuned in two stages. In the first stage, pseudo-inverse solution is used to initialize coarse parameters. In the second stage, PSO is used to fine tune the parameters.

Pseudo-inverse solution has the following form:

(10) W = ( φ T φ ) 1 φ T T ,

where ϕ is the concatenated input matrix, T is the target vector and W is the weight vector.

Velocity control of DC motor is studied quite extensively in literature. Most methods are based on PID or its variants. There are some neural network-based controllers designed and also tested. In ref. [1], PID control of DC motor velocity is done using computer and various equipment. Simulation and real system response results are given and compared. In ref. [2], several optimization algorithms are used and compared to tune the parameters of PI controller for DC motor velocity control. In ref. [3], Fractional Order PID (FOPID) controller is used to control DC motor velocity. System dynamics is identified using a variant of recurrent neural networks and the controller is tuned accordingly. In ref. [4], PID controller is used to control DC motor velocity. The parameters of the PID controller are optimized using gradient descent based LR approach. In ref. [5], DC motor velocity is controlled using FOPID controller. The controller’s parameters are found using PSO algorithm. In refs [6,7], Artificial Neural Networks are used to identify the dynamics and control velocity of DC motor. Training of the network is done using back-propagation algorithm. In ref. [8], ant colony optimization algorithm is used to tune the parameters of FOPID controller for DC motor velocity control. In ref. [9], modified Ziegler–Nichols method and PSO algorithms are used and compared to tune parameters of PI controller for DC motor velocity control. In ref. [10], system dynamics identification is done using recursive least squares method. Velocity control of DC motor is done using adaptive discrete pole placement controller and results are compared with PI controller. In ref. [11], velocity control of DC motor is done using PID controller parameters, which are found using Aquila optimizer method. In ref. [12], DC motor velocity control is done using nonlinear PID neural controller. PSO algorithm is used for optimization. In ref. [13], DC motor velocity control is implemented on a CAN bus network causing stochastic delays between plant and controller. PID controller parameters of which are optimized using PSO algorithm is used. In ref. [14], ZN and PSO methods are compared for DC motor velocity control problem under various types of disturbances and results are reported. Automatic control is not limited to single input single output linear systems like DC motor. Control of multi input multi output nonlinear systems is a more challenging problem. In ref. [15], PSO-optimized PID control of a differential driven mobile robot is implemented. System is tested for various disturbances. In ref. [16], PSO optimized PID control of quadcopter is implemented and tested for various disturbances.

## 2 Material and method

The DC motor parameters are taken realistically as shown in Table 1.

Table 1

Parameters of DC motor

Parameter Value
La (Henry) 0.35 × 10−3
Ra (Ohm) 0.600
J (kg m2) 155.4 × 10−7
B (N m s/rad) 1.0 × 10−5
Km (N m/A) 0.0187
Fs (N) 0.020

A sampling time of 1 × 10−4 s is taken for all simulations, and this is much less than the electrical time constant of the DC motor.

Note that in LR controller, the output depends on both past and future inputs. Furthermore, the output of the controller not only depends on error but also on velocity and velocity reference separately. So, for example, for PI controller, the velocity and velocity reference values of 1000 and 1002 are the same as 5 and 7, while for LR controller, these two sets of inputs are different. As input to the LR controller, a window of past velocity and reference and another window of future reference is entered as shown in Figure 4.

Figure 4

Windows of past and future.

The internal structure of LR controller is shown in Figure 5.

Figure 5

Internal structure of LR controller.

The parameters of PI controller are found using PSO technique. As performance metric, a function of total absolute error is used. LR controller has much more parameters than PI controller. The parameters of LR controller are found in two consecutive stages. In the first stage, pseudo-inverse solution is used to find the coarse parameters. In the second fine-tuning stage, PSO algorithm is used to find the optimal parameters of LR controller. The overall algorithm of LR controller tuning is given in Figure 6.

Figure 6

Optimizing LR controller.

## 3 Results

For free running DC motor under external disturbance of only static friction, performance difference between PID and LR controllers is very low and negligible as shown in Figures 7 and 8.

Figure 7

Figure 8

Performance of PID controller for free running DC motor is 172.5, while performance of LR controller for free running DC motor is 200. Note that there is a small performance difference between the two controllers when DC motor is running freely. The performance difference is about 15% and it may be accepted that PID controller has about the same performance as LR controller. It may be argued that there is too little gain for increase in computational cost so there is no reason to prefer LR controller over PID. This reasoning will be disproved with the following results when there is an external disturbance due to some load which the DC motor is driving. As the external disturbance increases, the performance difference also increases making the LR controller even more attractive.

For disturbance magnitude of 3 × 10−2, LR performs better than PID as shown in Figures 9 and 10.

Figure 9

Response of PID control system to disturbance magnitude of 3 × 10−2.

Figure 10

Response of LR control system to disturbance magnitude of 3 × 10−2.

Performances of two approaches for various disturbance frequencies are shown in Figure 11.

Figure 11

Performances of PID and LR controllers for disturbance magnitude of 3 × 10−2.

Note that LR performs slightly better than PID. The difference reduces down to 15% for some disturbance frequencies.

When the disturbance amplitude is increased further to 3 × 10−1, the performance difference increases largely as shown in Figures 1214.

Figure 12

Response of PID control system for disturbance magnitude of 3 × 10−1.

Figure 13

Response of LR control system for disturbance magnitude of 3 × 10−1.

Figure 14

Performances of PID and LR controllers for various disturbance frequencies.

Horizontal axis is the logarithm of disturbance frequency. Disturbance frequencies from 1 Hz to 5 kHz are applied to the system and performances are recorded. Note that in all the disturbance frequencies, LR controller has clearly higher performance than PID controller. This performance difference is higher in some disturbance frequencies and increases up to more than 1,700% (Table 2).

Table 2

Performance comparison of two control methods

Dist. amp. Dist. freq. PID perf. LR perf. % difference
0 173.19 199.88 15.41
3 × 10−2 1.00 144.14 199.88 38.68
3 × 10−2 2.00 132.16 205.47 55.47
3 × 10−2 5.00 160.79 208.72 29.81
3 × 10−2 10.00 160.22 208.32 30.03
3 × 10−2 20.00 170.97 205.28 20.06
3 × 10−2 50.00 171.96 201.94 17.43
3 × 10−2 100.00 172.12 200.05 16.23
3 × 10−2 200.00 172.33 200.17 16.16
3 × 10−2 500.00 172.42 201.39 16.80
3 × 10−2 1000.00 172.10 202.35 17.58
3 × 10−2 2000.00 167.02 202.23 21.08
3 × 10−2 5000.00 147.28 201.26 36.65
3 × 10−1 1.00 57.44 199.88 247.96
3 × 10−1 2.00 35.75 268.16 650.08
3 × 10−1 5.00 45.71 98.51 115.51
3 × 10−1 10.00 54.95 85.10 54.87
3 × 10−1 20.00 58.16 100.41 72.67
3 × 10−1 50.00 58.49 107.60 83.97
3 × 10−1 100.00 59.09 114.67 94.06
3 × 10−1 200.00 58.89 111.98 90.16
3 × 10−1 500.00 55.09 116.02 110.62
3 × 10−1 1000.00 36.09 147.94 309.88
3 × 10−1 2000.00 8.89 164.06 1745.65
3 × 10−1 5000.00 25.73 159.21 518.83

## 4 Conclusion and comment

Performance comparison of two alternative controllers is done for DC motor velocity control framework. It is found that more complex LR controller with higher number of parameters shows higher performance especially for disturbances of higher amplitude.

PI controller has two adjustable parameters and gives relatively satisfying performance for disturbances of low amplitude. On the other hand, when the amplitude of disturbance increases, PI controller’s performance drops. This is due to the underfitting of low model complexity of PI controller. As the disturbance amplitude increases, the plant’s effective model complexity increases and any controller with low model complexity will fail to follow up. LR controller has much more adjustable parameters than PI controller. Thus, LR controller has higher model complexity and can control more complex plants. The performance difference, especially at disturbances of high amplitude, can be explained with this reasoning.

As future study, reinforcement learning is planned to be applied to the control problem with various controller architectures.

1. Funding information: There is no one or no commercial company to be acknowledged

2. Conflict of interest: As the author of this study, I declare that I do not have any conflict-of-interest statement.

3. Ethics committee approval and informed consent: As the author of this study, I declare that I do not have any ethics committee approval and/or informed consent statement.

4. Ethical approval: The conducted research is not related to either human or animal use.

5. Data availability statement: Data sharing is not applicable for this article as no datasets were generated or analyzed during the current study.

## References

[1] Huang G, Lee S. PC-based PID Speed control in DC motor. International Conference on Audio, Language and Image Processing; 2008. p. 400–7.Search in Google Scholar

[2] Vishal V, Kumar V, Rana KP, Mishra P. Comparative study of some optimization techniques applied to DC motor control. IEEE International Advance Computing Conference (IACC); 2014. p. 1342–7.10.1109/IAdCC.2014.6779522Search in Google Scholar

[3] Munagala VK, Jatoth RK. A novel approach for controlling DC motor speed using NARXnet based FOPID controller. Evol Syst. 2022;1–6. 10.1007/s12530-022-09437-1.Search in Google Scholar

[4] Parvathy R, Devi RR. Gradient descent based linear regression approach for modeling PID parameters. International Conference on Power Signals Control and Computations (EPSCICON); 2014. p. 1–4.10.1109/EPSCICON.2014.6887482Search in Google Scholar

[5] Hasan FA, Rashad LJ, Fractional-order PID. Controller for permanent magnet DC motor based on PSO algorithm. Int J Power Electron Drive Syst. 1724;10(4):1724.Search in Google Scholar

[6] Weerasooriya S, El-Sharkawi MA. Identification and control of a DC motor using back-propagation neural networks. IEEE Trans Energ Convers. 1991 Dec;6(4):663–9.10.1109/60.103639Search in Google Scholar

[7] Hoque MA, Zaman MR, Rahman MA. Artificial neural network based controller for permanent magnet DC motor drives. Conference Record of the 1995 IEEE Industry Applications Conference Thirtieth IAS Annual Meeting. Vol. 2; 1995. p. 1775–80.10.1109/IAS.1995.530521Search in Google Scholar

[8] Patil MD, Vadirajacharya K, Khubalkar SW. Design and tuning of digital fractional-order PID controller for permanent magnet DC motor. J Inst Electron Telecommun Eng. 2021;1–11.10.1080/03772063.2021.1942243Search in Google Scholar

[9] Kanojiya RG, Meshram PM. Optimal tuning of PI controller for speed control of DC motor drive using particle swarm optimization. International Conference on Advances in Power Conversion and Energy Technologies (APCET); 2012. p. 1–6.10.1109/APCET.2012.6302000Search in Google Scholar

[10] Alkamachi A. Permanent magnet DC motor (PMDC) model identification and controller design. J Electr Eng. 2019;70(4):303–9.10.2478/jee-2019-0060Search in Google Scholar

[11] Aribowo W, Supari BS, Suprianto B. Optimization of PID parameters for controlling DC motor based on the aquila optimizer algorithm [IJPEDS]. Int J Power Electron Drive Syst. 2022;13(1):808–2814.Search in Google Scholar

[12] Al-Araji AS. Design of nonlinear PID neural controller for the speed control of a permanent magnet DC motor model based on optimization algorithm. Al-Khwarizmi Eng J (Alkej). 2017;10(1):72–82.Search in Google Scholar

[13] Qi Z, Shi Q, Zhang H. Tuning of digital PID controllers using particle swarm optimization algorithm for a CAN-based DC motor subject to stochastic delays. IEEE Trans Ind Electron. 2020 Jul;67(7):5637–46.10.1109/TIE.2019.2934030Search in Google Scholar

[14] Gökçe CO, Durusu V, Unal R. Farklı Yük Çeşitleri İçin Parçacık Sürü Optimizasyonu ve Ziegler-Nichols Metodunun DC Motor Hız Kontrolü Probleminde Karşılaştırılması. Avrupa Bilim ve Teknoloji Derg. 2022 Jan;33:88–92.10.31590/ejosat.1022991Search in Google Scholar

[15] Gökçe B, Koca YB, Aslan Y, Gökçe CO. Particle swarm optimization-based optimal PID control of an agricultural mobile robot. Dokl Bulg Akad Nauk. 2021;74(4):568–75.10.7546/CRABS.2021.04.12Search in Google Scholar

[16] Sonugur G, Gokce CO, Koca YB, Inci SS, Keles Z. Particle swarm optimization based optimal PID controller for quadcopters. Dokl Bulg Akad Nauk. 2021;74(12):1806–14.10.7546/CRABS.2021.12.11Search in Google Scholar