You are on page 1of 12

European Journal of Control 50 (2019) 176–187

Contents lists available at ScienceDirect

European Journal of Control


journal homepage: www.elsevier.com/locate/ejcon

Real-time implementation and analysis of a modified energy based


controller for the swing-up of an inverted pendulum on a cartR
Emese Kennedy, Ethan King, Hien Tran∗
Department of Mathematics, NC State University, Box 8205, Raleigh, NC 27695, USA

a r t i c l e i n f o a b s t r a c t

Article history: In this paper we derive a modified energy based swing-up controller using Lyapunov functions. During
Received 13 March 2018 the derivation, all effort has been made to use a more complex dynamical model for the single inverted
Revised 17 April 2019
pendulum (SIP) system than the simplified model that is most commonly used. We consider the elec-
Accepted 10 May 2019
trodynamics of the DC motor that drives the cart, and incorporate viscous damping friction as seen at
Available online 20 May 2019
the motor pinion. Furthermore, we use a new method to account for the limitation of having a cart-
Recommended by Prof. T Parisini pendulum system with a finite track length. Two modifications to the controller are also discussed to
make the method more appropriate for real-time implementation. One of the modifications improves ro-
Keywords:
Inverted pendulum bustness using a modified Lyapunov function for the derivation, while the other one incorporates viscous
Energy based control damping as seen at the pendulum axis. We present both simulation and real-time experimental results
Lyapunov functions implemented in MATLAB Simulink.
Real-time implementation
© 2019 Published by Elsevier Ltd on behalf of European Control Association.

1. Introduction The SIP control problem is composed of two tasks: the first task
is to swing-up the pendulum from its downward hanging position,
The swing-up and stabilization of a single inverted pendulum and the second task is to stabilize the pendulum around the ver-
(SIP) is a popular and challenging problem in nonlinear control tical upright position. These two tasks are usually accomplished
theory. It is popular because the shape and dynamics of the SIP using two separate controllers, however, there are a few existing
resemble many different real world systems, such as the ones in control methodologies that can handle both tasks without having
Fig. 1, thus the control methods used can be utilized in numerous to switch controllers [4]. Our novel stabilization controller was pre-
applications. The challenge in controlling the SIP arises because the viously published in [9] and [11]. We have also presented a swing-
equations of motion governing the system are inherently nonlinear up controller in [10]. Here, we will expand on our previous work
and because the upright position is an unstable equilibrium. Fur- by including a more in-depth derivation and analysis, as well as
thermore, the system is under-actuated as it has two degrees of two other swing-up controllers that led to the controller published
freedom, one for the cart’s horizontal motion and one for the pen- in [10].
dulum’s angular motion, but only the cart’s position is actuated,
while the pendulum’s angular motion is indirectly controlled.
In a laboratory setting, there are two main types of SIP systems: 1.1. Existing energy-based control methods
the rotary pendulum system, and the pendulum on a cart system.
The controllers for these two systems are similar, but they have One of the most popular control methods for swinging up the
different actuator dynamics. The greatest difference between the pendulum is where the control law is chosen such that the energy
two systems is that the pendulum on a cart system has a finite of the pendulum builds until reaching the upright equilibrium. This
track length that needs to be taken into account, especially dur- technique was originally proposed by Astrom and Furuta in 1996
ing swing-up. This paper only focuses on the controllers for a cart at the 13th International Federation of Automatic Control World
pendulum system. Congress [2]. Their revised paper that included the implementa-
tion of their method on a rotary pendulum was published in 20 0 0
[3]. Later, the method was adapted for a cart-pendulum system by
R
This research did not receive any specific grant from funding agencies in the
Angeli in [1], but without taking the finite length of the track into
public, commercial, or not-for-profit sectors.

Corresponding author. account. In [6,12,18,19] the use of energy based controllers for the
E-mail addresses: emi.kennedy@wgu.edu (E. Kennedy), eaking4@ncsu.edu pendulum on a cart system is discussed. Control methods that con-
(E. King), tran@ncsu.edu (H. Tran). sider the length of the track are presented in [5] and [7].

https://doi.org/10.1016/j.ejcon.2019.05.002
0947-3580/© 2019 Published by Elsevier Ltd on behalf of European Control Association.
E. Kennedy, E. King and H. Tran / European Journal of Control 50 (2019) 176–187 177

Fig. 1. Inverted pendulum like systems.

Table 1
Inverted pendulum model parameters.

Symbol Description Value

Mw Cart weight mass 0.37 kg


M Cart mass with extra weight 0.57 + Mw kg
Jm Rotor moment of inertia 3.90E-007 kg m2
Kg Planetary gearbox gear ratio 3.71
rmp Motor pinion radius 6.35E-003 m
Beq Equivalent viscous damping coefficient 5.4 N m s/rad
Mp Pendulum mass 0.230 kg
p Pendulum length from pivot to COG 0.3302 m
Ip Pendulum moment of inertia at its COG 7.88E-003 kg m2
Bp Viscous damping coefficient 0.0024 N m s/rad
g Gravitational constant 9.81 m/s2
Kt Motor torque constant 0.00767 N m/A
Km Back-electromotive-force constant 0.00767 V s/rad
Rm Motor armature resistance 2.6 

