Introduction

Nowadays Direct Current (DC) motor is used in many industry applications where a flexible range of angular velocity is required such as rolling mills, elevators, electric vehicles, robot manipulators, cranes, aircraft, etc. due to its features like cost-effectiveness, performance, ease of use, and quiet operation [1, 2]. Due to the environmental changes, making a linearized model from the nonlinear plant, unknown dynamics, and disturbances the motor parameter can be changed [3, 4]. Therefore robust controllers need to be employed for handling these uncertainties.

There are many controllers available to speed control of the DC motors under disturbances, and parameter changes like the Proportional Integral Derivative (PID) controller and Model Predictive Control (MPC). The main difficulty in implementing a PID controller is tuning its parameters and with the system getting complex and non-linear, the performance of PID is decreased [5]. PID is a nonlinear controller where the system faces difficulties in tracking the reference line and handling the nonlinearity of the plant [6]. MPC is becoming popular but performance becomes worse under parameter uncertainty like PID controller [7]. Uncertainty may arise as a result of mechatronic element deterioration, instrument noise, impacts from the environment, overload, etc. H-infinity controller with uncertainty and overloading is used to control the speed of the DC motor [8]. Conventional H-infinity controllers have precise control over DC motors but in a closed-loop system, the order of the system hampers the system performance [9]. One Category of Variable Structure System (VSS) is the Sliding Mode Controller (SMC) which was invented by Prof. V. I. Utkin and Prof. S. V. Emelyanov in the time of late 1950s. SMC can reduce the complexity of higher-order systems. It can track the system to reference points in the time of parameter variation and with external and internal disturbances [10]. SMC is now used as an automated controller in various applications such as robotics, mobility control issues, manufacturing control, aviation, and power electronics [11]. When the state trajectory gets closer to the sliding surface, it faces difficulties in precisely following the sliding mode as it approaches the equilibrium point. Consequently, the path substitutes between the two margins of the sliding mode surface, consequential in the existence of chattering [12]. SMC consists of two portions known as switching control and equivalent control and the chattering comes with growing the switching surface gain. To achieve robust stability, the switching gain must be greater than the maximum range of possible outcomes due to uncertainty [13].

There is much literature on the speed control of DC motors but most of them are not robust. Phase margin, gain margin, and bandwidth are used as performance parameters for controlling DC motors in which Atom Search Optimization (ASO) is used to determine the gain parameter of PID and this approach shows excellent performance. The result is compared with the Sine Cosine Algorithm (SCA) and Grey Wolf Optimization (GWO) based PID where these algorithms showed relatively poor performance [14]. Harris Hawks Optimization (HHO) algorithm is used to tune the gain parameter of PID taking Integral Time Absolute Error (ITAE) as a cost function [15]. The Genetic Algorithm (GA) is used to tune the PID used for speed control of the DC motor with relatively poor performances [16]. Fractional order PID (FOPID) is used where the objective function is ITAE with a larger overshoot problem [17]. The chaotic version of ASO-tuned FOPID shows minimum overshoot, rise time, and settling time with outstanding performance implemented to control the speed of the DC motor [18]. Nowadays, Multi-resolution PID (MRPID) controllers are used for thermal systems [19] which can be implemented to control the speed of the DC motor also and this controller overcomes the challenges of the PID and FOPID controllers in the presence of noise [20]. Intelligent controllers like Fuzzy Logic Controllers (FLC) are implemented to control DC motors based on improved GA [21] and improved Particle Swarm Optimization (PSO) algorithm [22]. Another type of controller is a Wavelet-based Fuzzy Adaptive Hybrid Bat-Vulture PID (WFA-HBVPID) controller is implemented to control the speed of the brushless DC motor [23]. Super twist algorithm based second order SMC for speed control of DC motor is also implemented [24]. Buck converter-based MPC is used to control the speed of the DC motor under variation of load torque conditions [25].

Fig. 1
figure 1

Block diagram presentation of the DC motor speed control for both simulation and hardware implementation

