**6. Numerical experimentation and simulation examples**

#### **6.1 Position control system by an armature-controlled dc servo motor**

#### *6.1.1 Positioning system description*

The plant is an armature-controlled dc servo motor, the scheme of which is given in **Figure 9** [19].

In order to derive the state-space mathematical model from the physics of the motor, we first start by writing Kirchoff's voltage equation around the armature current:

$$e\_a(t) = i\_a(t)R\_a + K\_b \frac{d\theta\_m}{dt},\tag{67}$$

where *ea*ð Þ*t* is the armature input voltage to the dc amplifier that drives the motor, *ia*ð Þ*t* is the armature current, *Ra* is the armature resistance, *Kb* is a constant of proportionality called the back emf constant, or briefly, the armature constant, and *θ<sup>m</sup>* is the angular displacement of the armature.

The torque, *Tm*ð Þ*t* , delivered by the motor is expressed separately in relation to both the armature current and the load seen by the armature as follows:

$$T\_m(t) = K\_l i\_a(t) = J\_m + \frac{d^2 \theta\_m}{dt^2} + D\_m \frac{d\theta\_m}{dt},\tag{68}$$

**Figure 9.** *DC motor schematic diagram.*

*An In-Depth Analysis of Sliding Mode Control and Its Application to Robotics DOI: http://dx.doi.org/10.5772/intechopen.93027*

where *Jm* and *Dm* both represent the equivalent inertia and viscous damping seen by the armature, respectively. Solving Eq. (68) for *ia*ð Þ*t* and substituting the result into Eq. (67) yields

$$
\varepsilon\_d(t) = \left(\frac{R\_d I\_m}{K\_t}\right) \frac{d^2 \theta\_m}{dt^2} + \left(\frac{D\_m R\_d}{K\_t} + K\_b\right) \frac{d\theta\_m}{dt}.\tag{69}
$$

Defining the state variables *x*<sup>1</sup> and *x*<sup>2</sup> as

$$
\infty\_1 = \theta\_m,\tag{70}
$$

$$
\omega\_2 = \frac{d\theta\_m}{dt},
\tag{71}
$$

and substituting into Eq. (69), we get

$$
\sigma\_a(t) = \left(\frac{R\_d J\_m}{K\_l}\right) \frac{d\varkappa\_2}{dt} + \left(\frac{D\_m R\_d}{K\_l} + K\_b\right) \varkappa\_2. \tag{72}
$$

Solving for *dx*2*=dt* yields

$$\frac{d\mathbf{x}\_2}{dt} = \frac{-1}{J\_m} \left( D\_m + \frac{K\_t K\_b}{R\_a} \right) \mathbf{x}\_2 + \left( \frac{K\_t}{R\_d J\_m} \right) \mathbf{e}\_a(t). \tag{73}$$

Using Eqs. (70), (71) and (73), the state equations are written as

$$\frac{d\mathbf{x}\_1}{dt} = \mathbf{x}\_2 \tag{74}$$

$$\frac{d\mathbf{x}\_2}{dt} = \frac{-\mathbf{1}}{J\_m} \left( D\_m + \frac{K\_t K\_b}{R\_d} \right) \mathbf{x}\_2 + \left( \frac{K\_t}{R\_d J\_m} \right) e\_a(t) \tag{75}$$

Hence, in vector-matrix form,

$$\dot{\mathbf{x}}(t) = \begin{bmatrix} 0 & 1\\ 0 & \frac{-1}{J\_m} \left( D\_m + \frac{K\_t K\_b}{R\_d} \right) \end{bmatrix} \mathbf{x} + \begin{bmatrix} 0\\ K\_t \\ \overline{R\_d J\_m} \end{bmatrix} e\_a(t).$$

Now, let us consider a position control system and assume a case of varying external disturbance torque to the dc motor. In other words, we assume that a varying external disturbance can enter into the system in the form of varying torque *τ*ð Þ*t* on the shaft of the motor. Therefore, in this derivation, taking account of the external disturbance term which will appear as an extra term in the state equation, we finally describe the state-space representation (a.k.a. the state differential equation) as follows:

$$
\dot{\mathbf{x}}(t) = \begin{bmatrix} \dot{\mathbf{x}}\_1(t) \\ \dot{\mathbf{x}}\_2(t) \end{bmatrix} = \begin{bmatrix} \mathbf{0} & \mathbf{1} \\ \mathbf{0} & -a \end{bmatrix} \begin{bmatrix} \boldsymbol{\varkappa}\_1(t) \\ \boldsymbol{\varkappa}\_2(t) \end{bmatrix} + \begin{bmatrix} \mathbf{0} \\ \boldsymbol{\varkappa} \end{bmatrix} e\_d(t) - \begin{bmatrix} \mathbf{0} \\ \boldsymbol{\varkappa} \end{bmatrix} \boldsymbol{\tau}(t), \tag{76}
$$