the second-order time derivatives of the position of the cart, x, and


the angle of the pendulum, α , are the two non-linear equations
Fig. 2. Single inverted pendulum diagram.

ẍ = − (I p + M p 2p )Beq x˙ − M p  p cos(α )B p α˙
Many of the published controllers have only been tested in sim-
ulations and not in real-time experiments [4]. As almost all simu-
− (M2p 3p + I p M p  p ) sin(α )α˙ 2
lations use a simplified model to represent the dynamics of the SIP, 
the observed experimental results are often very different from the
previously published simulation results. These simplified SIP mod-
+ (I p + M p 2p )Fc + M2p 2p g cos (α ) sin(α ) D (α ) (1)
els commonly used in simulations usually ignore the effects of fric-
tion, and often fail to incorporate some physical restrictions like and
the maximum deliverable voltage by the amplifier, the capacity of

the DC motor that drives the cart, and the finite track length [8].
α̈ = (M + M p )M p g p sin(α ) − (M + M p )B p (α˙ )
2. System dynamics
− M2p 2p sin(α ) cos(α )(α˙ )
2

2.1. System representation and notations



− M p  p cos(α )Beq (x˙ ) + M p  p cos(α )Fc D ( α ), (2)
Fig. 2 shows a diagram of the SIP mounted on a cart. The up-
ward pointing vertical position of the pendulum corresponds to an
angle of zero radians (i.e. α = 0 rad), and the counterclockwise ro- where D(α ) = (M + M p )I p + MM p 2p + M2p 2p sin2 (α ), and x and α
tation is defined to be positive (i.e. α˙ > 0). The displacement of are both functions of t. Furthermore, the driving force, Fc , gener-
the cart to the right is understood to be positive (i.e. x˙ > 0), as in- ated by the DC motor acting on the cart through the motor pinion
dicated by the Cartesian frame of coordinates presented in Fig. 2. is considered to be the single input to the system.
The model parameters and their values are provided in Table 1. Since in our real-time implementation the input is equal to the
cart’s DC motor voltage, Vm , we can use Kirchhoff’s voltage law and
the physical properties of our system to convert the driving force,
2.2. Equations of motion
Fc , to voltage input by deriving the relationship
Using Langrange’s method, while including the affects of fric-
Kg2 Kt Km (x˙ (t ) ) Kg Kt Vm
tion at the motor pinion and at the pendulum axis, with coeffi- Fc = − + . (3)
2
Rm rmp Rm rmp
cients Beq and Bp respectively, we have previously shown [8,9] that
178 E. Kennedy, E. King and H. Tran / European Journal of Control 50 (2019) 176–187

3. Controller design where Fai is the armature rotational inertial force acting on the cart
[15]. As seen at the motor pinion, Fai can be expressed as a func-
Here, we use the popular energy-based swing-up strategy, with tion of the armature inertial torque, Tai , thus
the dynamical model for the SIP system incorporating friction
Kg Tai
given by Eqs. (1) and (2) to construct a control while also con- Fai = . (12)
sidering the electrodynamics of the DC motor that drives the cart,
rmp
the limitation of having a cart-pendulum system with a finite track Now, applying Newton’s second law of motion to the shaft of the
length, and the maximum voltage which can be supplied to the cart’s DC motor yields
cart motor.
Jm θ̈m = Tai , (13)

3.1. Pendulum’s energy where θ m is the rotational angle of the motor shaft. Using the
mechanical configuration of the cart’s rack-pinion system and the
The total energy, E p , of the pendulum at its hinge is given by technical specifications from the Quanser IP02 User Manual [16], as
the sum of its rotational kinetic energy and its potential energy, so well as the study of the electrodynamics of a DC motor in [14] we
have
1
Ep = J p α˙ 2 + M p  p g(cos(α ) − 1 ), (4) θm =
Kg x
. (14)
2 rmp
where Jp , the pendulum’s moment of inertia at its hinge is defined
Then, we can substitute Eqs. (14) and (13) into (12) to obtain
as
 2 p Kg2 Jm ẍ
Mp 4 Fai = . (15)
Jp = r2 dr = M p 2p . (5) rmp
0 2 p 3
Note that the initial pendulum position, hanging straight down, has With the use of Eqa. (3) and (15), we can express (11) as
total energy negative, E p = −2M p  p g, while the upright position
   
Kg2 Jm Kg2 Kt Km Kg Kt Vm
has E p = 0. Our goal is to increase the energy of the pendulum un- M+ 2
ẍ = − Beq + 2
x˙ + . (16)
rmp Rm rmp Rm rmp
til it reaches the upright position, therefore we design a controller
to satisfy the condition Solving for ẍ results in
dE p Kg Kt rmpVm − (Kg2 Kt Km + Beq Rm rmp
2
)x˙
≥ 0. (6) ẍ = . (17)
dt Rm (Mrmp
2 + K2J )
g m
Differentiating (4) yields
Therefore, by substituting (17) into (10) and imposing the condi-
dE p 4 tion in (6), we obtain that our control input, Vm , must satisfy
= J p α˙ α̈ − M p  p g sin(α )α˙ = M p 2p α˙ α̈ − M p  p g sin(α )α˙ . (7)
dt 3
dE p
As derived in [10] and [8], the two Lagrange’s equations for our = M p  p α˙ cos(α )
dt
system can be written as  
Kg Kt rmpVm (Kg2 Kt Km + Beq Rm rmp
2
)x˙
  × − ≥ 0. (18)