Most of the works in the literature are based on PID controllers that are sensitive to parameter variation and disturbance subjected to the plant. Considering those problems, the contribution and flow of the work are presented in Fig. 1. And the key contribution investigates the following:

  • The implementation of GA and PSO to tune the gain parameters of both PID and SMC to find out the optimum performance of the DC motor and, therefore, presents a typical comparison between GA and PSO.

  • The system stability by implementing the bode plot of the closed loop system.

  • The robustness of SMC for six different extreme cases where parameters of the DC motor are varied in the range − 40% to + 50%.

  • The control signal variation under changing the parameter of the DC motor for these six cases while keeping the gain constant.

  • The speed tracking of the practical setup of the DC motor under two controllers.

This paper organization includes an introduction section which consists of theoretical aspects of DC motors and a literature review part. Section "DC Motor Model" describes the DC motor model and Section "Control Law and Algorithm" includes controller design and a brief description of algorithms. The results are discussed in Section "Result and Analysis" which includes speed tracking performance, stability analysis of the plant, robustness analysis, and the practical validation of simulated results. Finally, Section "Conclusion and Future Work" concludes the paper.

DC Motor Model

The DC motor is a device that transforms electrical energy, specifically voltage, into mechanical energy. (output is angular velocity). A simple electro-mechanical form is presented in Fig. 2, where the variables are \(\:V\) = DC power supply in volts, Eb=Back EMF in volts, \(\:{R}_{m}\)= Armature resistance in Ω, \(\:{L}_{m}\)= Armature inductance in Henry, i= Armature current in Ampere, \(\:{\omega\:}_{m}\)= Angular velocity in RPM, T = Torque in N-m, j= inertia constant in kg.m2, \(\:B\) =Friction constant in N-m-sec/rad.

Fig. 2
figure 2

Equivalent circuit model for DC motor

If \(\:{k}_{e}\) is the electromotive force constant of the motor and \(\:{k}_{t}\) is the torque constant of the motor, then the transfer function of the motor is given by Eq. (1) [26],

$$\:\frac{\omega_m\left(s\right)}{V\left(s\right)}=\frac{k_t}{\left(js+B\right)\:\left(R_m+{sL}_m\right)+k_tk_e}$$
(1)

The parameters of DC motor are selected as, Rm=0.6 Ω, Lm=0.8, j= 0.9 kg.m2, B = 0.7 N-m-sec/rad,, \(\:{k}_{e}\)= 0.2, \(\:{k}_{t}\) =0.2 [26] and the motor’s transfer function changes into,

$$\:\frac{{\omega\:}_{m}\left(s\right)}{V\left(s\right)}=\frac{2}{7.2{s}^{2}+11s+4.6}$$
(2)

Control Law and Algorithm

The overall system consists of a DC motor which is controlled by either PID or SMC tuned by GA or PSO. The controller is fed by an error signal which is the subtraction of the reference signal and feedback signal as input and then generates the control signal in volts which is fed to the DC motor system. The overall system representation is depicted in Fig. 3.

Fig. 3
figure 3

Block representation of the overall system

Conventional PID Controller Design

Three sections of the controller named Proportional (P), Integral (I), and Derivative (D) construct the PID controller. Also, the addition of differential gain with the PI controller forms the PID controller. The integral term here is responsible for eliminating steady-state error [27]. DC motors are employed in the majority of industrial and commercial applications, and the PID controller is appropriate for use due to its simplicity [28]. In the traditional PID, the control signal can be expressed as follows [29]:

$$\:G\left(s\right)=k_p+\frac{k_i}s+k_ds$$
(3)

where, \(\:{k}_{p}\), \(\:{k}_{i}\:\), \(\:{k}_{d}\) represent proportional gain, integral gain, and differential gain, respectively.

SMC Design

SMC is a nonlinear control strategy known for its high precision, robustness, and simplicity in tuning and implementation. For a DC motor, an error, \(\:e\) is the deviation of actual speed, \(\:{\omega\:}_{m}\) from the reference speed, \(\:{\omega\:}_{r}\), and it is given by Eq. (4).

