Sliding Mode Control of An Inverted Pendulum: Olfa Jedda, Jalel Ghabi and Ali Douik
Sliding Mode Control of An Inverted Pendulum: Olfa Jedda, Jalel Ghabi and Ali Douik
6.1 Introduction
Since the late 1970s, sliding mode control (SMC) has attracted a significant interest
from the control research community, and this is due to its insensitivity to model para-
metric uncertainties and external disturbances (Bandyopadhyay et al. 2009; Utkin
1977; Young et al. 1999). Indeed, the SMC design consists of two basic steps: select-
ing a stable sliding surface on the basis of control objectives and desired properties
of the closed loop system, and synthesizing a discontinuous control law in such a
way that the state trajectory of the system reaches the sliding surface in finite time
and then remains there (Bandyopadhyay et al. 2009; Bregeaut 2010). Yet, in practice
and in the presence of switching imperfections, the control cannot switch at a very
high frequency, and then the discontinuity in the control law yields to the so-called
chattering phenomenon.
This phenomenon can actuate disregarded high-frequency dynamics, degrade
system performances and even cause mechanical damages (Perruquetti and Bar-
bot 2002). In this regard, several approaches have been proposed in the literature
in order to overcome this problem such as the one proposed by Slotine and Sastry
(1983), which consists in substituting the signum function, origin of the discontinuity
in the control law, by a smooth function like saturation function (Hung et al. 1993;
Perruquetti and Barbot 2002; Slotine 1984; Slotine and Li 1991). Actually, the state
trajectory will evolve inside a thin boundary layer neighboring the switching surface
and then the chatter effect will be attenuated close to this surface.
Another approach, introduced by Levant (2003), the higher-order sliding mode
control (HOSMC), consists in constraining the state trajectory to reach in finite time
the sliding set defined by:
S r = x ∈ Rn : s = ṡ = s̈ = ... = s (r −1) = 0 (6.1)
In addition to the chatter elimination, HOSMC ensures a better accuracy and resolves
the problem of the restriction to a relative degree one, while preserving the main
features of the standard sliding mode (Levant 2003; Perruquetti and Barbot 2002). In
this study, only second-order sliding mode control (SOSMC) and specially twisting
and super-twisting algorithms (Emelyanov et al. 1996; Levant 1993; Perruquetti and
Barbot 2002; Shtessel et al. 2014) will be demonstrated for the control of the inverted
pendulum as a nonlinear and unstable system.
In Sect. 6.2, we represent the first order sliding mode theory. Section 6.3 is devoted
to second order sliding mode algorithms. In Sect. 6.4, Simulations results for both
first and second order sliding mode algorithms applied to the inverted pendulum will
be shown. Finally, concluding remarks will be given in Sect. 6.5.
Well known for its high accuracy and robustness against parametric variations and
external disturbances, the sliding mode control consists, by means of a discontinuous
control, in constraining the system states to reach, in finite time, and then to evolve
onto a sliding manifold defined by:
S = x ∈ Rn : s = 0 (6.2)
Hence, the design of SMC involves two major steps: the first is to select a stable
surface depending upon desired system dynamics, and the second is to synthesize
a control law so that the system state trajectory evolves onto the chosen surface
(Bregeaut 2010; Levant 2003).
6 Sliding Mode Control of an Inverted Pendulum 107
where x ∈ Rn is the state vector and u ∈ R is the control input. The control law of
the sliding mode controller is expressed as follows:
u = u eq + u d (6.4)
with u eq is the equivalent control and u d is the discontinuous control. Using the
equivalent control approach (DeCarlo et al. 1988; Gao and Hung 1992; Utkin 1992),
u eq is obtained by setting ṡ = 0. It ensures the maintain of the state trajectory onto
the switching surface s = 0 during the sliding mode (Bandyopadhyay et al. 2009;
Hung et al. 1993; Perruquetti and Barbot 2002).
For the system (6.3), the first time derivative of the sliding variable s = s (x) is
given by:
∂s
ṡ = ( f (x) + b (x) u) (6.5)
∂x
∂s
Assuming that ∂x b (x) is invertible, the equivalent control law is expressed by:
−1
∂s ∂s
u eq =− b (x) f (x) (6.6)
∂x ∂x
must be met in order to ensure a finite time convergence to the sliding surface. Hence,
the classic sliding mode control that satisfies the above condition is given by Riachy
(2008):
−1
∂s ∂s
u=− b (x) f (x) + k sign (s) (6.8)
∂x ∂x
Nevertheless, the discontinuity of the signum function in the vicinity of the sliding
surface s = 0 involves an infinite frequency commutation of the control law which
cannot exist in practice because of switching imperfections. This leads to the so-called
chattering phenomenon (Fig. 6.1) which can degrade performances of the controlled
system, excite disregarded high-frequency dynamics and even deteriorate the control
member.
To attenuate the chatter effect, several approaches were proposed in literature.
The main idea of the first approach is to substitute signum function by a continuous
one such as saturation function defined by:
s s
if ≤ 1
ϕ ϕ
sat(s, ϕ) = (6.11)
sign(s) if s > 1
ϕ
The continuous function will ensure the convergence of system state trajectory to a
thin boundary layer in the vicinity of the sliding surface. Consequently, the chatter
effect will be reduced to the detriment of optimum accuracy and robustness of sliding
mode.
The above restrictions were removed with the higher order sliding mode control
which satisfies a finite time convergence of not only the sliding variable to zero, but
also of a finite number of its time derivatives. In other words, for a relative degree
∂ (i) ∂ (r )
r > 1, i.e. ∂u s = 0 (i = [|1, r − 1|]) and ∂u s = 0, it is necessary to ensure, for
stability reasons, the following equalities:
s = ṡ = s̈ = · · · = s (r −1) = 0 (6.12)
Hence, HOSMC removes another drawback of classic sliding mode: the restriction
to a relative degree one. However, this will require an additional information about
the (r − 1) time derivatives of s. In what follows, only second order sliding mode
algorithms will be treated.
6 Sliding Mode Control of an Inverted Pendulum 109
The second order sliding mode controller consists on forcing the system state trajec-
tories to evolve in finite time onto the second order sliding set defined by:
S 2 = x ∈ Rn : s = ṡ = 0 (6.13)
∂ ṡ ∂ ṡ
s̈ = ( f (x) + b (x) u) + u̇ = α (x) + β (x) u̇ (6.15)
∂x ∂u
It is assumed that if |s (x)| < s0 then there are positive constants Φ, Γm and Γ M such
that
|α (x)| < Φ
(6.16)
0 < Γm ≤ β (x) ≤ Γ M
The twisting algorithm, one of the first known second order sliding mode algorithms,
ensures a finite time convergence of the state trajectory to the origin of the phase
plane (s, ṡ) after executing a certain number of rotations around it (Fig. 6.2), and this
is due to the commutation of the control between two values.
For a relative degree 1, the control algorithm is defined by the following control
law:
−u if |u| > u max
u̇ T w = −km sign(s) if s ṡ ≤ 0 and |u| ≤ u max (6.17)
−k M sign(s) if s ṡ > 0 and |u| ≤ u max
The sufficient conditions that ensure a finite time convergence to the second order
sliding set are:
4Γ M Φ
k M > km > 0, km > , km > , Γm k M − Φ > Γ M k m + Φ (6.18)
s0 Γm
110 O. Jedda et al.
Unlike twisting algorithm, this algorithm is only able to stabilize in finite time
(Fig. 6.3) systems whose relative degree is equal to one and then it does not require
information about the time derivative of the sliding variable.
The control law is given by:
Φ 4Φ Γ M (w + Φ)
w> , α2 ≥ , 0 < ρ ≤ 0.5 (6.20)
Γm Γm 2 Γm (w − Φ)
with:
such that M = 1 kg is the cart mass, m = 0.1 kg is the pendulum mass, l = 0.5 m is
the half length of the pendulum, g = 9.8 m/s2 is the acceleration of gravity (Wang
1994).
s = λ e + ė (6.22)
where e = x1 − xd1 is the tracking error and λ is a positive constant. The first time
derivative of s is:
ṡ = λ (x2 − ẋd1 ) + ( f − ẍd1 ) + b u
(6.23)
= h +bu
Using (6.8) and (6.23), the control law of the classic sliding mode controller is
expressed as:
u = −b−1 (h + k sign (s)) (6.24)
For simulation results, the design parameters are chosen as follows: λ = 5 and k =
π
18. The reference signal and the initial conditions are respectively xd1 = 30 sin t and
x0 = [0.2 0] . Thus, by applying the classic sliding mode to the inverted pendulum,
we obtain results shown in Fig. 6.5.
Figure 6.5 shows clearly the chattering phenomenon present in the control input.
Thus, in the next step, the signum function will be replaced by the saturation function
in order to attenuate the chatter effect.
Substituting the signum function by the saturation function defined in (6.11) in the
control law (6.24) yields to:
where ϕ is chosen to be equal to 0.5. Simulation results are shown in Fig. 6.6.
These results show the efficiency of this approach in reducing the chatter effect.
However, the existence of the boundary layer neighboring the sliding surface may
affect the main characteristics of the sliding mode control such as robustness.
Using (6.23), the second time derivative of the sliding function is given by:
...
s̈ = λ ( f + b u − ẍd1 ) + f˙ + ḃ u− x d1 + b u̇ = d + b u̇ (6.26)
(a) 15
10
5
0
u −5
−10
−15
0 1 2 3 4 5 6 7 8 9 10
Time (s)
(b) 0.2 x1
0.15 xd1
0.1
0.05
0
−0.05
−0.1
0 1 2 3 4 5 6 7 8 9 10
Time (s)
(c) 1
0.8
0.6
s
0.4
0.2
0
0 1 2 3 4 5 6 7 8 9 10
Time (s)
(d) 0.2 x2
0.1
0 xd2
−0.1
−0.2
−0.3
−0.4
−0.5
−0.6
−0.7
−0.8
0 1 2 3 4 5 6 7 8 9 10
Time (s)
Fig. 6.5 a Control input, b angular displacement, c sliding function, d angular velocity for classic
SMC
By fulfilling the necessary conditions (6.16) and the sufficient conditions (6.18), the
optimum value of km and k M , chosen after some trials, are respectively 7 and 35.
114 O. Jedda et al.
(a) 2
0
−2
−4
u −6
−8
−10
−12
−14
−16
0 1 2 3 4 5 6 7 8 9 10
Time (s)
(b) 0.2 x1
0.15 xd1
0.1
0.05
0
−0.05
−0.1
0 1 2 3 4 5 6 7 8 9 10
Time (s)
(c) 1
0.8
0.6
s
0.4
0.2
0 1 2 3 4 5 6 7 8 9 10
Time (s)
(d) 0.1
x2
0 xd2
−0.1
−0.2
−0.3
−0.4
−0.5
−0.6
−0.7
0 1 2 3 4 5 6 7 8 9 10
Time (s)
Fig. 6.6 a Control input, b angular displacement, c sliding function, d angular velocity for SMC
with saturation function
6 Sliding Mode Control of an Inverted Pendulum 115
(a) 1.5
1
0.5
0
u −0.5
−1
−1.5
−2
−2.5
−3
0 1 2 3 4 5 6 7 8 9 10
Time (s)
(b) 0.25 x1
0.2 xd11
0.15
0.1
0.05
0
−0.05
−0.1
0 1 2 3 4 5 6 7 8 9 10
Time (s)
(c) 1
0.8
0.6
0.4
s
0.2
0
−0.2
0 1 2 3 4 5 6 7 8 9 10
Time (s)
(d) x2
0.1
xd2
0
−0.1
−0.2
−0.3
−0.4
0 1 2 3 4 5 6 7 8 9 10
Time (s)
Fig. 6.7 a Control input, b angular displacement, c sliding function, d angular velocity for twisting
algorithm
116 O. Jedda et al.
−2
−4
−0.5 0 0.5 1
Figure 6.7 shows that the twisting Algorithm reduces the chattering phenomenon
while Fig. 6.8 shows that the system state trajectory converges to the origin of the
phase plane (s, ṡ).
Using (6.19) and (6.23), the control law for the super-twisting algorithm is given by:
In accordance with the conditions given in (6.16) and (6.20), and after performing
some simulations, we choose w = 8, α = 2 and ρ = 0.5.
Both Figs. 6.9 and 6.10 show that the super-twisting algorithm ensures a finite time
convergence of the system trajectory to the origin of the phase plane. In addition,
by comparing to Figs. 6.7a and 6.9a, we can conclude that super-twisting algorithm
is better than twisting algorithm with regards to the reduction of chattering effect in
the control input.
6.5 Conclusion
This paper has proposed some solutions to attenuate chattering phenomenon present
in classic sliding mode control. At first, a continuous approximation has been made
in the vicinity of the sliding surface by using the saturation instead of the signum
function. However, this introduces a boundary layer that may affect the main fea-
tures of sliding mode such as robustness. Then, a second order sliding mode control
algorithms: twisting and super-twisting algorithms, have been applied to the inverted
pendulum system. The simulations results have shown their efficiency in attenuating
chatter effect while ensuring a finite time convergence and high accuracy.
6 Sliding Mode Control of an Inverted Pendulum 117
(a) 1.5
1
0.5
0
−0.5
−1
u
−1.5
−2
−2.5
−3
−3.5
0 1 2 3 4 5 6 7 8 9 10
Time (s)
(b) 0.2
x1
xd1
0.15
0.1
0.05
0
−0.05
−0.1
0 1 2 3 4 5 6 7 8 9 10
Time (s)
(c) 1
0.8
0.6
0.4
s
0.2
0
−0.2
0 1 2 3 4 5 6 7 8 9 10
Time (s)
(d) 0.2 x2
0.1 xd2
0
−0.1
−0.2
−0.3
−0.4
0 1 2 3 4 5 6 7 8 9 10
Time (s)
Fig. 6.9 a control input, b angular displacement, c sliding function, d angular velocity for super-
twisting algorithm
118 O. Jedda et al.
References
Bandyopadhyay, B., Deepak, F., & Kim, K. (2009). Sliding mode control using novel sliding sur-
faces. Berlin: Springer.
Bregeaut, V. (2010). Quelques contributions a la theorie de la commande par modes glissants. Ph.D.
thesis, Central School of Nantes, Nantes, France.
DeCarlo, R. A., Zak, S. H., & Matthews G. P. (1988). Variable structure control of nonlinear
multivariable systems: A tutorial. Proceedings of the IEEE, 76, 212–232.
Edwards, C., Spurgeon, S. K. (1998). Sliding mode control: Theory and applications. London:
Taylor & Francis.
Emelyanov, S., Korovin, S., & Levant, A. (1996). High-order sliding modes in control systems.
Computational Mathematics and Modeling, 7, 294–318.
Gao, W., & Hung, J. (1992). Variable structure control of nonlinear systems: A new approach. IEEE
Transactions on Industrial Electronics, 40, 45–55.
Hung, J., Gao, W., & Hung, J. (1993). Variable structure control: A survey. IEEE Transactions on
Industrial Electronics, 40, 2–22.
Levant, A. (1993). Sliding order and sliding accuracy in sliding mode control. International Journal
of Control, 58, 1247–1263.
Levant, A. (2003). High-order sliding modes, differentiation and output-feedback control. Interna-
tional Journal of Control, 76, 924–941.
Perruquetti, W., & Barbot, J. (2002). Sliding mode control in engineering. New York: Marcel Dekker.
Riachy, S. (2008). Contribution a l’estimation et a la commande de systemes mecaniques sous-
actionnes. Ph.D. thesis, Central School of Lille, Lille, France.
Slotine, J. (1984). Sliding controller design for non-linear systems. International Journal of Control,
40, 421–434.
Slotine, J., & Sastry, S. (1983). Tracking control of non-linear systems using sliding surfaces, with
application to robot manipulators. International Journal of Control, 83, 465–492.
Slotine, J., & Li, W. (1991). Applied nonlinear control. New Jersey: Prentice Hall.
Utkin, V. (1977). Variable structure systems with sliding modes. IEEE Transactions on Automatic
Control, 22, 212–222.
Utkin, V. (1992). Sliding modes in control and optimization. Berlin: Springer.
Wang, L. (1994). A supervisory controller for fuzzy control systems that guarantees stability. IEEE
Transactions on Automatic Control, 39, 1845–1847.
Young, K., Utkin, V., & Ozguner, U. (1999). A control enginees guide to sliding mode control.
IEEE Transactions on Control Systems Technology, 7, 328–342.
Shtessel, Y., Edwards, C., Fridman, L., & Levant, A. (2014). Sliding mode control and observation.
New York: Springer.