2
Jm Kg Rm (Mrmp2 + K2J )
g m R m ( Mr 2 + K2J )
mp g m
M + Mp + 2
ẍ(t ) + M p  p sin(α (t ))α˙ (t )2
rmp
3.3. Lyapunov stability condition
− M p  p cos(α (t ))α̈ (t ) = Fc − Beq x˙ (t ), (8)

and A control to satisfy (18) can be constructed with the commonly


used candidate Lyapunov function
−M p  p cos(α (t ))ẍ(t )
1
4 L (X ) = (E p )2 , (19)
+ M p 2p α̈ (t ) − M p  p g sin(α (t )) = −B p α˙ (t ). (9) 2
3
where if the energy is increasing to 0, then (19) is decreasing to 0,
Then, using (9) and setting B p = 0 we can rewrite (7) as
therefore we consider the control criteria
dE p dL dE p
= M p  p α˙ cos(α )ẍ. (10) = Ep
dt dt dt
This is commonly done in swing-up control derivation, to simplify = E p M p  p α˙ cos(α )
the model by ignoring the effects of viscous damping at the pen-  
Kg Kt rmpVm (Kg2 Kt Km + Beq Rm rmp
2
)x˙
dulum axis. We first construct a control using this simplification × −
then we re-incorporate the term later for comparison.
Rm (Mrmp + Kg Jm )
2 2 Rm (Mrmp + Kg Jm )
2 2

≤ 0. (20)
3.2. Converting to voltage input Substituting the model parameter values provided in Table 1 into
(20) and simplifying yields the condition
In most swing-up derivations, the control input is taken to be
the acceleration of the cart, ẍ, but for our real-time implementa- E p α˙ cos(α )(Vm − 7.614x˙ ) ≤ 0, (21)
tion the control input is defined to be the voltage applied to the
cart Vm . Thus, we need to express ẍ in terms of Vm . We will do 3.4. Control law
this by considering Newton’s second law of motion together with
D’Alembert’s principle, To satisfy (21) we propose a novel control law of the form
 
Mẍ + Fai = Fc − Beq x˙ , (11) Vm (X ) = β|x˙ | −sign(E p α˙ cos(α )) + sg(X )eη|x| , (22)
E. Kennedy, E. King and H. Tran / European Journal of Control 50 (2019) 176–187 179

Based on the above cases, we obtain that β and η must satisfy


the condition

7.614 7.614
≤ β ≤ η|x| . (27)
eη|x| + 1 e −1

Moreover, we have to ensure that the commanded voltage does not


make the power amplifier go into saturation, so we must design
our control in a way that |Vm | < 10 V. This means that β and η
also have to satisfy

Fig. 3. Diagram representing how sg(X) is defined. The arrows indicate the direction
|β|x˙ |(−sign(E p α˙ cos(α )) + sg(X )eη|x| )| ≤ 10. (28)
of the cart’s displacement, while the number line indicates the cart’s position.
Based on technical specifications provided in [16] we can calculate
that the theoretical maximum velocity of the cart is x˙ = 1.075 m/s
where β and η are positive constants, sign represents the signum [8], which allows us to find a bound for (28) only in terms of β and
function, and the function sg(X) is defined as η. One particular choice for β and η that satisfies all of the above
 conditions is β = 4 and η = 0.9. Both our simulation and real-time
sg(X ) = 0.5 sign(x˙ ) − sign(x ) − sign(|x| − 0.25 )(sign(x˙ ) + sign(x )) , experimental results will be presented in the later sections of this
(23) paper, but first we consider two modifications to the control law
given by Eq. (22).
which will output ±1 depending on the position of the cart and di-
rection it is moving. The barrier function sg(X)eη|x| , with appropri-
ate η, has a small impact when the cart position is within the track
4. A more robust swing-up controller
limits but when near the boundary can ensure the sign of Vm will
be the same as the sign of sg(X) which will keep the cart within
4.1. Modified Lyapunov function
the track constraints. The total length of the track that the cart can
travel is 0.814 m, indicating that the cart’s horizontal displacement
Even though most publications on energy-based control meth-
in either direction must be less than 0.407 m (i.e. |x| < 0.407 m).
ods for the swing-up of the pendulum use the same Lyapunov
For safety reasons, the cart should not get too close to the end of
function we used in Eq. (19) for their derivation, in [13] Maeba
the track, thus sg(X) was defined in such a way that it switches
et al. point out that this function has several zeros aside from the
signs only when the cart’s displacement from the center is more
upright position. In fact, the pendulum’s energy given by (4), and
than 0.25 m and the direction of the cart’s displacement is towards
thus the Lyapunov function in (19), is zero every time the pendu-
either track end. Fig. 3 provides a graphical representation of how
lum’s angle and angular velocity satisfy
sg(X) is defined. Substituting (22) into (21) gives
  