$$\:e={\omega\:}_{r}-{\omega\:}_{m}$$
(4)
$$\:or,\:\ddot{e}=\ddot{{\omega\:}_{r}}-\ddot{{\omega\:}_{m}\:}$$
(5)

The sliding surface for a second-order system can be defined as [30]

$$\begin{array}{l}\quad \; s=Ce+\:\overset.e\\\:or\:\overset.s=C\overset.e+\ddot{\omega_r}-\ddot{\omega_m\:}\end{array}\\$$
(6)

Replacing the control variable V by u, Eq. (2) can be written in the time domain form.

$$\begin{array}{c}\:7.2\ddot{\omega_m}+11\dot{\omega_m}+4.6\omega_m=2u\\\:or,\:\ddot{\omega_m}=\frac{-11\dot{\omega_m}-4.6\omega_m+2u}{7.2}\end{array}$$
(7)

Combining Eq. (6) and Eq. (7),

$$\overset.s=C\overset.e+\ddot{{\omega\:}_r}+1.53\dot{{\omega\:}_m}+0.64{\omega\:}_m-0.28u$$
(8)

To satisfy the stability condition by Lyapunov,

$$s\overset.s<0$$
(9)

Combining the equivalent part and switching part final control signal becomes,

$$\:u=\frac1{0.28}\left(C\overset.e+\ddot{{\omega\:}_r}+1.53\dot{{\omega\:}_m}+0.64{\omega\:}_m+K\frac s{\left|s\right|+\delta\:}\right)$$
(10)

where, \(\:\delta\:\) is less than 1 but greater than 0 [31].

Optimization of Controllers Using Genetic Algorithm

Based on natural selection, GA can produce optimized results globally. The GA principle is based on the living creature, which will continue to exist while the other will fade or perish. A kid character is a hybrid of its parents’ personalities; it can live if it successfully adjusts to new circumstances. However, every child has a chance of disappearing if his or her parents have a bad character [32]. It starts with the initial population. It has three main stages: selection, crossover, and mutation. Each iteration of this algorithm is known as generation [33]. The design involves for PID controller has, \(\:{k}_{p}\), \(\:{k}_{i}\:\), \(\:{k}_{d}\) parameters and SMC has C, K, and \(\:\delta\:\) parameters that have to be tuned using GA. The whole process of determining these gain parameters using GA is represented in Fig. 4. In order to obtain the optimal parameters for the PID and SMC controllers, it is necessary to minimize the objective function, which is often referred to as the fitness function also known as ITAE and is given by Eq. (11) [34].

$$\:ITAE={\int\:}_{0}^{\infty\:}t\left|e\left(t\right)\right|dt\:$$
(11)
Fig. 4
figure 4

Flow diagram of GA [35]

Optimization of Controllers Using Particle Swarm Optimization Algorithm

Mr. James Kennedy and Russell C. Eberhart created the PSO algorithm in 1995. PSO is based on the biological behavior of some animals, especially birds, and fishes, and uses swarm intelligence to pursue live behaviors [36]. In this strategy, each bird “particle” seeks the optimal place by updating its location within the swarm based on its stored memories of the best site and knowledge of the global finest site. The main theme of the optimization procedure can be given by Eqs. (12) and (13).

$$\:v_k\left(i+1\right)=Wv_k\left(i\right)+C_1{rand}_1\left(g_{best}-x_k\left(i\right)\right)+C_2{rand}_2\left(p_{best}-x_k\left(i\right)\right)$$
(12)
$$\:{x}_{k}\left(i+1\right)={x}_{k}\left(i\right)+{v}_{k}\left(i+1\right)\:$$
(13)

where, k = 1,2,3…….,n.

Here, i is the iteration number, \(\:{C}_{1}\) and \(\:{C}_{2}\) are cognitive variables, \(\:{rand}_{1}\), and \(\:{rand}_{2}\) indicate the random value generated between 0 and 1, \(\:v\) indicates velocity, and \(\:x\) indicates the position of the particle [37].