where *<sup>x</sup>*ðÞ¼ *<sup>t</sup>* ð Þ *<sup>x</sup>*1ð Þ*<sup>t</sup> <sup>x</sup>*2ð Þ*<sup>t</sup> <sup>T</sup>* has as components the angular position *<sup>x</sup>*1ð Þ*<sup>t</sup>* and the angular velocity *<sup>x</sup>*2ð Þ*<sup>t</sup>* and where *<sup>α</sup>* <sup>≜</sup> <sup>1</sup> *Jm Dm* <sup>þ</sup> *KtKb Ra* � � and *<sup>κ</sup>* <sup>≜</sup> *Kt RaJm* , and *γ* ¼ 1*=J*, with *J* the moment of inertia of all the rotating parts. For the controller variable we choose the angular position:

$$
\mathfrak{x}\_1(t) = (\mathfrak{1}, \mathfrak{0})\mathfrak{x}(t). \tag{77}
$$

The numerical values of motor's parameters have been taken from the case study in [20]:

$$a = 4.6 \, s^{-1},$$

$$\kappa = 0.787 \, rad/(Vs^2), \eta = 0.1 \, kg^{-1} m^{-2}.$$

Finally, we try several varying external disturbance torque ð Þ *Nm* options such as


as examples, and we decide that the torque of *τ*ðÞ¼ *t sin*ð Þ 3*t Nm* is the one we choose for the numerical experimentation and simulations as trade-off after we weigh the pros and cons upon several performance tests and considerations. In addition, the simulations given for the DC motor have been run in the form of script code using Matlab [21].

#### *6.1.2 Design of the sliding mode controller for the position control system*

Sliding mode surface is defined as:

$$\dot{s}(t) = c\varepsilon(t) + \dot{e}(t),\tag{78}$$

where *e t*ðÞ¼ *r t*ðÞ� *x*1ð Þ*t* , *e t* \_ðÞ¼ *r t* \_ðÞ� *x*2ð Þ*t* , and *r t*ð Þ is a desired input signal and defined as *r t*ðÞ¼ *Asin*ð Þ 2*πFt* in the simulations where *A* and *F* are suitably determined, and *c* is a positive constant. Therefore, once we get a derivative of the expression above, we get the following:

$$
\dot{s}(t) = c\dot{e}(t) + \ddot{e}(t) = c\dot{e}(t) + \ddot{r}(t) - \dot{\varkappa}\_2(t).
$$

Taking the second row from Eq. (76) and replacing it with *x*\_ <sup>2</sup>ð Þ*t* above yields:

$$
\dot{s}(t) = c\dot{e}(t) + \ddot{r}(t) + a\varkappa\_2(t) - \varkappa e\_a(t) + \chi\tau(t). \tag{79}
$$

Next, we obtain the control law *ea*ð Þ*t* by equalizing *s t* \_ð Þ to zero and then using *γ* ¼ 1*=J* and *τ*ðÞ¼ *t Ksgn s t* ð Þ ð Þ in Eq. (79) as follows:

$$\mathbf{e}\_a(t) = \frac{1}{\kappa} [c\dot{\mathbf{e}}(t) + \ddot{r}(t) + a\mathbf{x}\_2(t) + \frac{\mathbf{K}\text{sgn}(s(t))}{J}].\tag{80}$$

Once Eq. (80) is substituted into Eq. (79), we obtain the following:

$$\dot{s}(t) = \frac{\pi(t)}{J} - \frac{\text{Ksgn}(s(t))}{J}. \tag{81}$$

where *K* is a positive constant. Letting *K* ¼ *max* ð Þþ j j *τ*ð Þ*t ηJ*, where *η*> 0, and multiplying (81) by *s t*ð Þ yields:

*An In-Depth Analysis of Sliding Mode Control and Its Application to Robotics DOI: http://dx.doi.org/10.5772/intechopen.93027*

$$s(t)\dot{s}(t) = \frac{\tau(t)}{J}s(t) - \frac{\max\left(|\tau(t)|\right) + \eta J}{J}|s(t)|,$$

Here, the following can always be written:

$$s(t)\dot{s}(t) = \frac{\tau(t)}{J}s(t) - \frac{\max\left(|\tau(t)|\right)}{J}|s(t)| - \eta|s(t)| \le -\eta|s(t)|.\tag{82}$$

**Remark 6.** It is not difficult to briefly demonstrate the validity of the inequality (82) from a practical point of view: if *s t*ð Þ is greater than zero (i.e., *s t*ð Þ>0), then *Z* term, which we define as *<sup>τ</sup>*ð Þ*<sup>t</sup> <sup>J</sup> s t*ðÞ� *max* ð Þ j j *<sup>τ</sup>*ð Þ*<sup>t</sup> <sup>J</sup>* j j *s t*ð Þ from (82), becomes less than zero (i.e., *Z term* <0); because *max* ð Þ j j *<sup>τ</sup>*ð Þ*<sup>t</sup> <sup>J</sup>* j j *s t*ð Þ <sup>&</sup>gt; *<sup>τ</sup>*ð Þ*<sup>t</sup> <sup>J</sup> s t*ð Þ. Since the larger term has a negative sign, the difference between the terms will also be negative. As a result, <sup>ð</sup>*some negative term*Þ � *<sup>η</sup>*j j *s t*ð Þ <sup>≤</sup> � *<sup>η</sup>*j j *s t*ð Þ is always valid and correct. If *s t*ð Þ<0, then *<sup>τ</sup>*ð Þ*<sup>t</sup> <sup>J</sup> s t*ð Þ<0; in addition, � *max* ð Þ j j *<sup>τ</sup>*ð Þ*<sup>t</sup> <sup>J</sup>* j j *s t*ð Þ |ffl{zffl} >0 <0, therefore the addition of two negative

terms will make the overall addition more negative; hence, ð*more negative term*Þ � *η*j j *s t*ð Þ ≤ � *η*j j *s t*ð Þ which means that the inequality is still valid and in the right direction. Therefore, <sup>1</sup> 2 *d dt s* <sup>2</sup> ð Þ ð Þ*<sup>t</sup>* <sup>≤</sup> � *<sup>η</sup>*j j *s t*ð Þ .

In order to decrease the chattering phenomenon caused by sliding mode control law, saturation function is adapted in this work, and the controller becomes

$$e\_a(t) = \frac{1}{\kappa} \left[ c\dot{e}(t) + \ddot{r}(t) + a\mathbf{x}\_2(t) + \frac{K}{J} \underbrace{sat(s(t), \rho)}\_{} \right],\tag{83}$$

where saturation function *sat s t* ð Þ ð Þ, *φ* is defined as,

$$\text{satt}(\mathbf{s}(t), \boldsymbol{\varrho}) = \begin{bmatrix} \mathbf{s}(t) \\ \boldsymbol{\varrho} \\ \operatorname\*{sgn}(\mathbf{s}(t)) | \boldsymbol{\varrho}(t) | > \boldsymbol{\varrho} \end{bmatrix}, \tag{84}$$

where *φ* is a very small positive constant (**Figures 10**–**18**).

Let us also see how the results will change if PID control is used as an alternative to the SMC. Although, in the comparisons given in the literature, the pros and cons of both strategies are mentioned, it is generally observed that SMC performs better than PID [22–25]. Nevertheless, PID control can still be used as an alternative to SMC. The results given here do not contradict the view that one can use it instead of the other without losing too much performance. In the case where only the PD control strategy is applied, let us state that we need to emphasize the following points for the tracking error performance indicated by **Figure 19**.

We can prefer PD control strategy mostly to advance faster between intermediate points of the entire trajectory, i.e. from waypoint to waypoint at which course is changed for following a reference trajectory in which we have to move end-effector along a predefined path. Speaking of which, the end-effector is crucial for the entire trajectory tracking problem in catching up a desired position within shortest time. In other words, accuracy is highly desirable for the end-effector to be positioned accurately under unknown disturbances and payload variations. Basically, the desired position is a function of time and continuously changes with respect to time. Therefore, conventional PD control strategy does not always exhibit good accuracy and robustness properties for trajectory tracking problem. However, we can still

**Figure 10.** *Position tracking under SMC of the position control system.*

**Figure 11.** *Speed tracking under SMC of the position control system.*

choose the PD control strategy because of the advantages it offers [26]. We should emphasize that the errors between the actual points and the waypoints, each of which can also be viewed as intermediate setpoints, do not necessarily have to be eliminated completely. As a result, we have decided to use the PD control because of the advantages it offers and to move faster between the waypoints by tolerating or neglecting the steady-state error computations that would bring extra computational burden (**Figures 20**–**22**).