E p α˙ cos(α ) β|x˙ | −sign(E p α˙ cos(α )) + sg(X )eη|x| − 7.614x˙ ≤ 0, (24) 3g(1 − cos(α ))
α˙ = ± . (29)
2 p
which can be rewritten as
  This means that the presented controller is not guaranteed to
β|x˙ | sg(X )E p α˙ cos(α )eη|x| − |E p α˙ cos(α )| ≤ 7.614x˙ E p α˙ cos(α ). swing the pendulum up since the energy will stop building once
(25) the desired zero energy is achieved. To fix this problem, we con-
sider the modified Lyapunov function presented in [13].
Then, dividing by |x˙ ||E p α˙ cos(α )| yields
 
β sign(E p α˙ cos(α ))sg(X )eη|x| − 1 L2 ( X ) =
1 2
E + k(1 − cos3 (α )), (30)
2 p
≤ 7.614sign(E p α˙ cos(α ))sign(x˙ ). (26)
Physically for our system, a positive input voltage means positive where k is a positive constant. Eq. (30) only has one zero, namely
cart displacement, therefore Vm and x˙ have the same sign. Further- the upright position with zero angular velocity (i.e. α = 0, α˙ = 0),
more, since we defined sg(X) to have the same sign as Vm , this and is strictly positive everywhere else. Differentiating (30) and
also means that sg(X) and x˙ must also have the same sign. Now, utilizing (20) we obtain the new Lyapunov condition
consider the possible sign combinations for E p α˙ cos(α ) and sg:
dL2
• Case 1: E p α˙ cos(α ) > 0 and sg(X ) = 1 (x˙ > 0) = E p M p  p α˙ cos(α )
dt
 
  7.614 Kg Kt rmpVm (Kg2 Kt Km + Beq Rm rmp
2
)x˙
β eη|x| − 1 ≤ 7.614 ⇒ β ≤ η|x| . × −
e −1 Rm (Mrmp 2 + K2J )
g m Rm (Mrmp 2 + K2J )
g m
• Case 2: E p α˙ cos(α ) > 0 and sg(X ) = −1 (x˙ < 0) 3
+ k cos(α ) sin(2α )α˙
  7.614 2
β −eη|x| − 1 ≤ −7.614 ⇒ β ≥ η|x| . ≤ 0. (31)
e +1
• Case 3: E p α˙ cos(α ) < 0 and sg(X ) = 1 (x˙ > 0)
Substituting the model parameter values provided in Table 1 into
  7.614 (31) yields the new condition
β −eη|x| − 1 ≤ −7.614 ⇒ β ≥ η|x| .
e +1
• Case 4: E p α˙ cos(α ) < 0 and sg(X ) = −1 (x˙ < 0)
E p α˙ cos(α )(Vm − 7.614x˙ ) + 12.28kα˙ cos(α ) sin(2α ) ≤ 0, (32)
  7.614 that the control input, Vm must satisfy to achieve Lyapunov
β eη|x| − 1 ≤ 7.614 ⇒ β ≤ η|x| .
e −1 stability.
180 E. Kennedy, E. King and H. Tran / European Journal of Control 50 (2019) 176–187

4.2. Modified control law • Case 4: E p α˙ cos(α ) < 0 and sg(X ) = −1


(i.e. want Vm < 0, x˙ < 0)
Consider a control law of the form   β | sin(2α )|
  β1 |x˙ | β2 − eη|x| + 3 <0
Vm (X ) = β1 |x˙ | −β2 sign(E p α˙ cos(α )) + sg(X )eη|x| |E p |
β3 sign(α˙ cos(α ))| sin(2α )| β3 | sin(2α )|
− , (33) ⇒ β1 > .
Ep |x˙ ||E p |(eη|x| − β2 )
where β 1 , β 3 , and η are positive constants, 1 > β 2 > 0. Note that The above cases all hold when the constants β 1 , β 2 , β 3 , and η
Eq. (33) is a modification of the previously presented control law satisfy
in (22). We use the same barrier function as defined in (22) and
derive conditions on the constants to achieve stability. Substituting β3 | sin(2α )|
β1 > . (40)
(33) into (32) gives |x˙ ||E p |(eη|x| − β2 )
 
 η| x|
 To avoid division by zero and bound the value of β 1 , we can satu-
E p α˙ cos(α ) β1 |x˙ | −β2 sign(E p α˙ cos(α )) + sg(X )e − 7.614x˙
rate the signals of E p and x˙ so that |E p | > δ1 and |x˙ | > δ2 for some
small positive constants δ 1 and δ 2 . Then, the condition (40) will be
−β3 |α˙ cos(α )|| sin(2α )| + 12.28kα˙ cos(α ) sin(2α )
satisfied when
≤ 0. (34)
β3
β1 ≥ . (41)
The above inequality is satisfied when δ1 δ2 (1 − β2 )
   