Table 1 Gain parameters of different controllers tuned by GA and PSO
Fig. 5
figure 5

Flow diagram of PSO [38]

Each particle in this technique maintains track of its locations in the issue space, related to the best option it has found. This is known as the \(\:{p}_{best}\). The global form of the particle swarm optimizer also keeps an eye on the general ideal value, which is another best value, and its position, attained so far by any particle in the group, is denoted by \(\:{g}_{best}\). The process by which the gain parameter of controllers is tuned using PSO is represented in Fig. 5. Similar to GA, ITAE is used here as the objective function to tune the gain parameters of both PID and SMC. In Table 1, the gain settings for both PID and SMC by GA and PSO are given.

Result and Analysis

Step input is used for evaluating DC motor performance. The testbed system shows outstanding performance when it is controlled by SMC. The performance is accessed concerning rise time, settling time, and percentage of overshoot, and they are presented in Table 2. To show the superiority of SMC, performance is compared with PID which is tuned by both GA and PSO, and with some recently published work. The GA-based SMC-controlled plant has a rise time of 0.0786 s and has a negligible overshoot. However, the PSO-based SMC-controlled DC motor has the lowest rise time of 0.0599 s and settling time of 0.1041 s, and the reason behind this is that PSO forces the system to converge more rapidly than GA. The system response is shown in Fig. 6, where two algorithms named GA and PSO are applied individually on controllers. With GA-based SMC, rise time improved by 88.78%, settling time improved by 94.26%, and overshoot improved by 100% concerning the PID controller.

Fig. 6
figure 6

Performance representation of DC motor under different optimization algorithms

Table 2 Performance matrices of DC motor

The gain parameters of controllers are tuned by GA and PSO algorithms, where ITAE is the objective function. Figure 7 represents the box plot of ITAE variation for different types of controllers. SMC shows the most stable performance, ITAE value is almost the same for both SMC and PID. The difference between GA-tuned SMC and PSO-tuned SMC is only 0.001662, on the other hand in the case of GA-tuned PID and PSO-tuned PID this difference is 0.1154 proving the robustness of SMC.

Fig. 7
figure 7

Box plot of ITAE value for different controllers

Stability Analysis

To understand the stability of the plant, the frequency response of the system under different controllers is presented. Both gain margin and phase margin are infinity for PID and SMC. A large gain.

margin (GM) and phase margin (PM) indicate that the system response is slower but more stable. The frequency response curve for the PID controller is depicted in Fig. 8 and the frequency response curve for the SMC is depicted in Fig. 9. In Fig. 9, a slight increase in magnitude (positive dB) indicates good tracking performance and the magnitude − 31 dB indicates SMC controlled DC motor is more stable. From both figures, it is obvious that the response of PID is slower than SMC, and SMC operates more stably than PID.

Fig. 8
figure 8

Frequency response of DC motor for PID controller (Input voltage to output speed)

Fig. 9
figure 9

Frequency response of DC motor for SMC controller (Input voltage to output speed)

Robustness Analysis of SMC

DC motor parameters can be changed due to tear and friction, dust, lubricant accumulation, etc. Hence a robust controller is needed so that the DC motor can perform constantly with uniform velocity, minimum overshoot, minimum rise time, and minimum settling time under parametric uncertainty, and external disturbances. This paper presents a robust controller named SMC and the robustness of SMC is investigated under 6 different cases.

The parameter of the testbed system controlled by GA-tuned SMC varied individually up to + 30% from their nominal values in the first case. In the next two cases (case_2 to case_3), two parameters are varied simultaneously up to the range between − 30% to + 40%. Case_4 represents the variation of three parameters simultaneously. On the other hand, case_5 considers four parameter variations where the variation is considered in the range between − 30% to + 50%. The very last case_6 represents five parameter variations and all cases are recorded in Table 3. The same parametric uncertainty is also applied in the case of GA-tuned PID controller.

Table 3 Parameter variation of DC motor under different cases