E p α˙ cos(α ) β1 |x˙ | −β2 sign(E p α˙ cos(α )) + sg(X )eη|x| − 7.614x˙ ≤ 0, Moreover, to avoid saturation of the power amplifier, the constants
(35) in (33) must be chosen so that |Vm | ≤ 10. One possible choice that
satisfies all conditions and yields satisfactory simulation results is
and β1 = 5.1, β2 = 0.5, β3 = 0.002, and η = 0.8. These constants were
−β3 |α˙ cos(α )|| sin(2α )| + 12.28kα˙ cos(α ) sin(2α ) ≤ 0 (36) calculated using k = 10−4 , δ1 = 0.001, and δ2 = 0.1.
are both satisfied. Based on our earlier conditions in (26) and (27),
we can obtain that (35) holds when 5. Incorporating viscous damping at the pendulum axis
7.614 7.614
≤ β1 ≤ η|x| . (37) The two swing-up methods presented so far in the previous
eη|x| + β2 e − β2 sections have accounted for viscous damping friction as seen at
Furthermore, inequality (36) is satisfied when the cart’s motor pinion, but they have ignored the effects of vis-
cous damping as seen at the pendulum axis. Though the effect of
β3 ≥ 12.28k. (38)
the viscous damping term, B p α˙ , in Eq. (9) is small, it is desirable
In addition to the conditions (37) and (38), the sign of Vm should for real-time experiments and some applications to use a more
be given by the value of sg(X) to make sure the cart avoids the complete model. In this section, we present another modification
edges of the track. Therefore, we must have for our previous swing-up controllers to include viscous damping
 at the pendulum axis. If we include the B p α˙ term from (9), then
 
sign β1 |x˙ | −β2 sign(E p α˙ cos(α )) + sg(X )eη|x| Eq. (10) becomes
 dE p
β3 sign(α˙ cos(α ))| sin(2α )| = M p  p α˙ cos(α )ẍ − B p α˙ 2 , (42)
− = sg(X ). (39) dt
Ep
which can be rewritten as
Now, consider the possible sign combinations for E p α˙ cos(α ) and
dE p
sg(X): = M p  p α˙ cos(α )
dt
• Case 1: E p α˙ cos(α ) > 0 and sg(X ) = 1
 
Kg Kt rmpVm (Kg2 Kt Km + Beq Rm rmp
2
)x˙
(i.e. want Vm > 0, x˙ > 0) × − − B p α˙ 2
Rm (Mrmp 2 + K2J )
g m Rm (Mrmp 2 + K2J )
g m
  β | sin(2α )|
β1 |x˙ | −β2 + eη|x| − 3 >0 (43)
|E p |
β3 | sin(2α )| using Eq. (17). Then, using the modified Lyapunov function given
⇒ β1 > . in (30), and adding the viscous damping term into the derivative,
|x˙ ||E p |(eη|x| − β2 )
we can modify (31) to obtain the new condition
• Case 2: E p α˙ cos(α ) > 0 and sg(X ) = −1
(i.e. want Vm < 0, x˙ < 0) dL2
= E p M p  p α˙ cos(α )
  β | sin(2α ) dt
 
β1 |x˙ | −β2 − eη|x| − 3 <0 Kg Kt rmpVm (Kg2 Kt Km + Beq Rm rmp
2
)x˙
|E p | × −
Rm (Mrmp 2 + K2J ) Rm (Mrmp 2 + K2J )
β3 | sin(2α )| g m g m
⇒ β1 > − . 3
|x˙ ||E p |(eη|x| + β2 ) + k cos(α ) sin(2α )α˙ − E p B p α˙ 2
2
• Case 3: E p α˙ cos(α ) < 0 and sg(X ) = 1
≤ 0. (44)
(i.e. want Vm > 0, x˙ > 0)
  β | sin(2α )| Substituting the model parameter values provided in Table 1 into
β1 |x˙ | β2 + eη|x| + 3 >0 (44), and simplifying yields the condition
|E p |
β3 | sin(2α )| E p α˙ cos(α )(Vm − 7.614x˙ )
⇒ β1 > − .
|x˙ ||E p |(eη|x| + β2 ) + 12.28kα˙ cos(α ) sin(2α ) − 0.0197E p α˙ 2 ≤ 0, (45)
E. Kennedy, E. King and H. Tran / European Journal of Control 50 (2019) 176–187 181

that our modified controller must satisfy to guarantee Lyapunov Table 2


Summary of simulated state response.
stability. To account for the effect of the damping term, consider
the control law of the form Method |x|max (m) |x˙ |max (m/s) |α|
˙ max (deg/s)
 
Vm (X ) = β1 |x˙ | −β2 sign(E p α˙ cos(α )) + sg(X )eη|x| Energy based controller (22) 0.29 0.897 583
First modified controller (33) 0.269 0.701 570
β3 sign(α˙ cos(α ))| sin(2α )|
− + 0.0197sign(E p )α˙ cos α , Final modified controller (46) 0.146 0.724 564
Ep
(46) Table 3
which is just a modification of (33) with positive constants, β 1 , Summary of simulated control effort and swing-up time.

β 3 , η, and 0 < β 2 < 1. Substituting (46) into (45), and simplifying Method Swing-up time (s) |Vm |max (V) |Vm |avg (V)
results in Energy based controller (22) 55 7.64 0.83
 
  First modified controller (33) 40 5.57 0.978
E p α˙ cos(α ) β1 |x˙ | −β2 sign(E p α˙ cos(α )) + sg(X )eη|x| − 7.614x˙ Final modified controller (46) 28 8 0.68

−β3 |α˙ cos(α )|| sin(2α )| + 12.28kα˙ cos(α ) sin(2α )


−0.0197 sin (α )|E p |α˙ 2
2
6. Simulation results
≤ 0. (47)
As before, the inequality in (47) is satisfied when both (37) and All three of the presented swing-up controllers were tested in
(38) hold for the constants. Furthermore, we must make sure that simulation using Simulink in MATLAB, as is common with energy
sign(Vm (X )) = sg(X ). Now, consider the possible sign combinations based methods only Lyapunov stability is guaranteed for the con-
for E p α˙ cos(α ) and sg: trollers, however a locally asymptotically stable feedback controller
can be used once the state is near the upright equilibrium. The
• Case 1: E p α˙ cos(α ) > 0 and sg(X ) = 1 simulated controllers are considered to have swung up the pen-
(i.e. want Vm > 0, x˙ > 0) dulum when the angle is within 15◦ of the upright position, the
  β | sin(2α )| switch to a stabilization controller is not included in the simu-
β1 |x˙ | −β2 + eη|x| − 3 + 0.0197|α˙ cos α| > 0
|E p | lations. Since the starting downward position of the pendulum is
β3 | sin(2α )| 0.0197|α˙ cos(α )| a stable equilibrium we must input some initial voltage to get
⇒ β1 > − the experiment started. The starting voltage for our simulation
|x˙ ||E p |(eη|x| − β2 ) |x˙ |(eη|x| − β2 )
was 8 V that was applied for 0.1 s. The resulting state responses
• Case 2: E p α˙ cos(α ) > 0 and sg(X ) = −1 are graphed in Figs. 4–7 with the corresponding control efforts
(i.e. want Vm < 0, x˙ < 0) presented in Fig. 8. The dashed blue lines in Fig. 5 indicate the
  β | sin(2α ) region where the stabilization control can take over (i.e. where
β1 |x˙ | −β2 − eη|x| − 3 + 0.0197|α˙ cos α| < 0
|α | < 15◦ ) [8]. A numerical summary comparing the three simu-
|E p |
lations is given in Tables 2 and 3. All three swing-up controllers
β3 | sin(2α )| 0.0197|α˙ cos(α )|
⇒ β1 > − + . successfully brought the pendulum angle within 15◦ of the upright
|x˙ ||E p |(eη|x| + β2 ) |x˙ |(eη|x| + β2 ) position, while the values of the states and the required control
• Case 3: E p α˙ cos(α ) < 0 and sg(X ) = 1 effort stayed within the possible ranges deliverable by the appa-
(i.e. want Vm > 0, x˙ > 0) ratus we use for real time experiments. Fig. 4 indicates that the
  β | sin(2α )| cart did not go past the end of the track in any of the simulations
β1 |x˙ | β2 + eη|x| + 3
|E p | (i.e. the value of |x| stayed below 0.407 m). The original energy
based controller from Eq. (22) was the slowest at swinging up the
−0.0197sign(E p )α˙ cos α > 0
pendulum, taking approximately 55 s, followed by the first modi-
0.0197|α˙ cos(α )| β3 | sin(2α )| fied controller from Eq. (33), which took approximately 40 s. The
⇒ β1 > −  .
|x˙ |(β2 + eη|x| ) |x˙ ||E p | β2 + eη|x| final modified controller from Eq. (46) was by far the fastest at
swinging up the pendulum, taking only 28 s. Furthermore, this fi-
• Case 4: E p α˙ cos(α ) < 0 and sg(X ) = −1
nal controller used the least amount of voltage on average (using
(i.e. want Vm < 0, x˙ < 0)
only 0.68 V). The original energy based controller used 0.83 V on
  β | sin(2α )|
β1 |x˙ | β2 − eη|x| + 3 − 0.0197sign(E p )α˙ cos α < 0 average, which is less than the average of 0.978 V used by the first
|E p | modified controller. The simulations suggest that the application of
a robust Lyapunov function and accounting for the affects of fric-
β3 | sin(2α )| 0.0197|α˙ cos(α )|
⇒ β1 > − . tion can allow for faster swing-up times with less control effort, as
|x||E p |(e − β2 )
˙ η| x | |x˙ |(eη|x| − β2 ) well as indicate that the barrier function term in the control can
The above cases all hold when the constants β 1 , β 2 , β 3 , and η maintain the cart within the track limits without overriding state
satisfy inputs to the control at interior positions.
β3 | sin(2α )| 0.0197|α˙ cos(α )|
β1 > − (48)
|x˙ ||E p |(eη|x| − β2 ) |x˙ |(eη|x| − β2 ) 7. Real-time implementation
and
0.0197|α˙ cos(α )| β3 | sin(2α )| 7.1. Apparatus
β1 > −  . (49)
|x˙ |(β2 + eη|x| ) |x˙ ||E p | β2 + eη|x| The apparatus used in our real-time experiments was designed
Just as before, we must again choose β 1 , β 2 , β 3 , and η in a way to and provided by Quanser Consulting Inc. (119 Spy Court Markham,
ensure that the amplifier does not go into saturation (i.e. |Vm | ≤ 10). Ontario, L3R 5H6, Canada). This includes a single inverted pendu-
A particular choice of constants that will satisfy all conditions for lum mounted on an IP02 servo plant (depicted in Fig. 9), a VoltPAQ
the new controller in (46) is β1 = 4.8, β2 = 0.6, β3 = 0.0115, and amplifier, and a Q2-USB DAQ control board. The IP02 cart incor-
η = 0.6. porates a Faulhaber Coreless DC Motor (2338S006) coupled with a
182 E. Kennedy, E. King and H. Tran / European Journal of Control 50 (2019) 176–187