Responses of the DC motor with GA-tuned PID and SMC for different cases (case_1 to case_6) along with the base response are represented in Figs. 10, 11, 12, 13, 14 and 15. The responses of the system by SMC and PID under case_1 and the nominal case are presented in Fig. 10. Where SMC is almost insensitive to the variation of armature resistance Rm. But in the case of PID settling time, the overshoot is reduced, and the rise time increases slightly. In case_2 armature resistance, Rm, and inertia constant j varied simultaneously with + 40% and − 30% respectively. Rise time has no change in this case for both PID and SMC, however, the settling time and percentage of overshoot are changed by a large value for the PID-controlled DC motor, which is depicted in Fig. 11. In case_3 armature inductance Lm is changed by -20% and torque constant Kt are changed by + 40% respectively and system performance under such variation is presented in Fig. 12. SMC shows stable performance by rise time and settling time but here slight increase in overshoot which is completely negligible in terms of PID. PID shows a variation in the rise time of 14.30%, a settling time of 15.54%, and an overshoot of 40.27%. The performance matrices under parametric variation are listed in Table 4. Case_4 is the representation of three parameter changes simultaneously within the range of -40% to + 40%. Settling time is delayed by 0.4415 seconds by PID controllers but in the case of SMC, it is only 0.0069 s proving the robustness of SMC again. The dynamic behavior of the system under case_4 is presented in Fig. 13. In case_5 highest parametric uncertainty is considered, where the variation is in between four parameters within the range of -30% to + 50%. The system performed abruptly, especially for PID which is depicted in Fig. 14. Percentage of overshoot is changed for PID controlled plant by 115.64%, settling time by 123.36%, and rise time by 38.83% which is alarming. In such a condition SMC continues its robust behavior with small changes in the percentage of overshoot and other performance matrices. In the last case (case_6), five parameters are changed simultaneously within the range of -40% to + 40%. The PID controllers settled plant output after 3.416 s with a significant steady-state error and SMC maintained its regular behavior which is presented in Fig. 15.

Table 4 Performance matrices of DC motor under different cases
Fig. 10
figure 10

Step response of the DC motor with PID and SMC under parameter variation, case_1

Fig. 11
figure 11

Step response of DC motor with PID and SMC under parameter variation, case_2

Fig. 12
figure 12

Step response of DC motor with PID and SMC under parameter variation, case_3

Fig. 13
figure 13

Step response of DC motor with PID and SMC under parameter variation, case_4

Fig. 14
figure 14

Step response of DC motor with PID and SMC under parameter variation, case_5

Fig. 15
figure 15

Step response of DC motor with PID and SMC under parameter variation, case_6

From Figs. 10, 11, 12, 13, 14 and 15, six different scenarios are presented by which a wide range of parametric uncertainty is applied to the testbed system, and the proposed SMC tuned by GA shows outstanding performance compared to the proposed PID tuned by GA and proves the robustness of the proposed SMC. From the analysis, the same pattern will be applicable in the case of PSO-tuned SMC and PSO-tuned PID also.

In Fig. 16, the control signals under different cases of SMC are presented. The nature of all signals is in the same pattern and these signals are settled within 0.15 s only. SMC always poses strong control over the plant and all the control signals under different cases followed the zero line after a short interval of time. On the other hand, the PID controller takes a longer time to settle and they never converge to zero which is presented in Fig. 17. Especially in case_5 there is a large undershoot, large steady-state error, and large settling time in the control signal. But in the case of SMC, the system goes to convergence after a strong effort of the control signal.

Fig. 16
figure 16

Control signal variation by SMC under different cases

Fig. 17
figure 17

Control signal variation by PID under different cases

Performance under Disturbance

This portion of the paper highlights the importance of disturbance rejection in DC motor control. To prove the further robustness of SMC, a random disturbance in Fig. 18 is applied to the DC motor. The key result is in Fig. 19, which supposedly demonstrates the motor’s response under each control method. The finding argues that the SMC exhibits superior performance by being “insensitive” to the disturbance. This likely translates to steadier motor operation compared to the PID controller. The PID-controlled DC motor shows a significant drop (undershoot) and a persistent difference from the desired value (steady-state error).