Fig. 5. Simulated state response of the pendulum’s angle. (For interpretation of the
Fig. 4. Simulated state response of the cart’s position. references to color in this figure, the reader is referred to the web version of this
article.)
E. Kennedy, E. King and H. Tran / European Journal of Control 50 (2019) 176–187 183

Fig. 7. Simulated state response of the pendulum’s angular velocity.


Fig. 6. Simulated state response of the cart’s velocity.
184 E. Kennedy, E. King and H. Tran / European Journal of Control 50 (2019) 176–187

Fig. 9. Single inverted pendulum mounted on a Quanser IP02 servo plant.

Fig. 10. Diagram of experimental setup.

power-series approximation of the Hamilton Jacobi Bellman Equa-


tion corresponding to the cost functional
 ∞
J= yT Qy + uT Ru dt,
0

where Q and R are fixed positive definite matrices, y = [x, α , x˙ , α˙ ]T


is the state vector governed by the SIP dynamics, and u is the input
voltage to the cart. Details for the derivation and computation of
the control can be found in [9,11] and [8]. For the experiments per-
formed here Q was the diagonal matrix with entries [800,150,1,1]
and R = [.1].

7.3. Experimental results

As seen in the simulation study the incorporation of friction


at the pendulum axis in the controller (46) markedly improved
performance over (33), so we consider only (22) and (46) here
for comparison in the real time experiments. The original energy
based controller from Eq. (22) and the final modified controller
Fig. 8. Simulated control effort. from Eq. (46) were both successfully implemented in real-time us-
ing Simulink and MATLAB with Quanser’s QuArc real-time control
software. The pendulum was considered upright when the angle
Faulhaber Planetary Gearhead Series 23/1. The cart is also equipped was within 15◦ of the upright position, at which point the power
with a US Digital S1 single-ended optical shaft encoder. The de- series based stabilization control took over. The real-time state re-
tailed technical specifications can be found in [16]. A diagram of sponse and the corresponding control effort are given in Fig. 11
our experimental setup is included in Fig. 10. for the original energy based controller from (22), and in Fig. 12
for the final modified controller from (46). A numerical summary
7.2. Stabilization control comparing the real-time performance of these two controllers is
given in Tables 4 and 5. The best swing-up time for the mod-
The stabilization controller used in the real time implementa- ified controller from (46) was only about 15 s, which is three
tion is a sub-optimal quadratic feedback control computed using a times faster than our best swing-up time for the original energy
E. Kennedy, E. King and H. Tran / European Journal of Control 50 (2019) 176–187 185

Fig. 11. Experimental state response and control effort using the energy based controller from Eq. (22).

Table 4 Table 5
Summary of experimental state response. Summary of experimental control effort and best swing-up time.

Method |x|max (m) |x˙ |max (m/s) |α|


˙ max (deg/s) Method Swing-up time (s) |Vm |max (V) |Vm |avg (V)

Energy based controller (22) 0.281 0.936 554 Energy based controller (22) 45 10 1.35
Final modified controller (46) 0.335 1.36 547 Final modified controller (46) 15 10 2.89
186 E. Kennedy, E. King and H. Tran / European Journal of Control 50 (2019) 176–187

Fig. 12. Experimental state response and control effort using the final modified controller from Eq. (46).

based controller from (22). The 15 s swing-up time is comparable reached the upper limit of 10 V on one occasion and had to be
to the swing-up time of the proportional-velocity controller pro- saturated.
vided by Quanser with our apparatus [17]. The modified controller We repeated the experiment with both controllers several
used 2.89 V on average while the original controller used only times. Even though we have been able to achieve successful swing-
1.35 V on average. For both controllers, the required control effort up using the original energy based controller from (22), this has
E. Kennedy, E. King and H. Tran / European Journal of Control 50 (2019) 176–187 187

not been the case for every experimental run. There have been [2] K.J. Astrom, K. Furuta, Swinging up a pendulum by energy control, in: Proceed-
some instances when instead of swinging up to the upright posi- ings of the 13th IFAC World Congress, E, 1996, pp. 37–42. San Francisco, CA
[3] K.J. Astrom, K. Furuta, Swinging up a pendulum by energy control, Automatica
tion, the pendulum ended up swinging back and forth at a con- 36 (20 0 0) 287–295.
stant rate without building up more energy. This is most likely [4] O. Boubaker, The inverted pendulum benchmark in nonlinear control theory:
caused by the issue with the Lyapunov function that we discussed a survey, Int. J. Adv. Robot. Syst. 10 (2013) 1–9.
[5] D. Chatterjee, A. Patra, H.K. Joglekar, Swing-up and stabilization of a cart-pen-
in Section 4. We did not experience this phenomena with our dulum system under restricted cart track length, Syst. Control Lett. 47 (2002)
modified controller from (46), but we did observe a wide range 355–364.
of swing-up times ranging between 15 and 40 s for that controller. [6] C.C. Chung, J. Hauser, Nonlinear control of a swinging pendulum, Automatica
31 (6) (1995) 851–862.
This inconsistency is likely caused by the way the function sg is
[7] C. Huifeng, L. Hongxing, Y. Peipei, Swing-up and stabilization of the inverted
defined. During the swing-up procedure the sg function causes the pendulum by energy well and sdre, in: Proceedings of Control and Decision
cart to make very fast big moves, and when the cart gets close Conference, CCDC ’09, IEEE, 2009, pp. 2222–2226.
[8] E. Kennedy, Swing-up and Stabilization of a Single Inverted Pendulum: Real–
to the end of the track the controller successfully makes the cart
Time Implementation, North Carolina State University, 2015 Ph.D. thesis.
move away from the edge with a quick jerking movement. Unfor- [9] E. Kennedy, H. Tran, Real-time implementation of a power series based non-
tunately, when the pendulum is near the upright position, this fast linear controller for the balance of a single inverted pendulum, in: Proceed-
jerk of the cart can overpower the movement of the pendulum, ings of International Multi Conference of Engineers and Computer Scientists,
IMECS, Vol I, Hong Kong, 2015, pp. 237–241. ISBN: 978–988–19253–2–9, ISSN:
and make the pendulum lose momentum. Making up this loss of 2078–0958 (Print); ISSN: 2078–0966 (Online)
momentum increases the swing-up time [8,10]. [10] E. Kennedy, H. Tran, Swing-up of an inverted pendulum on a cart using
a modified energy based approach, in: Proceedings of International Multi-
Conference of Engineers and Computer Scientists, IMECS, Hong Kong, Lec-
8. Conclusion ture Notes in Engineering and Computer Science, 2016a, pp. 185–190. ISBN:
978–988–19253–8–1, ISSN: 2078–0958 (Print); ISSN: 2078–0966 (Online)
We have presented and successfully implemented a new [11] E.A. Kennedy, H.T. Tran, Transactions on engineering technologies, Proceedings
of International MultiConference of Engineers and Computer Scientists, IMECS
energy-based swing-up controller that was derived using Lyapunov Springer.
functions based on the method originally proposed by Astrom [12] R. Lozano, I. Fantoni, D.J. Block, Stabilization of the inverted pendulum around
and Furuta [2,3]. We also introduced a novel barrier function to its homoclinic orbit, Syst. Control Lett. 40 (20 0 0) 197–204.
[13] T. Maeba, M. Deng, A. Yanou, T. Henmi, Swing-up controller design for inverted
make the swing-up method more appropriate for real-time im-
pendulum using energy method based on Lyapunov functions, in: Proceedings
plementation and demonstrated that the methodology can incor- of the 2010 International Conference on Modelling, Identification and Control,
porate a more detailed model of the SIP system than the mod- 2010, pp. 768–773. Okayama, Japan
[14] T.P. Pavlic, Rotary Electrodynamics of a dc Motor: Motor as Mechanical Capac-
els that are most commonly used in the literature. This detailed
itor, Department of Electrical and Computer Engineering, The Ohio State Uni-
model includes the electrodynamics of the DC motor that drives versity, 20 07–20 09. ECE 758: Control System Implementation Laboratory Notes
the cart, viscous damping friction as seen at the motor pinion, [15] Quanser Consulting, Inc., Linear Motion Servo Plants: IP01 or IP02 – Linear Ex-
and the viscous damping as seen at the pendulum axis. Further- periment #1: PV Position Control – Student Handout, 4th ed.
[16] Quanser Consulting, Inc., Linear Motion Servo Plants: IP01 or IP02 – IP01 and
more, we showed that accounting for friction can lead to improved IP02 User Manual, 5th ed.
performance with this methodology. Our final swing-up controller, [17] Quanser Consulting, Inc., Linear Motion Servo Plant: IP02 – Linear Experiment
given in Eq. (46), was able to swing the pendulum up in approxi- #6: PV and LQR Control – Student Handout, 4.1th ed.
[18] A. Siuka, M. Schoberl, Applications of energy based control methods for the
mately 15 s. However, the swing-up time of our final controller is inverted pendulum on a cart, Robot. Auton. Syst. 57 (2009) 1012–1017.
inconsistent. [19] J. Zhao, M.W. Spong, Hybrid control for global stabilization of the cart-pendu-
lum system, Automatica 37 (2001) 1941–1951.
References

[1] D. Angeli, Almost global stabilization of the inverted pendulum via continuous
state feedback, Automatica 37 (2001) 1103–1108.

You might also like