Fig. 18
figure 18

Random disturbance applied to the plant

Fig. 19
figure 19

DC motor response subjected to disturbances

Hardware Validation

The transfer function of the hardware model of the DC motor is designed using the system identification toolbox of MATLAB. With the interface of the Arduino Uno kit, the linearized transfer function is obtained as

$$\:\frac{\omega_m\left(s\right)}{V\left(s\right)}=\frac{537.5}{s^2+62s+483.4}$$
(14)

The experimental setup consists of a computer which is used for data analysis and programming, an Arduino Uno kit which is used as a microcontroller, an H-bridge converter to control the plant, a power supply, and the DC motor. The practical setup is presented in Fig. 20 for different controllers. The power adapter supplies electrical power to the DC motor. However, the magnitude of the voltage applied to the DC motor is also known as a control input that is controlled by an H-bridge converter module (L298N) that produces a Pulse Width Modulation (PWM) signal. This paper used two different controllers namely PID and SMC. The gain parameters of these controllers are tuned by GA. The reference speed is 205 RPM and controllers are designed based on the system Eq. (14). The performance of the speed tracking in the simulation platform is presented in Fig. 21 and in practical setup is presented in Fig. 22.

Fig. 20
figure 20

Hardware setup for controlling the speed of the DC motor

Fig. 21
figure 21

Speed tracking of DC motor in Simulation platform

Fig. 22
figure 22

Speed tracking of DC motor for practical setup

Although both control methods (PID and SMC) appear to track the reference speed to some extent, however, there are almost similar characteristics for both the simulation and hardware platform in their performances. In the simulation, the rise time with PID is 0.2 s and with SMC it is 0.125 s. A similar result is obtained in the hardware platform where the rise time and settling time are less with SMC compared to the PID controller. However, in the hardware platform in Fig. 22, the speed tracking line by SMC shows fewer or less severe fluctuations compared to the PID line, it suggests better disturbance rejection which is previously proved in the simulation platform. There is some notching in the output. The reason behind this is the hardware setup of the DC motor is such that it faces disturbance after some time interval and the SMC-controlled DC motor shows robust behavior again. A similar output is obtained in Sect. “Performance under Disturbance”. The SMC-controlled DC motor setup shows low chattering in speed-tracking, robustness, and less settling time, less percentage of overshoot.

Conclusion and Future Work

This paper presents a simple reduced chattered sliding mode controller (SMC) which is tuned by both genetic algorithm (GA) and particle swarm optimization (PSO) for the speed control of the DC motor. The performance matrices are compared with the proportional integral derivative (PID) controller to show the superiority of the SMC. The SMC reduces integral time absolute error to a large extent. Using GA-SMC rise time is improved by 85.28%, settling time by 93.63%, and percentage overshoot by 100% compared to GA-PID. In the case of PSO, these values are 87.41%, 93.33%, and 99.72% respectively. As the gain margin and phase margin of the plant tended to infinity, is an indication of stable plant operation. The robustness of the SMC is proved under the variation of the parameters of the DC motor and performance under disturbances. Six different cases are considered to show the robustness of SMC under parametric uncertainty. The steady operation of the DC motor controlled by SMC under a random disturbance further proved the robustness of the SMC compared to PID. Also, the SMC outperformed PID in the practical implementation. Therefore, the researchers can offer a solution directly applicable to industries where consistent motor performance is crucial.

In the future, researchers can explore the utilization of advanced optimization methods such as Differential Evolution Algorithm (DEA), Grey Wolf Optimization (GWO), and Flower Pollination Algorithm (FPA) in the process of adjusting parameters for the SMC. Assess their performance in terms of convergence speed, and solution quality in comparison to GA and PSO. Nowadays Rasberry pi become popular which can be implemented in the future and comparisons between different microcontrollers can be analyzed in the case of hardware implementation.