You are on page 1of 103

A Comparative Study on Several Control

Strategies for Inverted Pendulum Systems

A Thesis Presented
By

Yizhu Li
to

The Department of Mechanical and Industrial Engineering

in partial fulfillment of the requirements


for the degree of

Master of Science
in the field of

Mechanical Engineering

Northeastern University
Boston, Massachusetts
April 2018
I

ABSTRACT

This research undertakes the design and development of a series of control strategies,
including Proportional-Integral-Derivative (PID), Linear-Quadratic-Regulator (LQR),
robust and adaptive control approaches, for an inverted pendulum appended to a
single-mass and inverted pendulum added to a double-mass system. The control
objective is to keep the pendulum in the upright position while the base mass moves
to a desired position. For this, the governing coupled equations of motion are first
derived using Newtonian technique. Then PID controllers are developed for each
system using and optimally tuned to arrive at the best gains for best control
performance. Moreover, LQR controllers are designed for these systems and
compared with PID controllers. Then, a hierarchical sliding mode control approach is
proposed as the third controller. The two coupled systems, i.e., inverted pendulum
appended to a single-mass and inverted pendulum added to a double-mass, can be
divided into two subsystems and three subsystems respectively, and the sliding
surface for each subsystem is then designed. According to the hierarchical structure,
the final control law is derived from a Lyapunov-based approach and stability
viewpoint. Lastly, an adaptive control strategy is presented to improve the
performance of the systems. Extensive simulation and experimental results are
provided to justify the comparative advantage of robust control and adaptive control
methods over traditional linear controllers such as PID and LQR techniques.
II

TABLE OF CONTENTS

1. INTRODUCTION...................................................................................................1
2. OVERVIWE............................................................................................................7
3. DYNAMIC MOLDING AND CONTROL OF INVERTED PENDULUM
SINGLE-MASS SYSTEM......................................................................................8
3.1. Dynamic Modeling of Inverted Pendulum Single-Mass System.....................9
3.2. Controllers Design..........................................................................................16
3.2.1. PID Control………….........................................................................16
3.2.2. Optimal Control……….......................................................................17
3.2.3. Robust Control……………................................................................22
3.2.4. Adaptive Control………….................................................................28
3.3. Experiment.....................................................................................................30
4. DYNAMIC MOLDING AND CONTROL OF INVERTED PENDULUM
DOUBLE-MASS SYSTEM..................................................................................37
4.1. Dynamic Modeling of Inverted Pendulum Double-Mass System..................38
4.2. Controllers Design..........................................................................................44
4.2.1. PID Control….……............................................................................44
4.2.2. Optimal Control…………...................................................................45
4.2.3. Robust Control…………....................................................................48
4.2.4. Adaptive Control………….................................................................55
4.3. Summary........................................................................................................56
5. DISCUSSIONS AND RESULTS.........................................................................57
6. FUTRUE WORK..................................................................................................59
7. REFERENCES......................................................................................................60
III

Appendix A. INVERTED PENDULUM SINGLE-MASS SYSTEM......................65


A.1. Electromechanical Parameter Values.........................................65
A.2. Dynamic Modeling.....................................................................66
A.3. PID Control of Inverted Pendulum Single-Mass System...........71
A.4. LQR Control of Inverted Pendulum Single-Mass System.........72
A.5. Robust Control of Inverted Pendulum Single-Mass System......74
A.6. Adaptive Control of Inverted Pendulum Single-Mass System..75
Appendix B. INVERTED PENDULUM DOUBLE-MASS SYSTEM....................77
B.1. Electromechanical Parameter Values.........................................77
B.2. Dynamic Modeling.....................................................................79
B.3. PID Control of Inverted Pendulum Double-Mass System.........87
B.4. LQR Control of Inverted Pendulum Double-Mass System........88
B.5. Robust Control of Inverted Pendulum Double-Mass System....92
B.6. Adaptive Control of Inverted Pendulum Double-Mass System ..94
IV

LIST OF TABLES

Table1 Major components in the experimental inverted pendulum single-mass


system..............................................................................................................30
Table 2 Nominal properties of coreless DC motor [32] ..............................................32
Table 3 Properties of planetary gearbox [32] ..............................................................32
Table 4 Properties of gantry encoders [32] .................................................................33
Table 5 Quanser Q4 Data acquisition PCI card I/O [32] .............................................33
Table 6 UPM-15-03 Power Modules [43] ...................................................................34
Table 7 Results……………………………………………………………………….58
Table A.1 Electromechanical parameter values of inverted pendulum single-mass
system........................................................................................................65
Table B.1 Electromechanical parameter values of inverted pendulum double-mass
system..........................................................................................................77
V

LIST OF FIGURES

Figure 1.1 Gantry Pendulum System.............................................................................1


Figure 1.2 Inverted Pendulum System...........................................................................2
Figure 1.3 Inverted Pendulum Double-Mass System.....................................................2
Figure 3.1 Inverted Pendulum Single-Mass system.......................................................9
Figure 3.2 DC Motor Schematic Diagram Relating Applied Voltage to Position of the
Motor Pinion Gear, 𝜃𝑝 [32] .........................................................................9

Figure 3.3 Linearized External and Inertial Forces and Moments Affecting the Cart
and Pendulum.............................................................................................10
Figure 3.4 Linearized External Forces and Moments Affecting the Pendulum...........11
Figure 3.5 Simulink Model of Inverted Pendulum Single-Mass System ....................14
Figure 3.6 PID Control of Inverted Pendulum Single-Mass System...........................17
Figure 3.7 MATLAB/PID Tuner to Find the Value of 𝐾𝑝 , 𝐾𝑖 and 𝐾𝑑 for Inverted

Pendulum Single-Mass system...................................................................17


Figure 3.8 Simulink Model of LQR Control for Inverted Pendulum Single-Mass
System........................................................................................................21
Figure 3.9 Simulation Result of LQR Controller for Inverted Pendulum Single-Mass
System........................................................................................................22
Figure 3.10 Simulink Model of Hierarchical Mode Control for Inverted Pendulum
Single-Mass System.................................................................................25

Figure 3.10a Simulink Model of 𝑢𝑒𝑞1 in Hierarchical Sliding Mode Control for

Inverted Pendulum Single-Mass System................................................26



Figure 3.10b Simulink Model of 𝑢𝑒𝑞2 in Hierarchical Sliding Mode Control for

Inverted Pendulum Single-Mass System................................................26


VI

Figure 3.10c Simulink Model of 𝑆2 in Hierarchical Sliding Mode Control for


Inverted Pendulum Single-Mass System................................................26
Figure 3.10d Simulink Model of SMC in Hierarchical Sliding Mode Control for
Inverted Pendulum Single-Mass System................................................26
Figure 3.11 Simulation Result of Robust Control for Inverted Pendulum Single-Mass
System......................................................................................................28
Figure 3.12 Simulation Result of Adaptive Control for Inverted Pendulum
Single-Mass System.................................................................................29
Figure 3.13 Experimental Inverted Pendulum Single-Mass System (Built on Quanser
IP02 and LFJ Platforms) .........................................................................30
Figure 3.14 IP02 Components......................................................................................31
Figure 3.15 Quanser Q4 PCI Data Acquisition Card [42] ..........................................33
Figure 3.16 Universal Power Module UPM-1503.......................................................34
Figure 3.17 Q4 Terminal Board....................................................................................35
Figure 3.18 Experimental Result of LQR Control for Inverted Pendulum Single-Mass
System……………..................................................................................35
Figure 3.19 Experimental Result of Robust Control for Inverted Pendulum
Single-Mass System.................................................................................36
Figure 3.20 Experimental Result of Adaptive Control for Inverted Pendulum
Single-Mass System.................................................................................36
Figure 4.1 Inverted Pendulum Double-Mass System...................................................37
Figure 4.2 Linearized External Forces Affecting the Passive Cart..............................38
Figure 4.3 Linearized External Force Affecting the Pendulum....................................39
Figure 4.4 Linearized External Forces Affecting the Active Cart................................40
Figure 4.5 Simulink Model of Inverted Pendulum Double-Mass System...................42
Figure 4.6 PID Control of Inverted Pendulum Double-Mass System..........................45
Figure 4.7 Using MATLAB/PID Tuner to Design a PID Controller for Inverted
Pendulum Double-Mass System................................................................45
Figure 4.8 Simulink Model of LQR Control for Inverted Pendulum Double-Mass
System........................................................................................................47
VII

Figure 4.9 Inverted Pendulum Double-Mass System Response of LQR Control........48


Figure 4.10 Simulink Model of Hierarchical Sliding Mode Control for Inverted
Pendulum Double-Mass System..............................................................51

Figure 4.10a Simulink Model of 𝑢𝑒𝑞1 in Hierarchical Sliding Mode Control for

Inverted Pendulum Double-Mass System..............................................52



Figure 4.10b Simulink Model of 𝑢𝑒𝑞2 in Hierarchical Sliding Mode Control for

Inverted Pendulum Double-Mass System..............................................52



Figure 4.10c Simulink Model of 𝑢𝑒𝑞3 in Hierarchical Sliding Mode Control for

Inverted Pendulum Double-Mass System..............................................52


Figure 4.10d Simulink Model of 𝑆3 in Hierarchical Sliding Mode Control for
Inverted Pendulum Double-Mass System..............................................52
Figure 4.10e Simulink Model of SMC in Hierarchical Sliding Mode Control for
Inverted Pendulum Double-Mass System..............................................52
Figure 4.11 Simulation Result of Robust Control for Inverted Pendulum
Double-Mass System................................................................................55
Figure 4.12 Simulation Result of Adaptive Control for Inverted Pendulum
Double-Mass System................................................................................56
1

Chapter 1 Introduction
Inverted pendulum is an under-actuated and nonlinear system with lesser control
inputs than the degrees of freedom. Designing controllers for such a system resembles
the control of many applications such as robots, Segway, and space rockets [1].

There are two equilibrium points in a pendulum system. The first one is the gantry
system when the pendulum is vertically down shown in Figure 1.1. It is stable point,
because the system will return to this point automatically without outside intervention.
The second one is the inverted pendulum system when the pendulum is vertically up
shown in Figure 1.2. It is an unstable point, because even small perturbations will
cause its downfall. Studying stabilization of an inverted pendulum system seems more
meaningful, and an understanding of how to control such a system will allow us to
easily solve the other related control problems [2]. In this research, several controllers
have been designed not only for the inverted pendulum single-mass system, but also
for the inverted pendulum double-mass system (shown in Figure 1.3), which is more
difficult because it adds one more degree of freedom. The aim of this case study is to
keep the pendulum in the upright position while the base mass moving to a desired
position.

Figure 1.1: Gantry Pendulum System


2

Figure 1.2: Inverted Pendulum System

Figure 1.3: Inverted Pendulum Double-Mass System

In general, the control problem consists of obtaining dynamic models of systems, and
designing controllers based on these models to achieve the desired system response
and performance. In this research the first step is giving dynamic molding and then
several controllers are designed for each system (inverted pendulum single-mass
system and inverted pendulum double-mass system).

In recent years, many control theories are very popular. The


Proportional-Integral-Derivative (PID) control is a control loop feedback mechanism
and was first developed by Russian American engineer Nicolas Minorsky in 1992. It
is still popular in industrial fields. It can give the simplest and most efficient solution
to various simple problems. However, when a system becomes complex, through
nonlinearities, coupling, and uncertain dynamics, then the PID control would not be
able to achieve effective control. But after being improved or worked with other
3

controllers, it can still give us a satisfactory result. For instance, an adaptive PID
controller was designed by Vikram Chopra, Sunil K. Singla and Lillie Dewan for an
X-Y inverted pendulum in 2015[1]. Li Ming used self-adaptive fuzzy PID digital
control method for linear inverted pendulum in 2012[3]. Lal Bahadur Prasad, Barjeev
Tyagi, and Hari Om Gupta developed a PID & LQR controller for nonlinear Inverted
Pendulum dynamical system with disturbance input in 2011[4]. S. Omatu, T. Fujinaka,
and M. Yoshioka presented a Neuro-PID controller for inverted single and double
pendulums in 2000[5]. T. Fujinaka, Y. Kishida, and M. Yoshioka studied the
stabilization of double inverted pendulum with self-tuning neuro-PID in 2000[6]. An
interval type-2 fuzzy PID controller was proposed by Mohammad El-Bardini and
Ahmad M. El-Nagar for controlling an inverted pendulum on a cart system with an
uncertain model in 2014[7]. In this research, PID control theory has been applied to
hierarchical sliding mode and adaptive control.

Optimal control has been a field of study since its formulation in the mid-20th century,
and has been much aided by the increase of computing power and development of
efficient algorithms [8]. Optimal control deals with the problem of finding a control
law for a given system such that a certain optimality criterion is achieved [9]. The
optimal control includes several cases, such linear quadratic regulator (LQR),
state-dependent Riccati equation, optimal neural network control, and so on.
Alexander Bogdanov used them for a double inverted pendulum on a cart in 2004[10].
Oskar Stattin developed optimal control for Inverted Pendulum in 2015[8]. Khaled
Gamal Eltohamy and Chen-Yuan Kuo designed a single-input feedback controller for
a triple link inverted pendulum using a nonlinear optimization technique in 1998[11].
Viroch Sukontanakarn and Manukid Parnichkun proposed a real-time optimal
controller for rotary inverted pendulum in 2009[12]. In this research LQR controller
has been designed for both inverted pendulum single-mass system and inverted
pendulum double-mass system.

Robust control is an approach to controller design that explicitly deals with


4

uncertainty [13]. Since the model used in the design always differs from the actual
plant, and to make sure the controller designed using a model could work
satisfactorily with the actual plant, robust control theory has been developed since
around 1980. A special case of it is sliding mode control (SMC). It is a variable
structure control method, which can switch from one continuous structure to another
based on the current position in the state space [14]. Sliding mode control can work
effectively for single-input and single-output (SISO) system, but it should be
improved to control single-input and multi-output (SIMO) under-actuated system. For
example, Mun-Soo Park and Dongkyoung Chwa used coupled sliding-mode control
method to control inverted-pendulum systems in 2009[15]. Or we can use hierarchical
sliding mode control, which is proposed for a class of SIMO under-actuated systems
[16]. Dianwei Qian, Jianqiang Yi, Dongbin Zhao, and Yinxing Hao developed a
hierarchical sliding mode controller for series double inverted pendulums system in
2006[17]. Dianwei Qian, Jianqiang Yi, and Dongbin Zhao designed hierarchical
sliding mode controller for SIMO under-actuated systems [16]. This research
improved their theory for inverted pendulum single-mass system and inverted
pendulum double-mass system to make to the controllers work better.

Adaptive control has its roots in the mid-fifties [18]. Adaptive control is the control
method used by a controller which must adapt to a controlled system with parameters
which vary, or are initially uncertain [19]. Designing an adaptive controller always
follows two steps. At first, we must use classical control theory to design a controller
that meets the specifications by assuming the gains were known. Secondly, identified
the unknown gains and design function of time instead of unknown gains. Designing
an adaptive controller should be careful, because a bad function of gain would
become disturbance to the system and make performance of system even worse.
However, many people succeeded in developing an adaptive controller for inverted
pendulum. For example, T. C. Kuo, Y. J. Huang and B. W. Hong designed an adaptive
PID with sliding mode control for the rotary inverted pendulum system in 2009[20].
Ming Li developed a self-adaptive fuzzy PID digital control method for linear
5

inverted pendulum in 2012[3]. Chaio-Shiung Chen and Wen-Liang Chen proposed


robust adaptive sliding mode control using fuzzy modeling for an inverted pendulum
system in 1998[2]. An adaptive hierarchical fuzzy sliding mode control has been
designed for a class of coupling nonlinear systems by Chih-Min Lin, Wei-Liang
Chung-Li and Tao-Yuan in 2006[21]. Rong-Jong Wai, Meng-An Kuo, and Jeng-Dao
Lee presented a cascade adaptive fuzzy sliding-mode control for nonlinear two-axis
inverted-pendulum servomechanism in 2008[22]. Chih-Min Lin and Yi-Jen Mon
designed a hierarchical fuzzy sliding-mode controller of a double inverted pendulum
system in 2005[23]. Chin Wang Tao, Jinshiuh Taur, Chien Ming Wang, and U.S.Chen
proposed a fuzzy hierarchical swing-up and sliding position controller for the
swing-up and position controls of an inverted pendulum–cart system in 2008[24]. A
cascade adaptive fuzzy sliding-mode control scheme including inner and outer control
loops was investigated by Rong-Jong Wai, Meng-An Kuo, and Jeng-Dao Lee for the
stabilizing and tracking control of a nonlinear two-axis inverted-pendulum
servomechanism in 2008[25]. In this research, adaptive controllers have been
designed for both inverted pendulum single-mass system and inverted pendulum
double-mass system.

People usually use stability theory while they designing controllers.


In mathematics, stability theory addresses the stability of solutions of differential
equations and of trajectories of dynamical systems under small perturbations of initial
conditions[26]. The most useful and general approach for studying the stability of
nonlinear control system is the theory introduced in the late 19th century by the
Russian mathematician Alexandr Mikhailovich Lyapunov [27]. Lyapunov's work, The
General Problem of Motion Stability, includes so many fruitful ideas and results of
primary significance that the whole history of the theory of stability of motion can be
divided into the pre-Lyapunov and post-Lyapunov periods [28]. Lyapunov proposed
two methods for demonstrating stability: the Indirect Method of Lyapunov, also called
the First Method, and Lyapunov’s Direct Method, also called the Second Method of
Lyapunov. The First Method, Lyapunov established some important stability results
6

for linear systems [29]. The direct method is not restricted to local motion, and
determines the stability properties of a nonlinear system by constructing a scalar
''energy-like'' function for the system and examining the function's time variation [27].
When designing a controller, Lyapunov theorem is often used to derive the control
law to make sure the system can be guaranteed to be asymptotically stable. For
instance, Carlos Aguilar Ibañez, O. Gutiérrez Frias, and M. Suárez Castañón
investigated a Lyapunov-based controller for the inverted pendulum cart system in
2005[30]. M. J. Anderson and W. J. Grantham used Lyapunov optimal feedback
control method for a nonlinear inverted pendulum in 1989[31]. In this research, the
final robust control law was derived from a Lyapunov-based approach and stability
viewpoint.
7

Chapter 2 Overview
Stabilization of an inverted pendulum system is a complex and nonlinear problem. It
has been extensively studied by numerous researchers [2]. Most researchers just
studied one control strategy for an inverted pendulum appended to a single-mass. This
research undertakes the design and development of a series of control strategies for an
inverted pendulum appended to a single-mass and an inverted pendulum added to a
double-mass system.

In chapter 3, several controllers were designed to keep the inverted pendulum


appended to a single-mass always inverted stabilization while the base mass moves a
certain distance, including PID controller, LQR controller, robust controller and
adaptive controller.

The fourth chapter studies the stabilization of the inverted pendulum double-mass
system, which consists of two carts moving along a rail: (i) a passive cart with a
free-swinging pendulum attached through a spring and a damper to (ii) an active cart
with a DC motor and gearbox. PID controller, LQR controller, robust controller and
adaptive controller have been designed for this system to keep the inverted pendulum
added to a double-mass system always up while the base mass moving to a desired
position.

In this research, several control architectures are proposed for operation of inverted
pendulum mechanical systems. Extensive simulation and experimental results are
provided to justify that the comparative advantage of robust control and adaptive
control methods over PID and LQR techniques.
8

Chapter 3
Dynamic Modeling and Control of Inverted Pendulum
Single-Mass System
In this chapter, a series of controllers were developed and implemented for the
inverted pendulum single-mass system as shown in Figure 3.1, which consists of a
cart moving along a rail, a drive mechanism (coreless DC motor, planetary gearbox,
power amplifier), and a pendulum which is free to rotate about a pivot attached to the
cart. The system includes two sensors for measuring the pendulum angle and the cart
position. All the parameter values required to perform controller design and system
simulations are provided in Appendix A.1. Designing controllers for such a system
resembles the control of many applications, such as robots and space rockets [1].

Section 3.1 shows how to derive the complete system dynamics by determining the
equations of motion for the electrical, mechanical and combined systems. Following
this, in Section 3.2, PID, LQR, robust, and adaptive controllers have been designed to
bring the experimental gantry system to the desired position while simultaneously
minimizing the vibration of the pendulum. To this end, the closed-loop system would
be subjected to performance requirement which would keep the pendulum always up
while the base mass moving a desired distance (0.05m). In Section 3.3, the controllers
designed offline would be implemented in the real-time control system, and their
performance will be evaluated for comparison to the anticipated/simulated results.
9

Figure 3.1: Inverted Pendulum Single-Mass System

3.1 Dynamic Molding of Inverted Pendulum Single-Mass System


1. Equations of Motion
The drive mechanism in the system may be represented schematically as depicted by
Figure 3.2.

Figure 3.2: DC Motor Schematic Diagram Relating Applied Voltage to Position of the
Motor Pinion Gear, 𝜃𝑝 [32]

i. DC Motor Current
By using Kirchhoff's Voltage Law on the circuit diagram in Figure 3.2, we could get
d
𝑅𝑎 𝑖𝑎 (𝑡) + 𝐿𝑎 (dt 𝑖𝑎 (𝑡)) + 𝑣𝐵𝐸𝑀𝐹 (𝑡) = 𝑣𝐴 (𝑡) (3.1)

where 𝑅𝑎 and 𝐿𝑎 represent armature resistance and armature inductance, and


𝑖𝑎 (𝑡) and 𝑣𝐴 (𝑡) represent the motor current draw and the applied voltage respectively.
𝑣𝐵𝐸𝑀𝐹 is the voltage fed back into the circuit, because of the motion of wires in a
10

magnetic field, and can be determined from the equation

𝑣𝐵𝐸𝑀𝐹 (𝑡) = 𝑁𝐾𝐵 𝜃𝑔̇ (𝑡) (3.2)

where N is the gear ratio of the planetary gearbox, 𝐾𝐵 is the motor speed coefficient,

and 𝜃𝑔̇ is the rotational velocity of the motor pinion gear.

ii. DC Motor Gear Angle


Since 𝐽𝑚 represents the rotor inertia, we can derive the equation by summing the
moment as

𝐽𝑚 𝑁𝜃𝑔̈ (𝑡) + 𝐵𝑚 𝑁𝜃𝑔̇ (𝑡) = 𝜏𝑚 + 𝜏𝐿 (3.3)

where 𝐵𝑚 represents the damping acting on the rotor, 𝜏𝑚 and 𝜏𝐿 are the torques on
the motor provided by the magnetic field and the external load applied via the
interactions of the rack and motor pinion gear respectively, and can be identified as
𝜏𝑚 = 𝐾𝑡 𝑖𝑎 (𝑡) (3.4a)
𝑓𝑐 𝑟𝑔
𝜏𝐿 = − (3.4b)
𝑁

where 𝐾𝑡 is the motor torque constant, 𝑓𝑐 is the reaction force applied to the motor
pinion gear by the rack, and 𝑟𝑔 is the radius of the motor pinion gear.

iii. Cart Position

Figure 3.3: Linearized External and Inertial Forces and Moments Affecting the Cart
11

Figure 3.4: Linearized External Forces and Moments Affecting the Pendulum

By considering the velocity of the center of gravity of the pendulum with respect to an
inertial reference frame, we could have
𝐿𝑃 𝐿𝑃
𝒗 ̂ ∗ (−
⃗ 𝑝 = 𝑥̇ 𝑐 𝐢̂ + 𝜃̇𝑝 𝐤 sin(𝜃𝑝 ) 𝐢̂ + cos(𝜃𝒑 ) 𝐣̂)
2 2
𝐿𝑃 𝐿
= (𝑥̇ 𝑐 − 𝜃̇𝑝 cos(𝜃𝑝 )) 𝐢̂ − 2𝑃 𝜃̇𝑝 sin(𝜃𝑝 ) 𝐣̂ (3.5)
2

and taking the derivative to determine the inertial acceleration,


𝐿𝑃 𝐿 𝐿 𝐿
⃗ 𝑝 = (𝑥̈ 𝑐 −
𝒂 𝜃̈𝑝 cos(𝜃𝑝 ) + 2𝑃 𝜃̇𝑝2 sin(𝜃𝑝 )) 𝐢̂ − ( 2𝑃 𝜃̈𝑝 sin(𝜃𝑝 ) + 2𝑃 𝜃̇𝑝2 cos(𝜃𝑝 )) 𝐣̂
2

(3.6)
Considering the sum of the forces in the x-direction as,
∑ 𝐹𝑥 = 𝑀𝑐 𝑥̈ 𝑐 + 𝑀𝑝 𝑎𝑝𝑥 (3.7)
The free body diagram given in Figure 3.3 can be expanded as,
𝐿𝑃 𝐿
(𝑀𝑐 + 𝑀𝑝 ) 𝑥̈ 𝑐 − 𝑀𝑝 𝜃̈𝑝 cos(𝜃𝑝 ) + 𝐵𝑐 𝑥̇ 𝑐 + 𝑀𝑝 2𝑃 𝜃̇𝑝2 sin(𝜃𝑝 ) + 𝑓𝑘 = 𝑓𝑐 (3.8)
2

where 𝑓𝑘 = 𝑏 sign(𝑥̇ 𝑐 )
Here, 𝑀𝑐 and 𝑀𝑝 represent the masses of the cart and pendulum respectively, 𝐵𝑐 is

the damping coefficient observed by the cart, 𝐿𝑃 is the full length of the pendulum,
𝑥𝑐 is the position of the cart in the x direction, 𝜃𝑝 is the counterclockwise angle of

the pendulum with respect to the initial vertical line, 𝑓𝑘 respects coulomb observed by
the cart, and b is coulomb friction coefficient.

iv. Pendulum Angle


If the sum of moments about the pendulum joint are counted, denoted in Figure 3.4 by
12

point P, which may be written as,

⃗ 𝐶𝐺 × 𝐯⃗̇ 𝐩
∑ 𝜏𝑝 = 𝐼𝑝 𝜃̈𝑝 + 𝑚𝒓 (3.9)
1 𝐿
where 𝐼𝑝 = 12 𝑀𝑝 𝐿2𝑝 + 𝑀𝑝 ( 2𝑃 )2 (3.10)

𝐿𝑃 𝐿𝑃
𝐫CG = − 𝑠𝑖𝑛(𝜃𝑝 ) 𝐢̂ + 𝑐𝑜𝑠(𝜃𝑝 ) 𝐣̂ (3.11)
2 2

𝐯⃗̇ 𝑝 = 𝑥̈ 𝑐 𝐢̂ (3.12)

Here, 𝐼𝑝 respects the pendulum inertia about point P, 𝐫CG is the position of the

pendulum center of gravity with respect to point P, and 𝐯⃗̇ p is the velocity of the point

P. Submitting Eqs. (3.10), (3.11), (3.12) into Eq. (3.9), we can get

1 𝐿𝑃 2 𝐿 𝐿
̂ + 𝑀𝑝 ( 𝑃 𝑠𝑖𝑛(𝜃𝑝 ) 𝐢̂ − 𝑃 cos(𝜃𝑝 ) 𝐣̂) × 𝑥̈ 𝑐 𝐢̂
∑ 𝜏𝑝 = [ 𝑀𝑝 𝐿2𝑝 + 𝑀𝑝 ( ) ] 𝜃̈𝑝 𝐤
12 2 2 2
1 𝐿
̂
= [3 𝑀𝑝 𝐿2𝑝 𝜃̈𝑝 + 𝑀𝑝 2𝑃 𝑥̈ 𝑐 cos(𝜃𝑝 )] 𝐤 (3.13)

Considering this equation and the free body diagram given in Figure 3.4, the last
equation of motion can be written as,
1 𝐿𝑃 𝐿𝑃
𝑀𝑝 𝐿2𝑝 𝜃̈𝑝 − 𝑀𝑝 𝑥̈ 𝑐 + 𝐵𝑝 𝜃̇𝑝 − 𝑀𝑝 𝑔 sin(𝜃𝑝 ) = 0 (3.14)
3 2 2

where 𝐵𝑝 is the damping coefficient affecting the pendulum.

v. Simplify Carts and Pendulum Equations


Controllers will be designed to make sure the rotation of the pendulum angle is very
small, so the nonlinear cart and pendulum dynamics may be linearized by

sin(𝜃𝑝 ) = 𝜃𝑝 (3.15a)

cos(𝜃𝑝 ) = 1 (3.15b)

Submitting Eqs. (3.15a) and (3.15b) into Eqs. (3.8) and (3.14), and removed the
higher order terms, the equations can be expressed as
𝐿𝑃
(𝑀𝑐 + 𝑀𝑝 ) 𝑥̈ 𝑐 − 𝑀𝑝 𝜃̈𝑝 + 𝐵𝑐 𝑥̇ 𝑐 + 𝑏 sign(𝑥̇ 𝑐 ) = 𝑓𝑐 (3.16)
2

1 𝐿𝑃 𝐿𝑃
𝑀𝑝 𝐿2𝑝 𝜃̈𝑝 − 𝑀𝑝 𝑥̈ 𝑐 + 𝐵𝑝 𝜃̇𝑝 − 𝑀𝑝 𝑔 𝜃𝑝 = 0 (3.17)
3 2 2

vi. Combined Transfer Function


13

Submitting Eqs. (3.4a) and (3.4b) into Eq. (3.3). we could get
𝑟𝑔
𝐽𝑚 𝑁𝜃̈𝑝 + 𝐵𝑚 𝑁𝜃̇𝑝 = 𝐾𝑡 𝑖𝑎 − 𝑓𝑐 (3.18a)
𝑁

𝑁2 𝑁 2
𝑁
𝑓𝑐 = −𝐽𝑚 𝜃̈𝑝 − 𝐵𝑚 𝑟 𝜃̇𝑝 + 𝑟 𝐾𝑡 𝑖𝑎 (3.18b)
𝑟𝑔 𝑔 𝑔

By substituting Eq. (3.18b) into Eq. (3.16), and realizing that the angle of the motor
𝑥𝑐
pinion gear may be written as 𝜃𝑝 = , Eq. (3.16) may be rewritten as,
𝑟𝑔

𝑁2 𝑁2 𝐿𝑃 𝑁
(𝑀𝐶 + 𝑀𝑝 + 𝐽𝑚 ) 𝑥̈ 𝑐 + (𝐵𝑐 + 𝐵𝑚 ) 𝑥̇ 𝑐 − 𝑀𝑝 𝜃̈𝑝 − 𝑟 𝐾𝑡 𝑖𝑎 (𝑡) = 0 (3.19)
𝑟𝑔 𝑟𝑔 2 𝑔

Thus, all the equations of motion can be written as,


𝑑 𝑁𝐾𝐵
𝑅𝑎 𝑖𝑎 (𝑡) + 𝐿𝑎 (𝑑𝑡 𝑖𝑎 (𝑡)) + 𝑥̇ 𝑐 = 𝑣𝐴 (𝑡) (3.20)
𝑟𝑔

𝑁2 𝑁2 𝐿𝑃 𝑁
(𝑀𝐶 + 𝑀𝑝 + 𝐽𝑚 ) 𝑥̈ 𝑐 + (𝐵𝑐 + 𝐵𝑚 ) 𝑥̇ 𝑐 + 𝑏 sign(𝑥̇ 𝑐 ) − 𝑀𝑝 𝜃̈𝑝 − 𝑟 𝐾𝑡 𝑖𝑎 (𝑡) = 0
𝑟𝑔 𝑟𝑔 2 𝑔

(3.21)
1 𝐿 𝐿
𝑀𝑝 𝐿2𝑝 𝜃̈𝑝 − 𝑀𝑝 2𝑃 𝑥̈ 𝑐 + 𝐵𝑝 𝜃̇𝑝 − 𝑀𝑝 𝑔 2𝑃 𝜃𝑝 = 0 (3.22)
3

2. Build Mode in Simulink


Simulink model of the system shows in Figure 3.5. The value of each symbol has
been applied in the model (see Appendix A.1.).
Figure 3.5: Simulink Model of Inverted Pendulum Single-Mass System
14
15

3. Open-loop Transfer Functions


With the help of Maple, the open-loop transfer function relating the position of the
cart 𝑥𝑐 and 𝜃𝑝 to the applied motor voltage 𝑣𝐴 can be found. By omitting coulomb

friction and apply the value of each symbol, the results can be shown as below (see
Appendix A.2. for the process of calculating):
𝑥𝑐 ’s open-loop transfer function is:
3.36 ∗ 1018 ∗ (2.9 ∗ 109 ∙ s 2 + 8 ∗ 108 ∙ s − 1.267 ∗ 1011 )
𝐗c =
s(4.5 ∗ 1023 ∙ s 4 + 6.52 ∗ 1027 ∙ s 3 + 1.11 ∗ 1029 ∙ s 2 − 2.97 ∗ 1029 ∙ s − 4.76 ∗ 1030 )
(3.23a)
𝜃𝑝 's open-loop transfer function is:
4.34 ∗ 1028 ∙ s
𝛉𝑝 =
4.5 ∗ 1023 ∙ s 4 + 6.52 ∗ 1027 ∙ s 3 + 1.11 ∗ 1029 ∙ s 2 − 2.97 ∗ 1029 ∙ s − 4.76 ∗ 1030
(3.23b)
4. Stability
The stability of a system can be determined from its poles [33]:
(1) Stable systems have poles only in the left-hand plane.
(2) Unstable systems have at least one pole in the right-hand plane and/or poles of
multiplicity greater than 1 on the imaginary axis.
(3) Marginally stable systems have one pole on the imaginary axis and the other poles
in the left-hand plane.

For this system based on 𝑥𝑐 ’s and 𝜃𝑝 's transfer function, the poles and zeros can be

found simply by using Maple (see Appendix A.2. for the process of calculating):
𝑥𝑐 :
Zeros: 6.471542452, -6.747184114
Poles: 0., 6.604454017, -6.418833021, -17.25594561, -14437.72415
𝜃𝑝 :

Zeros: 0
Poles: 6.604454017, -6.418833021, -17.25594561, -14437.72415
It shows that there is one pole at right-hand plane for 𝑥𝑐 and 𝜃𝑝 , so the system is
unstable.
16

5. State-Space Representation
Using the differential equations, the state-space representation of the open loop
dynamics can be developed as following (see Appendix A.2. for the process of
calculating). The input is voltage (𝑣𝐴 (𝑡)), the output are cart position (𝑥𝑐 (𝑡)) and
pendulum angle (𝜃𝑝 (𝑡)).
𝜃̇𝑝 (𝑡) 0
0 1 0 0 0 𝜃𝑝 (𝑡)
𝜃̈𝑝 (𝑡) 0
50.21 −0.317 0 −44.6575 17.3349 𝜃̇𝑝 (𝑡)
𝑥̇ 𝑐 (𝑡) 0
= 0 0 0 1 0 𝑥𝑐 (𝑡) + 𝑣𝑎 (𝑡)
𝑥̈ 𝑐 (𝑡) 0
1.47 −0.0093 0 −10.033 3.8946 𝑥̇ 𝑐 (𝑡) 50000
d [ 0 0 0 −24895.63 −14444.44] [ 𝑖𝑎 (𝑡)] [
[d𝑡 𝑖𝑎 ](𝑡) 9 ]

(3.24)

𝜃𝑝 (𝑡)

𝜃𝑝 (𝑡) 𝜃̇𝑝 (𝑡)


1 0 0 0 0
[ ]=[ ] + [0] 𝑣𝑎 (𝑡) (3.25)
𝑥𝑐 (𝑡) 0 0 1 0 0 𝑥𝑐 (𝑡)
𝑥̇ 𝑐 (𝑡)
[ 𝑖𝑎 (𝑡)]

3.2 Controllers Design


3.2.1 PID control
The conventional Proportional-Integral-Derivative (PID) controller is
d𝑒(𝑡)
𝑢(𝑡) = 𝐾𝑝 𝑒(𝑡) + 𝐾𝑖 ∫ 𝑒(𝑡)d𝑡 + 𝐾𝑑 (3.26)
d𝑡

where 𝑢(𝑡) is the control sign, e(t) is the control error, 𝐾𝑝 , 𝐾𝑖 and 𝐾𝑑 are the

proportional, the integral and the derivative gains of the controller respectively.
Increasing 𝐾𝑝 will decrease the steady-state error, but too much 𝐾𝑝 will make

system unstable. Integral controller could remove the steady-state error completely
regardless of the values of other gains, but it may lead to oscillatory response.
Derivative controller could improve damping and stability of system, but it leads to a
permanent steady-state error. Increasing 𝐾𝑑 could amplify noise.

To make the performance of the system meet the criterion, a PID controller has been
added to the closed loop between cart position error and motor voltage under negative
unity feedback. The block diagram is shown in Figure 3.6. MATLAB/PID Tuner were
17

used to get the value of 𝐾𝑝 , 𝐾𝑖 and 𝐾𝑑 shown in Figure 3.7 (see the code in
Appendix A.3.). To meet criteria, 𝐾𝑝 should be about 2.009 × 106 , 𝐾𝑖 should be

about 1.512 × 108 and 𝐾𝑑 should be about 6676, which is too expensive for most
physical systems to offer it. The settling time is too small for most physical systems to
realize it. Thus, unfortunately PID control does not work for this system.

Figure 3.6: PID Control of Inverted Pendulum Single-Mass System

Figure 3.7: MATLAB/PID Tuner to Find the Values of 𝐾𝑝 , 𝐾𝑖 and 𝐾𝑑 for Inverted
Pendulum Single-Mass System

3.2.2 Optimal Control


The main objective of optimal control is to determine control signals that will cause a
process to satisfy some physical constraints and at the same time maximize or
minimize a chosen performance index (PI) or cost function [4]. The case where the
18

system dynamics are described by a set of linear differential equations and the cost is
described by a quadratic function is called the LQ problem. One of the main results in
the theory is that the solution is provided by the linear–quadratic regulator (LQR), a
feedback controller [34]. The performance index shown as,
t
PI = ∫0 f (𝑥 T 𝑄𝑥 + 𝑢T 𝑅𝑢) d𝑡 (3.27)

where Q and R are symmetric positive definite matrices.


The linear state-space equation of a system can be expressed as
𝑥̇ = 𝐴𝑥 + 𝐵𝑢
{ (3.28)
𝑦 = 𝐶𝑥 + 𝐷𝑢
where A, B, C and D are system matrices, y is output, x is the state.
The state feedback control as
𝑢 = −𝐾𝑥 (3.29)
where K is the LQR gain shown as,
𝐾 = 𝑅 −1 𝐵 T 𝑃 (3.30)
where P is a positive definite symmetric constant matrix obtained from the solution of
matrix Algebraic Riccati Equation (ARE):
𝐴𝑇 𝑃 + 𝑃𝐴 − 𝑃𝐵𝑅 −1 𝐵T 𝑃 + 𝑄 = 0 (3.31)

1. Observer Design
Considering a system as Eq. (3.28), when some states (𝑥) are not available or not
physical, the estimate of states can be used in the controller design. The error state is
defined as
𝑒 = 𝑥̃ = 𝑥 − 𝑥̂ (3.32)
where 𝑥 is actual state, 𝑥̂ is estimate of 𝑥, and error output as
𝑦̃ = 𝑦 − 𝑦̂ = 𝑦 − 𝐶𝑥̂ (3.33)
where 𝑦̂ is estimate of y.
Then the estimated system can be expressed as

𝑥̂̇ = 𝐴𝑥̂ + 𝐵𝑢 + 𝐿𝑦̃ (3.34)


Differentiate 𝑒 with respect to time t, then
𝑒̇ = 𝑥̃̇ = 𝑥̇ − 𝑥̂̇= 𝐴𝑥 + 𝐵𝑢 − (𝐴𝑥̂ + 𝐵𝑢 + 𝐿𝑦̃)
19

= (𝐴 − 𝐿𝐶)(𝑥 − 𝑥̂) = (𝐴 − 𝐿𝐶)𝑒 (3.35)


If we want

lim e(t) = 0 (3.36)


t→∞

L should be selected such that

det(𝑆𝐼 − (𝐴 − 𝐿𝐶)) = 0 (3.37)

2. Controllability and Observability


If the control input, u, of a system can take each state variable, 𝑥𝑖 where i = 1... n,
from an initial state to a final state then the system is controllable, otherwise it is
uncontrollable [33]. A system must be controllable if the rank of its controllability
matrix
𝑀𝑐 = [𝐵 𝐴𝐵 𝐴2 𝐵 … 𝐴𝑛−1 𝐵]𝑛×𝑛 (3.38)
equals the number of states in the system,
rank(𝑀𝑐 ) = 𝑛 (3.39a)
or det(𝑀𝑐 ) ≠ 0 (3.39b)
where det() is the determinant function.

If a system is observable, it is possible to fully reconstruct the system state from its
output measurements using the state observer [35]. A system must be observable if
the rank of its observability matrix
𝑀𝑜 = [𝐶 𝐶𝐴 𝐶𝐴2 … 𝐶𝐴𝑛−1 ]𝑛×𝑛 (3.40)
equals the number of states in the system,
rank(𝑀𝑜 ) = 𝑛 (3.41a)
or det(𝑀𝑜 ) ≠ 0 (3.41b)

Before designing a LQR controller, we must check the controllability and


observability of the system. We can obtain the determinate of matrices as follows (see
the code in Appendix A.4.):
det(𝑀𝑐 ) = 1.4501 ∗ 104 ≠ 0 (3.42)
20

det(𝑀𝑜 ) = −1 ≠ 0 (3.43)
Thus, the matrices are of full rank and the system is controllable and observable.

3. LQR Controller Design


When design the LQR controller for the system, the order of current is reduced,
because only the cart position and pendulum angle must be controlled. Simulink
model of the system shows in Figure 3.8 (see the code in Appendix A.4.). With the
choice of R=1/36 and
7.89 ∗ 103 0 0 0
Q=[ 0 2.95 ∗ 103 0 0 ]
0 0 1.2207 ∗ 105 0
0 0 0 1.4 ∗ 102
LQR gain vector can be obtained as
k=[−533 −666.1 2977.3 441.3]
and
2540 4
14010 73
L=[ ]
−64 289
−12745 20388
1
To decrease oscillations, two filters are designed as . The response of the
(0.0008s+1)2

system shown in Figure 3.9. It meets the criterion, but has a lot of oscillations.
Figure 3.8: Simulink Model of LQR Control for Inverted Pendulum Single-Mass System
21
22

Figure 3.9: Simulation Result of LQR Control for Inverted Pendulum Single-Mass
System

3.2.3 Robust Control


The theory of robust control assumes that there is an uncertainty or error between the
actual plant and its mathematical model and includes such uncertainty or error in the
design process of the control system [36]. In recent years, sliding mode control
methodology has been widely used for control design problem for a class nonlinear
system because of its robust stability and robust performance. Among it, a hierarchical
sliding mode control approach is proposed for a class of single-input and multi-output
(SIMO) under-actuated system [16]. According to the inverted pendulum single-mass
system physical structure can be divided in to two subsystems: pendulum and cart,
hierarchical sliding mode control method can be applied to this system. This research
improved the theory proposed by Dianwei Qian, Jianqiang Yi and Dongbin Zhao in
2007[16]. When the sliding surface function was designed, an integral controller has
been added to eliminate the steady-state error and the overshoot.

Stability theory plays a central role in systems theory and engineering [37]. The most
useful and general approach for studying the stability of nonlinear control system is
23

the theory introduced in the late 19th century by the Russian mathematician Alexandr
Mikhailovich Lyapunov [27]. Lyapunov, in his original 1892 work, proposed two
methods for demonstrating stability [38]. The first method developed the solution in a
series which was then proved convergent within limits. The second method, which is
now referred to as the Lyapunov stability criterion, makes use of a Lyapunov function
V(x) which has an analogy to the potential function of classical dynamics [39]. In this
section the second method has been used to make sure the system can be guaranteed
to be asymptotically stable. It is introduced as follows for a system 𝑥̇ = 𝑓(𝑥) having
a point of equilibrium at 𝑥 = 0. Consider a function 𝑉(𝑥): R𝑛 → R such that [39]
(1) 𝑉(𝑥) = 0 if and only if 𝑥 = 0,
(2) 𝑉(𝑥) > 0 if and only if 𝑥 ≠ 0,
(3) V̇(x) < 0 for all values of 𝑥 ≠ 0
then 𝑉(𝑥) is called a Lyapunov function candidate and the system is asymptotically
stable in the sense of Lyapunov.

1. Hierarchical sliding mode control design


Consider the state space expression of the class of SIMO under-actuated systems with
n subsystems in the following normal form:
𝑥̇ 1 =𝑥2
𝑥̇ 2 =𝑓1 +𝑏1 𝑢
{ 𝑥̇ 3 =𝑥4 (3.44)
𝑥̇ 5 =𝑓2 +𝑏2 𝑢


Here, 𝐗 = [𝑥1 , 𝑥2 , … , 𝑥2𝑛 ]𝑇 is the state variable vector; 𝑓𝑖 and 𝑏𝑖 (i=1, 2, …, n) are
the nonlinear functions of the state vector; and u is the single control input [16]. For
inverted pendulum single-mass system, we can set
𝑥1 =𝜃𝑝
𝑥2 =𝜃̇𝑝
{ (3.45)
𝑥3 =𝑥𝑐
𝑥4 =𝑥̇ 𝑐
Define the sliding surface as [16]
𝑠1 = 𝑐1 𝑥1 + 𝑥2
𝑠2 = 𝑐2 𝑥3 + 𝑥4 (3.46)
24

where 𝑐1 and 𝑐2 are positive constant.


Differentiate 𝑠1 and 𝑠2 with respect to time t, then,
𝑠̇1 = 𝑐1 𝑥̇ 1 + 𝑥̇ 2 =𝑐1 𝑥2 + 𝑓1 + 𝑏1 𝑢
𝑠̇2 = 𝑐2 𝑥̇ 3 + 𝑥̇ 4 =𝑐2 𝑥4 + 𝑓2 + 𝑏2 𝑢 (3.47)
Lets 𝑠̇𝑖 = 0 in Eq. (3.47), the equivalent control of the 1th and 2nd subsystem is
obtained as [16]
𝑢𝑒𝑞1 = −(𝑐1 𝑥2 + 𝑓1 )/ 𝑏1
𝑢𝑒𝑞2 = −(𝑐2 𝑥4 + 𝑓2 )/ 𝑏2 (3.48)

Define the 1th layer sliding surface as [16]


𝑆1 = 𝑠1 (3.49)
and the 2nd layer sliding surface as [16]
𝑆2 = 𝜆1 𝑆1 + 𝑠2 (3.50)
where 𝜆1 is constant.
Differentiate 𝑆1 and 𝑆2 with respect to time t in Eqs. (3.49) and (3.50), then
𝑆1̇ = 𝑠̇1 = 𝑐1 𝑥̇ 1 + 𝑥̇ 2
𝑆2̇ = 𝜆1 𝑆1̇ + 𝑠̇2 = 𝜆1 (𝑐1 𝑥̇ 1 + 𝑥̇ 2 ) + 𝑐2 𝑥4 + 𝑓2 + 𝑏2 𝑢 (3.51)
The Lyapunov function of the ith layer sliding surface is selected as [16]
𝑉𝑖 = 𝑆𝑖2 /2 (3.52)
By considering the stability of the ith layer sliding surface, let
𝑆𝑖̇ = −𝑘𝑖 𝑆𝑖 − 𝜂𝑖 tanh(10 ∙ 𝑆𝑖 ) − 𝐾𝑖 ∫ 𝑆𝑖 𝑑𝑡 (3.53)
where 𝑘𝑖 , 𝜂𝑖 and 𝐾𝑖 are positive constants.
Then

𝑆1̇ = −𝑘1 𝑆1 − 𝜂1 tanh(10 ∙ 𝑆1 ) − 𝐾1 ∫ 𝑆1 𝑑𝑡

𝑆2̇ = −𝑘2 𝑆2 − 𝜂2 tanh(10 ∙ 𝑆2 ) − 𝐾2 ∫ 𝑆2 𝑑𝑡 (3.54)


From Eqs. (3.46), (3.47), (3.48), (3.51) and (3.54), the hierarchical sliding mode
control law can be obtained as

𝜆1 𝑏1 𝑢𝑒𝑞1 + 𝑏2 𝑢𝑒𝑞2 − 𝑘2 𝑆2 − 𝜂2 tanh(10 ∙ 𝑆2 ) − 𝐾2 ∫ 𝑆2 𝑑𝑡


𝑢=
𝜆1 𝑏1 + 𝑏2
25

′ +𝑢′ −𝑘 𝑆 −𝜂 tanh(10∙𝑆 )−𝐾


𝜆1 𝑢𝑒𝑞1 𝑒𝑞2 2 2 2 2 2 ∫ 𝑆2 𝑑𝑡
= (3.55)
𝜆1 𝑏1 +𝑏2

′ ′
where 𝑢𝑒𝑞1 = −(𝑐1 𝑥2 + 𝑓1 ), 𝑢𝑒𝑞2 =−(𝑐2 𝑥4 + 𝑓2 ).

Thus, Simulink model shows in Figure 3.10.

Figure 3.10: Simulink Model of Hierarchical Sliding Mode Control for Inverted Pendulum Single-Mass System
26


Figure 3.10a: Simulink Model of 𝑢𝑒𝑞1 in Hierarchical Sliding Mode Control for
Inverted Pendulum Single-Mass System


Figure 3.10b: Simulink model of 𝑢𝑒𝑞2 in Hierarchical Sliding Mode Control for

Inverted Pendulum Single-Mass System

Figure 3.10c: Simulink Model of 𝑆2 in Hierarchical Sliding Mode Control for


Inverted Pendulum Single-Mass System

Figure 3.10d: Simulink Model of SMC in Hierarchical Sliding Mode Control for
Inverted Pendulum Single-Mass System
27

2. Stability Analysis
i. Asymptotic stability
Differentiating 𝑉𝑖 with respect to time t in Eq. (3.52), then
𝑉̇𝑖 = 𝑆𝑖̇ 𝑆𝑖 (3.56)
Because
𝑆𝑖̇ = −𝑘𝑖 𝑆𝑖 − 𝜂𝑖 tanh(10 ∙ 𝑆𝑖 ) − 𝐾𝑖 ∫ 𝑆𝑖 𝑑𝑡 (3.57)
where 𝑘𝑖 , 𝜂𝑖 and 𝐾𝑖 are positive constants, we could have
𝑉̇𝑖 < 0 in D- {0} (3.58)
Because of Eq. (3.52), we could have
𝑉𝑖 > 0 in D- {0} (3.59)
According to Eqs. (3.46), (3.49), (3.50), and (3.52), we obtained
𝑉𝑖 (0) = 0 (3.60)
According to Asymptotic Stability Theorem, X=0 is asymptotically stable.

ii. Open interval of the parameter


D. Qian, J. Yi, D. Zhao (Dianwei Qian, Jianqiang Yi and Dongbin Zhao, 2008) have
developed a theorem that the parameter of the ith-subsystem sliding surface should be
convergent to an open interval [16]. From Eqs. (3.47) and (3.48), we have

𝑐1 = |(𝑓1 + 𝑏1 𝑢𝑒𝑞1 )/𝑥2 | ≤ (|𝑓1 | + |𝑏1 𝑢𝑒𝑞1 |)/|𝑥2 |

𝑐2 = |(𝑓2 + 𝑏2 𝑢𝑒𝑞2 )/𝑥4 | ≤ (|𝑓2 | + |𝑏2 𝑢𝑒𝑞2 |)/|𝑥4 | (3.61)

They said that when the states of the subsystem keep sliding on its own sliding
surface and converge to a certain neighborhood of the origin, the subsystem can be
treated as an autonomous system [16]. Hence,
𝑐1 < |𝑓1 /𝑥2 |
𝑐2 < |𝑓2 /𝑥4 | (3.62)
Besides, from Eq. (3.47), there exists
𝑠̇1 = 𝑐1 𝑥̇ 1 + 𝑥̇ 2 = 0
𝑠̇2 = 𝑐2 𝑥̇ 3 + 𝑥̇ 4 = 0 (3.63)
The eigenvalue of Eq. (3.63) should be negative for guaranteeing the stability of the
28

1th and 2nd subsystem sliding surfaces[16]. Thus,


𝑐1 > 0
𝑐2 > 0 (3.64)
3. Simulation results
By selecting 𝑐1 = 43.9911, 𝑐2 = 0.1766, 𝜆1 = −0.35, 𝑘2 = 0.4, 𝜂2 = 0.0005,
𝐾2 = 240, and initial state vector 𝑿0 as [0, 0, −0.05, 0]T . Also setting initial value
of 𝑆2 as 9.1891299 in the 𝐾2 ∫ 𝑆2 𝑑𝑡 part to eliminate the overshoot, we could get
the results are shown in Figure 3.11 (MATLAB code as shown in Appendix A.5.). It
meets criteria.

Figure 3.11: Simulation Result of Robust Control for Inverted Pendulum Single-Mass
System

3.2.4 Adaptive Control


An adaptive controller is a controller with adjustable parameters and a mechanism for
adjusting the parameters [40]. This research used adaptive PID & adaptive
hierarchical sliding mode control for the system. At first the gain values of PI
controller, 𝐾𝑝 and 𝐾𝑖 , have been designed to be a function of time and are given as

follows [1]:

𝐾𝑝 = 𝐾𝑝0 + ∆𝐾𝑝 e−𝑘𝑡


29

𝐾𝑖 = 𝐾𝑖0 − ∆𝐾𝑖 e−𝑘𝑡 (3.65)


where 𝐾𝑝0 , ∆𝐾𝑝 , 𝐾𝑖0 , ∆𝐾𝑖 and 𝑘 are all positive constants.
The adaptive PID controller has been designed as this because the value of 𝐾𝑝

should be high during the initial part of the system response to reduce the rise time of
the system and low during the later stages to overcome overshoot and the settling time
[1]. 𝐾𝑖 should be large as time approaches infinity and small during the initial stage
to remove the offset. Thus, the constants 𝑘2 and 𝐾2 in Eq. (3.55) become as

𝑘2 = 𝐾2 + ∆𝐾𝑝2 e−𝐾𝑝2 𝑡

𝐾2 = 𝐾𝐼 − ∆𝐾𝐼2 e−𝐾𝐼2 𝑡 (3.66)


The constants 𝑐1 and 𝑐2 in Eq. (3.46) can be designed to be a function of time as
𝑐1 = 𝑐10 − ∆𝑐1 e−𝑘𝑐1𝑡
𝑐2 = 𝑐20 + ∆𝑐2 e−𝑘𝑐2 𝑡 (3.67)
Submitting Eqs. (3.66) and (3.67) into Eq. (3.55), and selecting 𝐾2 = 0.5, ∆𝐾𝑝2 =
15, 𝐾𝑝2 = 0.1, 𝐾𝐼 = 320, ∆𝐾𝐼2 = 1, 𝐾𝐼2 = 0.3, 𝑐10 = 43.9911, ∆𝑐1 = 3, 𝑘𝑐1 =

0.1 , 𝑐20 = 0.1766 , ∆𝑐2 = 10 , and 𝑘𝑐2 = 150 , the performance of the system
response could be shown in Figure 3.12 (see code as Appendix A.6.). Compared with
Figure 3.12, the settling time has been reduced.

Figure 3.12: Simulation Result of Adaptive Control for Inverted Pendulum


Single-Mass System
30

3.3 Experiment

Figure 3.13: Experimental Inverted Pendulum Single-Mass System (Built on Quanser


IP02 and LFJ Platforms)

1. Laboratory Equipment
The list of major components in the experimental inverted pendulum single-mass
system is provided in Table 1.

ID Description ID Description
1 IP02 Cart 11 IP02 Pendulum Encoder Connector
2 Stainless Steel Shaft 12 Motor Connector
3 Rack 13 Coreless DC Motor
4 Cart Position Pinion 14 Planetary Gearbox
5 Cart Motor Pinion 15 Linear Bearing
6 Cart Motor Pinion Shaft 16 IP02 Weight
7 Pendulum 17 Power Amplifier
8 IP02 Cart Encoder 18 Terminal Board
9 IP02 Pendulum Encoder 19 PCI Data Acquisition Card
10 IP02 Cart Encoder Connector
Table1: Major components in the experimental inverted pendulum single-mass
system
31

i. IP02 Cart
The IP02 consists of a cart driven by a coreless DC motor equipped with a planetary
gearbox. The cart slides along a stainless steel shaft using linear bearings[41]. There is
a rotary joint to which a free-swinging pendulum can be attached and suspended in
front of the cart.

(a) Front View [32]

(b) Bottom View


Figure 3.14: IP02 Components

ii. DC Motor
The IP02 utilizes a coreless DC motor, as shown in Figure 3.14b and its nominal
properties shown in Table 2.
32

Property Value
Nominal Voltage 6 [V]

Back-EMF Constant, 𝐾𝐵 0.804 [mV/rpm]

Torque Constant, 𝐾𝑡 1.088 [oz-in/A]

Resistance, 𝑅𝑎 2.6 [Ω]


Inductance, 𝐿𝑎 180 [μH]

Rotor Inertia, 𝐽𝑚 5.523e-5 [oz-in-s 2 ]


Mass 2.47 [oz]
Recommended Max Speed 6000 [rpm]

Recommended Max Torque 0.566 [oz-in]


Recommended Max Current 1 [A]
Table 2: Nominal properties of coreless DC motor [32]

iii. Planetary Gearbox


The coreless DC motor is coupled to a planetary gearbox, as shown in Figure 3.14b,
and its nominal properties shown in Table 3.

Property Value
Gear Ratio, N 3.71
Mass 2.12 [oz]

Max Torque 28.32 [oz-in] Continuous


56.65 [oz-in] Intermittent
Table 3: Properties of planetary gearbox [32]

iv. Encoders
Both cart and pendulum positions are measured with two ball bearing guided
incremental optical encoders in this system. The encoder model used in the IP02 is a
US Digital S1 single-ended optical shaft encoder with 4096 counts per revolution.
The properties are shown in Table 4.
33

Encoder Resolution Mass


Cart Encoder 1024 cycles per revolution 2.275e-5 0.7 [oz]
(4.96 counts per revolution) [m/count]
Pendulum Encoder 1024 cycles per revolution 0.0015 0.7 [oz]
(4.96 counts per revolution) [rad/count]
Table 4: Properties of gantry encoders [32]

v. PCI Data Acquisition Card


A Quanser Q4 PCI Data acquisition card (shown in Figure 3.15) has been used to
connect and control the devices instrumented with analog and digital sensors and
encoders. The Q4 includes all the I/O shown in Table 5[32].

Figure 3.15: Quanser Q4 PCI Data Acquisition Card [42]

Number Resolution Voltage Range Comments


Analog 4 14-bit ±10 V AI and
Inputs (A/D) Encoders
sampled
simultaneously
Analog 4 12-bit ±10 V, ±5 V, Samples all AO
Outputs 0-10 V simultaneously
(D/A) configurable
Encoder 4 24-bit count values AI and
Inputs (Quadrature and Encoders
34

others) sampled
simultaneously
Counters 2 32-bit max (varies PWM from
(PWM) with frequency) 0.008Hz to
16.7 MHz
Digital I/O 16
Table 5: Quanser Q4 Data acquisition PCI card I/O [32]

vi. Power Amplifier


A Universal Power Module UPM-1503 (shown in Table 6) has been used as a power
amplifier to drive DC motor. As shown in Figure 3.16, it consists of one ±12 volt
power supply, 4 analog sensor inputs, and one power amplified analog output.

Figure 3.16: Universal Power Module UPM-1503

Maximum Maximum Output Type Number of


Output continuous Outputs
Voltage Current
15 3 Linear Voltage 1
Table 6: UPM-15-03 Power Modules [43]

vii. Terminal Board


A Q4 Terminal Board has been used to interface with cables carrying signals from /to
sensors, actuators, and signal conditioners from the PCI card I/O.
35

Figure 3.17: Q4 Terminal Board

2. Experimental result
Figure 3.18 shows the experimental result of LQR control. We can see there is more
oscillations than the simulation result, because there are many disturbance inputs in
real-time environment, such as noises. But fortunately, the pendulum could always up,
even though the results are not perfect. It proves that even though LQR control is a
linear controller, it can work for nonlinear system. Figure 3.19 shows the
experimental result of hierarchical sliding mode control. Compared with Figure 3.18,
we can see it has decreased oscillations greatly. Figure 3.20 shows the experimental
result of adaptive control after changed some gain values. Compared to Figure 3.19,
the settling time has been decreased but it has more oscillations.

Figure 3.18: Experimental Result of LQR Controller for Inverted Pendulum


Single-Mass System
36

Figure 3.19: Experimental Result of Robust Control for Inverted Pendulum


Single-Mass System

Figure 3.20: Experimental Result of Adaptive Control for Inverted Pendulum


Single-Mass System
37

Chapter 4
Dynamic Modeling and Control of Inverted Pendulum
Double-Mass System
In this chapter, PID, LQR, robust and adaptive controllers have been presented for
inverted pendulum double-mass system. The inverted pendulum double-mass system
may be represented schematically as depicted by Figure 4.1 and consists of two carts
moving along a rail: (i) a passive cart with a free-swinging pendulum attached
through a spring and a damper to (ii) an active cart with a DC motor and gearbox as
used in the Chapter 3. The system includes three sensors for measuring the pendulum
angle, the active cart position and passive cart position. All the parameter values
required to perform controller design and system simulations are provided in
Appendix B.1.

Section 4.1 presents how to derive the complete system dynamics by determining the
equations of motion for the electrical, mechanical and combined systems. Following
this, in Section 4.2 PID, LQR, robust, and adaptive controllers have been designed to
make sure the pendulum could keep inverted position while the base mass moving to
the desired position. Section 4.3 discusses the simulation results.

Figure 4.1: Inverted Pendulum Double-Mass System


38

4.1 Dynamic Molding of Inverted Pendulum Double-Mass System


1. Equations of Motion
i. DC Motor
As we discussed in Section 3.1, the equations of DC motor current and DC motor gear
angle could be shown as,
𝑑 𝑁𝐾𝐵
𝑅𝑎 𝑖𝑎 (𝑡) + 𝐿𝑎 (𝑑𝑡 𝑖𝑎 (𝑡)) + 𝑥̇ 𝑎 = 𝑣𝐴 (𝑡) (4.1)
𝑟𝑔

𝑓𝑐 𝑟𝑔
𝐽𝑚 𝑁𝜃𝑔̈ (𝑡) + 𝐵𝑚 𝑁𝜃𝑔̇ (𝑡) = 𝐾𝑡 𝑖𝑎 (𝑡) − 𝑁 (4.2)

where 𝑅𝑎 and 𝐿𝑎 represent armature resistance and armature inductance,


𝑖𝑎 (𝑡) and 𝑣𝐴 (𝑡) represent the motor current draw and the applied voltage respectively,

N is the gear ratio of the planetary gearbox, 𝐾𝐵 is the motor speed coefficient, 𝜃̇g is

the rotational velocity of the motor pinion gear, constants 𝐽𝑚 and 𝐵𝑚 represent the
rotor inertia and the damping acting on the rotor, 𝐾𝑡 is the motor torque constant, 𝑓𝑐
is the reaction force applied to the motor pinion gear by the rack, and 𝑟𝑔 is the radius

of the motor pinion gear.

ii. Passive Cart Position

Figure 4.2: Linearized External Forces Affecting the Passive Cart


39

Figure 4.3: Linearized External Force Affecting the Pendulum

As we discussed in Section 3.1, the velocity and acceleration of the center of gravity
of the pendulum can be found with respect to an inertial reference frame as,
𝐿𝑃 𝐿
𝐯⃗p = (𝑥̇ 𝑐 − 𝜃̇𝑝 cos(𝜃𝑝 )) 𝐢̂ − 2𝑃 𝜃̇𝑝 sin(𝜃𝑝 ) 𝐣̂ (4.3)
2

𝐿𝑃 𝐿𝑃 𝐿𝑃 𝐿𝑃
𝐚⃗𝐩 = (𝑥̈ 𝑐 − 𝜃̈𝑝 cos(𝜃𝑝 ) + 𝜃̇𝑝2 sin(𝜃𝑝 )) 𝐢̂ − ( 𝜃̈𝑝 sin(𝜃𝑝 ) + 𝜃̇𝑝2 cos(𝜃𝑝 )) 𝐣̂
2 2 2 2
(4.4)
Considering the sum of the forces of passive cart in the x-direction as,
∑ 𝐹𝑥 = 𝑀𝑐 𝑥̈ 𝑐 + 𝑀𝑝 𝑎𝑝𝑥 (4.5)

The free body diagram given in Figure 4.1 can be expanded as,
𝐿𝑃 𝐿
(𝑀𝑐 + 𝑀𝑝 ) 𝑥̈ 𝑐 − 𝑀𝑝 𝜃̈𝑝 cos(𝜃𝑝 ) − 𝐵𝑓 𝑥̇ 𝑎 + (𝐵𝑓 + 𝐵𝑐 ) 𝑥̇ 𝑐 + 𝑀𝑝 2𝑃 𝜃̇𝑝2 sin(𝜃𝑝 ) + 𝑓𝑘
2

= 𝐾 (𝑥𝑎 − 𝑥𝑐 ) (4.6)
where 𝑓𝑘 = 𝑏2 sign(𝑥̇ 𝑐 )
Here, 𝑀𝑐 and 𝑀𝑝 represent the masses of passive cart and pendulum respectively,

𝐵𝑐 is the damping coefficient observed by the cart, 𝐿𝑃 is the full length of the
pendulum, 𝑥𝑐 and 𝑥𝑎 is the position of passive and active cart in the x direction, 𝜃𝑝

is the counterclockwise angle of the pendulum with respect to the initial vertical line,
𝑓𝑘 respects coulomb observed by the passive cart, 𝑏2 is coulomb friction coefficient
affecting passive cart, K is the stiffness of the flexible joint, and 𝐵𝑓 is the viscous

friction coefficient of the flexible joint.

iii. Active Cart Position


40

Figure 4.4: Linearized External Forces Affecting the Active Cart

Since we could have the sum of the forces of active cart in the x-direction as,
∑ 𝐹𝑥 = 𝑀𝑎 𝑥̈ 𝑎 (4.7)
Considering this equation and the free body diagram given in Figure 4.4, this may be
expanded as,

𝑀𝑎 𝑥̈ 𝑎 + (𝐵𝑐 + 𝐵𝑓 )𝑥̇ 𝑎 − 𝐵𝑓 𝑥̇ 𝑐 + 𝐾 𝑥𝑎 − 𝐾 𝑥𝑐 + 𝑓𝑘 − 𝑓𝑐 = 0 (4.8)

where 𝑓𝑘 = 𝑏1 sign(𝑥̇ 𝑎 )
Here, 𝑀𝑎 and 𝑀𝑝 represent the masses of active cart and pendulum respectively, 𝐵𝑐

is the damping coefficient observed by the cart, 𝐿𝑃 is the full length of the
pendulum, 𝑥𝑎 and 𝑥𝑐 is the position of active and passive cart in the x direction, 𝜃𝑝

is the counterclockwise angle of the pendulum with respect to the initial vertical line,
𝑓𝑘 respects coulomb observed by the active cart, 𝑏1 is coulomb friction coefficient
affecting active cart, K is the stiffness of the flexible joint, and 𝐵𝑓 is the viscous

friction coefficient of the flexible joint.

iv. Pendulum Angle


As we discussed in Chapter 3, we could get the last equation of motion as,
1 𝐿 𝐿
𝑀𝑝 𝐿2𝑝 𝜃̈𝑝 − 𝑀𝑝 2𝑃 𝑥̈ 𝑐 + 𝐵𝑝 𝜃̇𝑝 − 𝑀𝑝 𝑔 2𝑃 sin(𝜃𝑝 ) = 0 (4.9)
3

where 𝐵𝑝 is the damping coefficient affecting the pendulum.

v. Simplify Carts and Pendulum Equations


Controllers will be designed to make sure the pendulum angle are very small, so the
nonlinear cart and pendulum dynamics may be simplified by
41

sin(𝜃𝑝 ) = 𝜃𝑝 (4.10a)

cos(𝜃𝑝 ) = 1 (4.10b)

Submitting Eqs. (4.10a) and (4.10b) into Eqs. (4.6) and (4.9), and removed the higher
order terms, the equations can be expressed as

𝑀𝑐 𝑥̈ 𝑎 + (𝐵𝑐 + 𝐵𝑓 )𝑥̇ 𝑎 − 𝐵𝑓 𝑥̇ 𝑐 + 𝐾 𝑥𝑎 − 𝐾 𝑥𝑐 + 𝑏1 sign(𝑥̇ 𝑎 ) = 𝑓𝑐 (4.11)

𝐿𝑃
(𝑀𝑐 + 𝑀𝑝 ) 𝑥̈ 𝑐 − 𝑀𝑝 𝜃̈𝑝 − 𝐵𝑓 𝑥̇ 𝑎 + (𝐵𝑓 + 𝐵𝑐 ) 𝑥̇ 𝑐 − 𝐾 𝑥𝑎 + 𝐾 𝑥𝑐 + 𝑏 sign(𝑥̇ 𝑐 ) = 0
2

(4.12)
1 𝐿𝑃 𝐿𝑃
𝑀 𝐿2 𝜃̈ + 𝐵𝑝 𝜃̇𝑝 − 𝑀𝑝 𝑥̈ 𝑐 − 𝑀𝑝 𝑔 𝜃𝑝 = 0 (4.13)
3 𝑝 𝑝 𝑝 2 2

vi. Combined Transfer Function


From Eq. (4.2) we could have
𝑁2 𝑁 2𝑁
𝑓𝑐 = −𝐽𝑚 𝜃̈𝑝 − 𝐵𝑚 𝑟 𝜃̇𝑝 + 𝑟 𝐾𝑡 𝑖𝑎 (4.14)
𝑟𝑔 𝑔 𝑔

By substituting Eq. (4.14) into Eq. (4.11), and realizing that the angle of the motor
𝑥𝑐
pinion gear may be written as 𝜃𝑝 = , Eq. (4.11) may be rewritten as,
𝑟𝑔

𝑁2 𝑁2
(𝑀𝑐 + 𝐽𝑚 ) 𝑥̈ + (𝐵 + 𝐵 + 𝐵𝑚 2 ) 𝑥̇ 𝑎 − 𝐵𝑓 𝑥̇ 𝑐 + 𝐾 𝑥𝑎 − 𝐾 𝑥𝑐 + 𝑏1 sign(𝑥̇ 𝑎 )
𝑟𝑔 2 𝑎 𝑐 𝑓
𝑟𝑔
𝑁
− 𝑟 𝐾𝑡 𝑖𝑎 (𝑡) = 0 (4.15)
𝑔

Thus, all the equations of motion can be expressed as,


𝑑 𝑁𝐾𝐵
𝑅𝑎 𝑖𝑎 (𝑡) + 𝐿𝑎 (𝑑𝑡 𝑖𝑎 (𝑡)) + 𝑥̇ 𝑎 = 𝑣𝐴 (𝑡) (4.16)
𝑟𝑔

1 𝐿𝑃 𝐿𝑃
𝑀 𝐿2 𝜃̈ − 𝑀𝑝 𝑥̈ 𝑐 + 𝐵𝑝 𝜃̇𝑝 − 𝑀𝑝 𝑔 𝜃𝑝 = 0 (4.17)
3 𝑝 𝑝 𝑝 2 2

𝐿𝑃
(𝑀𝑐 + 𝑀𝑝 ) 𝑥̈ 𝑐 − 𝑀𝑝 𝜃̈𝑝 − 𝐵𝑓 𝑥̇ 𝑎 + (𝐵𝑓 + 𝐵𝑐 ) 𝑥̇ 𝑐 − 𝐾 𝑥𝑎 + 𝐾 𝑥𝑐 + 𝑏2 sign(𝑥̇ 𝑐 ) = 0
2

(4.18)

𝑁2 𝑁2
(𝑀𝑐 + 𝐽𝑚 ) 𝑥̈ 𝑎 + (𝐵𝑐 + 𝐵𝑓 + 𝐵𝑚 ) 𝑥̇ 𝑎 − 𝐵𝑓 𝑥̇ 𝑐 + 𝐾 𝑥𝑎 − 𝐾 𝑥𝑐 + 𝑏1 sign(𝑥̇ 𝑎 )
𝑟𝑔 𝑟𝑔
𝑁
− 𝑟 𝐾𝑡 𝑖𝑎 (𝑡) = 0 (4.19)
𝑔
42

2. Build Mode in Simulink


Simulink model of the system shows in Figure 4.5. The value of each symbol has
been applied (see Appendix B.1.).

Figure 4.5: Simulink Model of Inverted Pendulum Double-Mass System

3. Open-loop Transfer Functions


With the help of Maple, the open-loop transfer function relating the position of the
43

cart 𝑥𝑎 , 𝑥c and pendulum angle 𝜃p to the applied motor voltage 𝑣𝐴 can be found.

The results can be shown as below (see Appendix B.2. for the process of calculating):
𝑥𝑎 ’s open-loop transfer function can be expressed as:
𝑿𝒂
1.12 ∗ 1018 ∗ (4.77 ∗ 1018 ∙ s 4 + 1.32 ∗ 1013 ∙ s 3 + 4.6 ∗ 1014 ∙ s 2 − 1.21 ∗ 1014 ∙ s − 2.98 ∗ 1016 )
=
2.35 ∗ 1026 ∙ s 7 + 3.39 ∗ 1030 ∙ s 6 + 5.92 ∗ 1031 ∙ s 5 + 8.9 ∗ 1032 ∙ s 4 + 3.97 ∗ 1033 ∙ s 3 − 4.34 ∗ 1034 ∙ s 2 − 2.68 ∗ 1035 ∙ s

(4.20)
𝑥𝑐 ’s open-loop transfer function can be expressed as:
𝑿𝒄
2.24 ∗ 1020 ∗ (4.81 ∗ 109 ∙ s 2 + 2.4 ∗ 109 ∙ s − 2.1 ∗ 1011 ) ∙ (11 ∙ s + 710)
=
2.35 ∗ 1026 ∙ s 7 + 3.39 ∗ 1030 ∙ s 6 + 5.92 ∗ 1031 ∙ s 5 + 8.9 ∗ 1032 ∙ s 4 + 3.97 ∗ 1033 ∙ s 3 − 4.34 ∗ 1034 ∙ s 2 − 2.68 ∗ 1035 ∙ s

(4.21)
𝜃𝑝 's open-loop transfer function can be expressed as:
𝛉𝐩
30
4.79 ∗ 10 ∙ s ∙ (11 ∙ s + 710)
=
26 6 30 5 31
2.35 ∗ 10 ∙ s + 3.39 ∗ 10 ∙ s + 5.92 ∗ 10 ∙ s + 8.9 ∗ 1032 ∙ s3 + 3.97 ∗ 1033 ∙ s2 − 4.34 ∗ 1034 ∙ s − 2.68 ∗ 1035
4

(4.22)

4. Stability
For 𝑥𝑎 ’s, 𝑥𝑐 ’s and 𝜃𝑝 's transfer function, the poles and zeros can be found simply by

using Maple (see Appendix B.2. for the process of calculating):


𝑥𝑎 :
Zeros: 6.423776181, −1.117810518+11.77599544i, −6.955610047,
−1.117810518−11.77599544i
Poles: 0, 0, 6.469034991, −4.568631367+14.4109187i, −6.342778315,
−8.464477867, −14437.37167, −4.568631367−14.410901871i
𝑥𝑐 :
Zeros: 6.363041647, −6.862235207, −64.54545452
Poles: 0, 6.469034991, −4.568631367+14.4109187i, −6.342778315,
−8.464477867, −14437.37167, −4.568631367−14.410901871i

𝜃p :
44

Zeros: 0, −64.54545455
Poles: 6.469034991, −4.568631367+14.4109187i, −6.342778315,
−8.464477867, −14437.37167, −4.568631367−14.410901871i

It shows that there is one pole at right-hand plane for 𝑥𝑎 , 𝑥𝑐 and 𝜃p , so the system

is unstable.

5. State-Space Representation
Using the differential equations, the state-space representation of the open loop
dynamics can be developed as Eqs. (4.23) and (4.24) (see Appendix B.2. for the
process of calculating). The input is voltage (𝑣𝐴 (t)), the outputs are carts' position
( 𝑥𝑎 (t), 𝑥𝑐 (t)) and the pendulum angle (𝜃𝑝 (t)).
𝑑𝑖𝑎 (𝑡)
𝑖𝑎 (𝑡) 50000
𝑑𝑡 −14444.44 0 −24895.63 0 0 0 0
0 0 1 0 0 0 0 𝑥𝑎 (𝑡) 9
𝑥̇ 𝑎 (𝑡)
𝑥̇ 𝑎 (𝑡) 0
𝑥̈ 𝑎 (𝑡) 4.099 −129.90 −7.635 129.90 2.01 0 0
= 𝑥𝑐 (𝑡) + 0 𝑣𝑎 (𝑡)
𝑥̇ 𝑐 (𝑡) 0 0 0 0 1 0 0
𝑥̇ (𝑡) 0
𝑥̈ 𝑐 (𝑡) 0 143.18 2.218 −143.18 −2.22 0.94 −0.01 𝑐
𝜃𝑝 (𝑡) 0
0 0 0 0 0 0 1
𝜃̇𝑝 (𝑡) [ ] 0
0 637.31 9.874 −637.31 −9.88 47.86 −0.55 [𝜃̇𝑝 (𝑡) ] [
[ 𝜃̈𝑝 (𝑡) ] 0 ]

(4.23)
𝑖𝑎 (𝑡)
𝑥𝑎 (𝑡)
𝑥𝑎 (𝑡) 0 1 0 0 0 0 0 𝑥̇ 𝑎 (𝑡)
𝑥 (𝑡)
[ 𝑐 ]= [0 0 0 1 0 0 0] 𝑥𝑐 (𝑡) + [0]𝑣𝐴 (t) (4.24)
𝜃𝑝 (𝑡) 0 0 0 0 0 1 0 𝑥̇ 𝑐 (𝑡)
𝜃𝑝 (𝑡)
[𝜃̇𝑝 (𝑡)]

4.2 Controllers Design


4.2.1 PID Control
To make the performance of the system meet the criterion, a PID controller has been
added to the closed loop between active cart position error and motor voltage under
negative unity feedback. The block diagram is shown in Figure 4.6. This research
used MATLAB/PID Tuner to get the value of 𝐾𝑝 , 𝐾𝑖 and 𝐾𝑑 shown in Figure 4.7
(see the code in Appendix B.3.). Unfortunately, it shows that PID control does not
work for this system.
45

Figure 4.6: PID Control of Inverted Pendulum Single-Mass System

Figure 4.7: Using MATLAB/PID Tuner to design a PID Controller for Inverted
Pendulum Double-Mass System

4.2.2 Optimal Control


1. Controllability and Observability
To make the system stable and reach design requirements, this study designed a LQR
controller. Before that we must check the controllability and observability of the
system. The determinate of controllability matrix and observability matrix can be
obtained as follows (see the code in Appendix B.5.):
det(𝑀𝑐 ) = −2.3904 ∗ 1014 ≠ 0 (4.25)
det(𝑀𝑜 ) = −1 ≠ 0 (4.26)
Thus, the matrices are of full rank and the system is controllable and observable.
46

2. LQR Controller Design


Simulink model shows in Figure 4.8 (see the code in Appendix B.4.). By choosing
R=0.15/36 and

32 0 0 0 0 0
0 0.5 0 0 0 0
0 0 19 0 0 0
𝑄=
0 0 0 2 0 0
0 0 0 0 1700 0
[0 0 0 0 0 0.4]
the LQR gain vector can be obtained as following:
𝑘 = [1182.2 38.6 −1292.9 −181.7 885.9 87.8]
and

231 158 8
1717 30913 −15293
−126 220 30
𝐿=
3983 43544 −24194
−91 −26 315
[−5718 −51761 29729 ]
1
To decrease oscillations, three filters are designed as . The response of the
(0.0008s+1)2

system shows in Figure 4.9. There are a lot of oscillations. When the cart stops
moving, the pendulum would fall. Here, the order of current has been reduced by
omitting inductance, because the observer needs to be very fast to make the system
stable with inductance, and it is hard to be realized in the experiment.
Figure 4.8: Simulink Model of LQR Control for Inverted Pendulum Double-Mass System
47
48

Figure 4.9: Inverted Pendulum Double-Mass System Response of LQR Control

4.2.3 Robust Control


According to the inverted pendulum double-mass system physical structure can be
divided in to three subsystems: pendulum, passive cart and active cart, hierarchical
sliding mode control is developed for the system.

1. Hierarchical sliding mode control design


Consider the state space expression of the class of SIMO under-actuated systems with
n subsystems in the following normal form [16]:
𝑥̇ 1 =𝑥2
𝑥̇ 2 =𝑓1 +𝑏1 𝑢
𝑥̇ 3 =𝑥4
𝑥̇ 4 =𝑓2 +𝑏2 𝑢 (4.27)
𝑥̇ 5 =𝑥6
𝑥̇ 6 =𝑓3 +𝑏3 𝑢

{ …
Here, 𝐗 = [𝑥1 , 𝑥2 , … , 𝑥2𝑛 ]T is the state variable vector; 𝑓𝑖 and 𝑏𝑖 (i=1, 2, ..., n) are
the nonlinear functions of the state vector; and u is the single control input. For
inverted pendulum double-mass system, we can set
49

𝑥1 =𝜃𝑝
𝑥2 =𝜃̇𝑝
𝑥3 =𝑥𝑐 (4.28)
𝑥4 =𝑥̇ 𝑐
𝑥5 =𝑥𝑎
{𝑥6 =𝑥̇ 𝑎
Where 𝜃𝑝 is pendulum angle, 𝑥𝑐 is passive cart position, and 𝑥𝑎 is active cart

position.
Define the sliding surface as [16]
𝑠1 = 𝑐1 𝑥1 + 𝑥2
𝑠2 = 𝑐2 𝑥3 + 𝑥4
𝑠3 = 𝑐3 𝑥5 + 𝑥6 (4.29)
where 𝑐1, 𝑐2 and 𝑐3 are positive constant.
Differentiate 𝑠1 , 𝑠2 and 𝑠3 with respect to time t, then [16],
ṡ 1 = c1 ẋ 1 + ẋ 2 =c1 x2 + f1 + b1 u
ṡ 2 = c2 ẋ 3 + ẋ 4 =c2 x4 + f2 + b2 u
ṡ 3 = c3 ẋ 5 + ẋ 6 =c3 x6 + f3 + b3 u (4.30)
Lets 𝑠̇𝑖 = 0 in Eqs. (4.30), the equivalent control of the 1th, 2nd and 3rd subsystem
are obtained as [16]
𝑢𝑒𝑞1 = −(𝑐1 𝑥2 + 𝑓1 )/ 𝑏1
𝑢𝑒𝑞2 = −(𝑐2 𝑥4 + 𝑓2 )/ 𝑏2
𝑢𝑒𝑞3 = −(𝑐3 𝑥6 + 𝑓3 )/ 𝑏3 (4.31)

Define the 1th layer sliding surface as [16]


𝑆1 = 𝑠1 (4.32)
the 2nd layer sliding surface as [16]
𝑆2 = 𝜆1 𝑆1 + 𝑠2 (4.33)
and the 3rd layer sliding surface as [16]
𝑆3 = 𝜆2 𝑆2 + 𝑠3 (4.34)
where 𝜆1 and 𝜆2 are all constants.
Differentiate 𝑆1, 𝑆2 and 𝑆3 with respect to time t in Eqs. (4.32), (4.33) and (4.34),
then

𝑆1̇ = 𝑠̇1 = 𝑐1 𝑥̇ 1 + 𝑥̇ 2
50

𝑆2̇ = 𝜆1 𝑆1̇ + 𝑠̇2 = 𝜆1 (𝑐1 𝑥̇ 1 + 𝑥̇ 2 ) + 𝑐2 𝑥4 + 𝑓2 + 𝑏2 𝑢


𝑆3̇ = 𝜆2 𝑆2̇ + 𝑠̇3 = 𝜆2 [𝜆1 (𝑐1 𝑥̇ 1 + 𝑥̇ 2 ) + 𝑐2 𝑥4 + 𝑓2 + 𝑏2 𝑢] + 𝑐3 𝑥6 + 𝑓3 + 𝑏3 𝑢
(4.35)
The Lyapunov function of the ith layer sliding surface is selected as [16]
𝑉𝑖 = 𝑆𝑖2 /2 (4.36)
By considering the stability of the ith layer sliding surface, let

𝑆𝑖̇ = −𝑘𝑖 𝑆𝑖 − 𝜂𝑖 tanh(200 ∙ 𝑆𝑖 ) (4.37)


where 𝑘𝑖 , 𝜂𝑖 and 𝐾𝑖 are positive constants.
Then

𝑆1̇ = −𝑘1 𝑆1 − 𝜂1 tanh(200 ∙ 𝑆1 )


𝑆2̇ = −𝑘2 𝑆2 − 𝜂2 tanh(200 ∙ 𝑆2 )
𝑆3̇ = −𝑘3 𝑆3 − 𝜂3 tanh(200 ∙ 𝑆3 ) (4.38)
From Eqs. (4.29), (4.30), (4.31), (4.35) and (4.38), the hierarchical sliding mode
control law can be obtained as
𝜆1 𝜆2 𝑏1 𝑢𝑒𝑞1 + 𝜆2 𝑏2 𝑢𝑒𝑞2 +𝑏3 𝑢𝑒𝑞3 − 𝑘3 𝑆3 − 𝜂3 tanh(200 ∙ 𝑆3 )
𝑢=
𝜆1 𝜆2 𝑏1 + 𝜆2 𝑏2 +𝑏3
′ +𝜆 𝑢′ +𝑢′ −𝑘 𝑆 −𝜂 tanh(200∙𝑆 )
𝜆1 𝜆2 𝑢𝑒𝑞1 2 𝑒𝑞2 𝑒𝑞3 3 3 3 3
= (4.39)
𝜆1 𝜆2 𝑏1 +𝜆2 𝑏2 +𝑏3

′ ′ ′
where 𝑢𝑒𝑞1 = −(𝑐1 𝑥2 + 𝑓1 ), 𝑢𝑒𝑞2 =−(𝑐2 𝑥4 + 𝑓2 ), 𝑢𝑒𝑞3 =−(𝑐3 𝑥6 + 𝑓3 ).

Thus, Simulink model shows in Figure 4.10.


Figure 4.10: Simulink Model of Hierarchical Sliding Mode Control for Inverted Pendulum Double-Mass System
51
52


Figure 4.10a: Simulink Model of 𝑢𝑒𝑞1 in Hierarchical Sliding Mode Control for
Inverted Pendulum Double-Mass System


Figure 4.10b: Simulink Model of 𝑢𝑒𝑞2 in Hierarchical Sliding Mode Control for

Inverted Pendulum Double-Mass System


Figure 4.10c: Simulink Model of 𝑢𝑒𝑞3 in Hierarchical Sliding Mode Control for

Inverted Pendulum Double-Mass System

Figure 4.10d: Simulink Model of 𝑆3 in Hierarchical Sliding Mode Control for


Inverted Pendulum Double-Mass System

Figure 4.10e: Simulink Model of SMC in Hierarchical Sliding Mode Control for
Inverted Pendulum Double-Mass System
53

2. Stability Analysis
i. Asymptotic stability
Differentiating 𝑉𝑖 with respect to time t in Eq. (4.36), then
𝑉̇𝑖 = 𝑆𝑖̇ 𝑆𝑖 (4.40)
Because

𝑆𝑖̇ = −𝑘𝑖 𝑆𝑖 − 𝜂𝑖 tanh(200 ∙ 𝑆𝑖 ) (4.41)


where 𝑘𝑖 , 𝜂𝑖 and 𝐾𝑖 are positive constants, we could have
𝑉̇𝑖 < 0 in D- {0} (4.42)
Because Eq. (4.36), we could have
𝑉𝑖 > 0 in D- {0} (4.43)
According to Eqs. (4.29), (4.32), (4.33), (4.34), and (4.36), we obtained
𝑉𝑖 (0) = 0 (4.44)
According to Asymptotic Stability Theorem, we could get X=0 is asymptotically
stable.

ii. Open interval of the parameter


D. Qian, J. Yi, D. Zhao (Dianwei Qian, Jianqiang Yi and Dongbin Zhao, 2008) have
developed a theorem that the parameter of the ith-subsystem sliding surface should be
convergent to an open interval [16]. From Eqs. (4.25) and (4.26), we have

𝑐1 = |(𝑓1 + 𝑏1 𝑢𝑒𝑞1 )/𝑥2 | ≤ (|𝑓1 | + |𝑏1 𝑢𝑒𝑞1 |)/|𝑥2 |

𝑐2 = |(𝑓2 + 𝑏2 𝑢𝑒𝑞2 )/𝑥4 | ≤ (|𝑓2 | + |𝑏2 𝑢𝑒𝑞2 |)/|𝑥4 |

𝑐3 = |(𝑓3 + 𝑏3 𝑢𝑒𝑞3 )/𝑥6 | ≤ (|𝑓3 | + |𝑏3 𝑢𝑒𝑞3 |)/|𝑥6 | (4.45)

They said that when the states of the subsystem keep sliding on its own sliding
surface and converge to a certain neighborhood of the origin, the subsystem can be
treated as an autonomous system [16]. Hence, we have
𝑐1 < |𝑓1 /𝑥2 |
𝑐2 < |𝑓2 /𝑥4 |
𝑐3 < |𝑓3 /𝑥6 | (4.46)
Besides, from Eq. (4.30), there exists
54

𝑠̇1 = 𝑐1 𝑥̇ 1 + 𝑥̇ 2 = 0
𝑠̇2 = 𝑐2 𝑥̇ 3 + 𝑥̇ 4 = 0
𝑠̇3 = 𝑐3 𝑥̇ 5 + 𝑥̇ 6 = 0 (4.47)
The eigenvalue of Eq. (4.29) should be negative for guaranteeing the stability of the
1th, 2nd and 3rd subsystem sliding surfaces [16]. Thus,
𝑐1 > 0
𝑐2 > 0
𝑐3 > 0 (4.48)
3. Simulation results
With the MATLAB code as shown in Appendix B.5., setting initial state vector 𝐗 𝟎 as
[0, 0, −0.044425, 0, −0.044425,0]T , and selecting 𝑐1 = 4.7302 , 𝑐2 = 0.4506 ,
𝑐3 = 2.5377, 𝜆1 = −1, 𝜆2 = −50, 𝑘3 = 8 and 𝜂3 = 17, we could get the result as
shown in Figure 4.11. It shows that the active cart moves 0.05m distance and the
pendulum always up. Wherever initial position of carts has been set, it always has a
steady-state error of 0.005575m, so initial state vector 𝐗 𝟎 can be set as
[0, 0, −0.044425, 0, −0.044425,0]T to make sure the active cart could move 0.05m.
Figure 4.11 shows that the two carts cannot move same distance, because of
deformation of the spring. The 2nd and the 3rd sliding surface cannot reach to zero at
the same time, so the 3rd layer sliding surface cannot reach to asymptotically stable
equilibrium point. It is possible to eliminate the steady state error of the 2nd layer
sliding surface. However, adding an integral controller to the sliding surface function
does not work this time, and even worse it could bring oscillations. Because from Eq.
(4.39) we can see the Integral controller cannot only affect the 2nd layer sliding
surface.
55

Figure 4.11: Simulation Result of Robust Control for Inverted Pendulum


Double-Mass System

4.2.4 Adaptive Control


This research designed an adaptive PID & adaptive hierarchical sliding mode control
for the system. At first the gain value of Proportion controller, 𝐾𝑝 , can be designed to

be a function of time as

𝐾𝑝 = 𝐾𝑝0 + ∆𝐾𝑝 𝑒 −𝑘𝑡 (4.49)

Thus, the constants 𝑘3 in Eq. (4.39) becomes as

𝑘3 = 𝐾3 + ∆𝐾𝑝3 e−𝐾𝑝3 𝑡 (4.50)

The constants 𝜂3 and 𝑐2 can be designed to be a function of time as


𝜂3 = 𝜂30 + ∆𝜂3 𝑒 −𝑘𝜂3 𝑡 (4.51)
𝑐2 = 𝑐20 + ∆𝑐2 𝑒 −𝑘𝑐2 𝑡 (4.52)
Submitting Eqs. (4.50), (4.51) and (4.52) into Eq. (4.39), and selecting 𝐾3 = 9,

∆𝐾𝑝3 = 11.5 , 𝐾𝑝3 = 1 , 𝜂30 = 17 , ∆𝜂3 = 1.1 , 𝑘𝜂3 = 2 , 𝑐20 = 0.6506 , ∆𝑐2 =

−0.5, and 𝑘𝑐2 = 3, the results are shown in Figure 4.12 (see code as Appendix B.6.).
Compare with Figure 4.11, the steady-state error and settling time have been
decreased.
56

Figure 4.12: Simulation Result of Adaptive Controller for Inverted Pendulum


Double-Mass System

4.3 Summary
In this chapter, PID, LQR, robust and adaptive control methods are applied to the
inverted pendulum double-mass system. Figure 4.7 shows that PID control cannot
work for this system. In Figure 4.9, the performance of LQR controller has a lot of
oscillations and that would cause the pendulum fall when the carts stop moving.
Figure 4.11 presents that hierarchical sliding mode technique can meet our
requirements but it exists steady-state error. By designing an adaptive controller, the
performance of the system can be improved, such as the steady-state error and settling
time have been decreased (as shown in Figure 4.12).
57

Chapter 5 Discussions and Results


From all discussions before, we can get results shown in Table 7. Simple PID
controller cannot give the efficient solution to inverted pendulum single-mass system
or inverted pendulum double-mass system, because the two systems include
nonlinearities, coupling, and uncertain dynamics. However, theory of PID controller
is very important, which we can apply it to other control methods. For example, this
study applied proportional and integral control theory to hierarchical sliding mode
control while designing the ith layer sliding surface function.

LQR controller can work for simple nonlinear system, such as inverted pendulum
double-mass system, but when the nonlinear system become complex, it cannot give a
satisfactory result, such as the inverted pendulum double-mass system. Figure 3.9,
Figure 3.18 and Figure 4.9 show that it has oscillations using LQR approach for the
two systems.

Hierarchical sliding mode control could give a better result than PID and LQR control
for nonlinear system. But there still exist some weak points, such as how to eliminate
steady-state error and select the controller parameters. An integral controller can be
helpful to eliminate steady-state error when the system does not include an elastic
object that could stores mechanical energy, such as spring. For example, Figure 3.11
and Figure 3.19 show that an integral controller can eliminate the steady-state error
for the inverted pendulum single-mass system. However, it cannot work for the
inverted pendulum double-mass system. Moreover, the more complex a system
becomes, the more difficult to select the controller parameters, especially for the
real-time experimental environment.

Adaptive control can improve the performance of the system response. Figure 4.12
shows that compared with the robust control was designed, adaptive control has
decreased the steady state error and settling time. Figure 3.12 and Figure 3.20 show
58

that the inverted pendulum single-mass system can reach the desired position quickly
by using adaptive control.

Inverted Pendulum Inverted Pendulum


Single-Mass System Double-Mass System
PID Control × ×
LQR Control ○ ×
Robust Control ○ ○
Adaptive Control ○ ○
Table 7: Results
59

Chapter 6 Future Work


There are some improvements can be pursued for further investigation. There are
some options and suggestions for the future study directions below.

1. Investigation on adaptive control by using different function of time instead of


the gain values
Compared with Figure 3.11, even though the performance of adaptive control (shown
in Figure 3.12) has less settling time, it has more oscillations. Thus, it is possible to
expand the investigation on different function of time instead of the gain values, such
as 𝑘2 and 𝐾2 in Eq. (3.55), 𝑐1 and 𝑐2 in Eq. (3.46). Furthermore, one might get
better simulation result and experimental result than the results shown in Figure 3.12
and Figure 3.20.

2. Investigation on selecting parameters of hierarchical sliding mode control


In Section 4.2.3 and Section 4.3.4, the parameters chose cannot work in the
experiment. It is possible to expand the investigation on different parameters to get
satisfactory experimental results.

3. Investigation on adaptive control by designing function of time instead of other


parameters
Figure 4.12 of Chapter shows that the steady-state error has been decreased greatly.
Because of the deformation of the spring, the steady-state error of the 3rd layer sliding
surface cannot be eliminated. However, it is possible to develop function of time
instead of other parameters to eliminate the steady-state error of the 2nd layer sliding
surface.
60

REFERENCES
[1] Vikram Chopra, Sunil K. Singla and Lillie Dewan, ''Stabilization of an X-Y
inverted pendulum using adaptive gain scheduling PID controllers,'' Engineering
Research, vol. 3, no. 2, pp. 59-78, July 2015.
[2] Chaio-Shiung Chen and Wen-Liang Chen, ''Robust adaptive sliding-mode control
using fuzzy modeling for an inverted-pendulum system,'' IEEE transactions on
industrial electronics, vol. 45, no. 2, pp.297-306, April 1998.
[3] LI Ming, ''Self-adaptive Fuzzy PID Digital Control Method for Linear Inverted
Pendulum,'' Proceedings of the 31st Chinese Control Conference, Hefei, China, 2012,
pp. 3563-3567.
[4] Lal Bahadur Prasad, Barjeev Tyagi, and Hari Om Gupta. (2011, Nov). Optimal
control of nonlinear inverted pendulum dynamical system with disturbance input
using PID controller & LQR. Presented at 2011 IEEE International Conference on
Control System, Computing and Engineering. Available:
https://ieeexplore.ieee.org/document/6190585/.
[5] S. Omatu, T. Fujinaka, and M. Yoshioka. (2000, Oct.). Neuro-PID control for
inverted single and double pendulums. Presented at 2000 IEEE International
Conference on Systems, Man, and Cybernetics. Available:
https://ieeexplore.ieee.org/abstract/document/884401/
[6] T. Fujinaka, Y. Kishida, and M. Yoshioka, ''Stabilization of double inverted
pendulum with self-tuning neuro-PID,'' in IEEE-INNS-ENNS International Joint
Conference on Neural Networks, Como, Italy, 2000, pp. 245-248.
[7] Mohammad El-Bardini and Ahmad M. El-Nagar. (2014, May). Interval type-2
fuzzy PID controller for uncertain nonlinear inverted pendulum system. ISA
Transactions. vol. 53(3), pp. 732-743. Available:
https://www.sciencedirect.com/science/article/pii/S0019057814000391
61

[8] Oskar Stattin, ''Optimal Control of Inverted Pendulum,'' B.S. thesis, Dept. Math.,
Royal Institute of Technology Univ., Stockholm, Sweden, 2015.
[9] Optimal control. (n.d.). Retrieved April 09, 2018 from the Optimal control Wiki:
https://en.wikipedia.org/wiki/Optimal_control.
[10] Alexander Bogdanov, ''Optimal Control of a Double Inverted Pendulum on a
Cart'', OGI School of Science & Engineering, Hillsboro, OR, Tech. Rep.
CSE-04-006, Dec. 2004
[11] Khaled Gamal Eltohamy and Chen-Yuan Kuo. (2010, Nov.). Nonlinear optimal
control of a triple link inverted pendulum with single control input. International
Journal of Control. [Online]. vol. 69(2), pp. 239-256. Available:
https://www.tandfonline.com/doi/pdf/10.1080/002071798222811?needAccess=true.
[12] Viroch Sukontanakarn and Manukid Parnichkun. (2009). Real-Time Optimal
Control for Rotary Inverted Pendulum. American Journal of Applied Sciences. vol. 6
(6), pp. 1106-1115. Available:
https://www.researchgate.net/profile/Viroch_Sukontanakarn2/publication/263091218_
PDF_ajassp200911061115_2/links/00b49539e7557e78a6000000/PDF-ajassp2009110
61115-2.pdf.
[13] Robust control. (n.d.). Retrieved April 01, 2018 from the Robust control Wiki:
https://en.wikipedia.org/wiki/Robust_control.
[14] Sliding mode control. (n.d.). Retrieved April 01, 2018 from the Sliding mode
control Wiki: https://en.wikipedia.org/wiki/Sliding_mode_control.
[15] Mun-Soo Park and Dongkyoung Chwa, ''Swing-Up and Stabilization Control of
Inverted-Pendulum Systems via Coupled Sliding-Mode Control Method,'' IEEE
Transactions on Industrial Electronics, vol. 56, Issue 9, pp. 3541 - 3555, Sept. 2009.
[16] Dianwei Qian, Jianqiang Yi and Dongbin Zhao, ''Hierarchical sliding mode
control for a class of SIMO under-actuated systems,'' Control and Cybernetics, vol. 37,
no.1, pp.159-175, March 2008.
62

[17] Dianwei Qian, Jianqiang Yi, and Dongbin Zhao, ''Hierarchical Sliding Mode
Control for Series Double Inverted Pendulums System,'' in Proc. the 2006 IEEE/RSJ
International Conference on Intelligent Robots and Systems, Beijing, China, 2006,
pp. 4977- 4982.
[18] Iven Mareels and Jan Willem Polderman, ''Introduction,'' in Adaptive Systems An
Introduction, Boston : Birkhäuser, 1996, pp. 1.
[19] Adaptive control. (n.d.). Retrieved April 01, 2018 from the Adaptive control Wiki:
https://en.wikipedia.org/wiki/Adaptive_control.
[20] T. C. Kuo, Y. J. Huang, and B. W. Hong. (2009, July). Adaptive PID with
sliding mode control for the rotary inverted pendulum system. Presented at 2009
IEEE/ASME International Conference on Advanced Intelligent Mechatronics.
Available: https://ieeexplore.ieee.org/document/5229784/
[21] Chih-Min Lin, Chung-Li, and Tao-Yuan. (2005, Oct.). Adaptive Hierarchical
Fuzzy Sliding-Mode Control for a Class of Coupling Nonlinear
Systems. Contemporary Mathematical Sciences. vol.1, no.4, pp. 177-204. Available:
https://pdfs.semanticscholar.org/a2ee/064330f71354d7567a1bae91640fdb33b930.pdf.

[22] Rong-Jong Wai, Meng-An Kuo, and Jeng-Dao Lee, ''design of cascade adaptive
fuzzy sliding-mode control for nonlinear two-axis inverted-pendulum
servomechanism,'' IEEE Transactions on Fuzzy Systems, vol. 16, issue 5, pp.
1232-1244, Oct., 2008.
[23] Chih-Min Lin and Yi-Jen Mon, ''Decoupling control by hierarchical fuzzy
sliding-mode controller,'' IEEE Transactions on Control Systems Technology, vol. 13,
no. 4, pp. 593-598, July, 2005.
[24] Chin Wang Tao, Jinshiuh Taur, Chien Ming Wang, and U.S.Chen, ''Fuzzy
hierarchical swing-up and sliding position controller for the inverted pendulum–cart
system,'' Fuzzy Sets and Systems, vol. 159, issue 20, pp. 2763-2784, Oct., 2008.
63

[25] Rong-Jong Wai, Meng-An Kuo, and Jeng-Dao Lee, ''Design of Cascade
Adaptive Fuzzy Sliding-Mode Control for Nonlinear Two-Axis Inverted-Pendulum
Servomechanism,'' IEEE Transactions on Fuzzy Systems, vol. 16, issue 5, pp.
1232-1244, Oct., 2008.
[26] Stability theory. (n.d.). Retrieved April 09, 2018 from the Stability theory Wiki:
https://en.wikipedia.org/wiki/Stability_theory.
[27] Jean-Jacques E.Slotine, Weiping Li, ''Fundamentals of Lyapunov Theroy'', in
Applied Nonlinear Control, New Jersey: Prentice Hall, 1991, pp. 40-41.
[28] David R. Merkin, ''Introduction,'' in Introduction to the Theory of Stability, New
York: Springer-Verlag, Inc, 1997, pp.2-3
[29] Anthony N. Michel, Ling Hou, and Derong Liu, ''Introduction,'' in Stability of
Dynamical Systems, 2nd ed., AG Switzerland : Springer International, 2015, pp. 4-5.
[30] Carlos Aguilar Ibañez, O. Gutiérrez Frias, and M. Suárez Castañón,
''Lyapunov-based controller for the inverted pendulum cart system,'' Nonlinear
Dynamics, vol. 40, issue 4, pp 367–374, June, 2005.
[31] M. J. Anderson and W. J. Grantham. (1989, Dec.). Lyapunov Optimal Feedback
Control of a Nonlinear Inverted Pendulum. Dynamic Systems, Measurement, and
Control. vol. 111 (4), pp. 554-558. Available:
http://dynamicsystems.asmedigitalcollection.asme.org/article.aspx?articleid=1404587
[32] Nader Jalili, '' Final Term Project: Classical Controller Design and
Implementation for A Gantry System,'' unpublished.
[33] Norman S. Nise, ''Stability'' in Control Systems Engineering, 3rd ed., New York:
John Wiley & Sons, Inc., 2000, pp. 326-327.
[34] Linear-quadratic regulator. (n.d.). Retrieved April 09, 2018 from the
Linear-quadratic regulator Wiki:
https://en.wikipedia.org/wiki/Linear%E2%80%93quadratic_regulator.
64

[35] State observer. (n.d.). Retrieved April 09, 2018 from the State observer Wiki:
https://en.wikipedia.org/wiki/State_observer.
[36] Katsuhiko Ogata, ''Control systems design in state space,'' in Modern Control
Engineering, 5th ed. 2009, New Jersey: Prentice Hall, 2009, pp. 806-808.
[37] Hassan K. Khalil, ''Lyapunov Stability ,'' in Nonlinear Systems, 3rd ed., New
Jersey: Prentice Hall, 2002, pp. 111.
[38] Bhatia, Nam Parshad; Szegő, Giorgio P, ''Stability Theory'', in Stability theory of
dynamical systems, New York: Springer-Verlag Berlin Heidelberg, 1970, pp. 56-79.
[39] Lyapunov stability. (n.d.). Retrieved April 09, 2018 from the Lyapunov stability
Wiki: https://en.wikipedia.org/wiki/Lyapunov_stability#cite_note-lyapunov-1.
[40] Karl Johan Astrom, Bjorn Witternmark, ''Introduction,'' in Adaptive Control, 2nd
ed., Reading, Mass. : Addison-Wesley, 1995, pp. 1.
[41] User Manual IP02 Base Unit Experiment, Quanser Inc, Ontario, Canada, 2012,
pp. 4-9.
[42] Quanser Inc (2017, Aug 29). Quanser Q4. Retrieved April 10, 2018 from
http://quanser-update.azurewebsites.net/quarc/documentation/q4.html.
[43] Universal Power Module 1503,1506,2405,2405-PWM User Manual, Quanser Inc,
Ontario, Canada, Available: http://www2.hawaii.edu/~gurdal/EE351L/upm.pdf.
65

APPENDIX A. Inverted Pendulum Single-Mass System


Appendix A.1. Electromechanical Parameter Values
Parameter Symbol Values Unites
Mass of the cart + weight + wires (approx.) 𝑀𝑐 0.96 Kg
Mass of the pendulum 𝑀𝑝 0.23 Kg

Length of the pendulum 𝐿𝑝 0.337 m


Radius of the motor pinion gear 𝑟𝑔 0.00635 m
Maximum cart travel length 𝐿𝑡 0.814 m
Internal gear ratio N 3.71:1 -
Motor torque constant 𝐾𝑡 0.00767 Nm/Amp
Back Electromotive-force constant 𝐾𝐵 0.00767 V.sec/rad

Motor input voltage range 𝑣𝐴 ±5 Volts


Motor armature resistance 𝑅𝑎 2.6 Ω
Motor armature inductance 𝐿𝑎 0 H
Cart encoder resolution 𝐾𝐸𝐶 2.275*10-5 m/count
Pendulum encoder resolution 𝐾𝐸𝑃 0.0015 rad/count
Gravitational constant of earth g 9.81 m/sec2

Viscous damping at the pendulum axis 𝐵𝑃 0.0024 N.sec/m.rad


Viscous friction of the active cart 𝐵𝑐 0.002 N.sec/m
Viscous friction of the motor shaft 𝐵𝑚 0.000018 N.sec/m.rad
Motor shaft moment of inertia 𝐽𝑚 3.90*10-7 kg. m2
Viscous friction coefficient of the flexible 𝐵𝑓 2.2 N.sec/m
joint
Coulomb friction coefficient b 0.35 N.sec/m
Table A.1: Electromechanical parameter values of inverted pendulum single-mass
system
66

Appendix A.2. Dynamic Modeling


67
68
69
70
71

Appendix A.3. PID Control of Inverted Pendulum Single-Mass

System
clear all;
num_xc=[2.717197871*10^18 2.068251968*10^17
-6.234767921*10^19];
den_xc=[1.813984163*10^18 3.053492910*10^19
-4.555081036*10^19 -6.969984478*10^20 0];
xcsystem=tf(num_xc,den_xc)
num_theta=[6.355522856*10^18 0];
den_theta=[1.813984163*10^18 3.053492910*10^19
-4.555081036*10^19 -6.969984478*10^20];
theta_system=tf(num_theta,den_theta)
72

Appendix A.4. LQR Control of Inverted Pendulum Single-Mass

System
1.Controllability and Observability
A=[0, 1, 0, 0;0, -16.74554526, 1.470698607,
-0.4878730576e-2;0, 0, 0, 1;0, -39.16781208, 26.38554173,
-0.8752843618e-1];
B=[0;1.497917086;0;3.50362642];
C=[1, 0, 0, 0;0, 0, 1, 0];
Mc=[B A*B A*A*B A*A*A*B]
det_Mc=det(Mc)
Mo=[C;C*A;C*A^2;C*A^3]
det_Mo=det(Mo(1:4,1:4))

2. LQR Controller
clear all;
A=[0, 1, 0, 0;0, -16.74554526, 1.470698607,
-0.4878730576e-2;0, 0, 0, 1;0, -39.16781208, 26.38554173,
-0.8752843618e-1];
B=[0;1.497917086;0;3.50362642];
C1=[1 0 0 0;0 0 1 0];
q1=200/(2.534*0.1^2);
q2=50/(2*0.09211^2);
q3=100/(3.2*0.016^2);
q4=0.008/(1.1*0.0072^2);
R=1/36;
Q=[q1 0 0 0;0 q2 0 0;0 0 q3 0;0 0 0 q4]
73

k=lqr(A,B,Q,R)
N=-1/(C1(1,:)/(A-B*k)*B)
AA=A';
CC=C1';
P=[-4.0000 + 0.5000i; -4.0000 - 0.5000i;-3.000 +
0.2000i;-3.000 - 0.2000i]
LL=place(AA,CC,40*P);
L=LL'
74

Appendix A.5. Robust Control of Inverted Pendulum Single-Mass

System
1. Robust Control
a1=47.8583476;
a2=-0.8976130226e-2;
b1=4.48806511;
a3=.9421754475;
a4=-0.2016637257e-2;
b2=1.00831862;
a5=-.5471372821;
a6=-0.1077135627e-1;
%Control Parameters
lamda1=-0.35;
lamda2=1;
c1=0.93*abs(a1+a2+a5)
c2=0.19*abs(a3+a4+a6)
K2=0.4;
eta2=0.0005;
KI=240;
75

Appendix A.6. Adaptive Control of Inverted Pendulum Single-Mass

System
a1=47.8583476;
a2=-0.8976130226e-2;
b1=4.48806511;
a3=.9421754475;
a4=-0.2016637257e-2;
b2=1.00831862;
a5=-.5471372821;
a6=-0.1077135627e-1;
lamda1=-0.35;
lamda2=1;
c1=43.9911;
c2=0.1766;
deltac2=10;
kc2=150;
deltac1=3;
kc1=0.1;
KI1=4;
deltaKI=1;
KP1=0.1;
deltaKP=14;
KI2=0.3;
deltaKI2=1;
KP2=0.1;
deltaKP2=15;
76

K2=0.5;
eta2=0.0005;
KI=320;
77

Appendix B. Inverted Pendulum Double-Mass System


Appendix B.1. Electromechanical Parameter Values
Parameter Symbol Values Unites
Mass of the cart + weight + wires (approx.) 𝑀𝑐 and 0.96 Kg
𝑀𝑎
Mass of the pendulum 𝑀𝑝 0.23 Kg

Length of the pendulum 𝐿𝑝 0.6413 m


Radius of the motor pinion gear 𝑟𝑔 0.00635 m
Maximum cart travel length 𝐿𝑡 0.814 m
Internal gear ratio N 3.71:1 -
Motor torque constant 𝐾𝑡 0.00767 Nm/Amp
Back Electromotive-force constant 𝐾𝐵 0.00767 V.sec/rad

Motor input voltage range 𝑣𝐴 ±5 Volts


Motor armature resistance 𝑅𝑎 2.6 Ω
Motor armature inductance 𝐿𝑎 0 H
Cart encoder resolution 𝐾𝐸𝐶 2.275*10 m/count
-5

Pendulum encoder resolution 𝐾𝐸𝑃 0.0015 rad/count


Gravitational constant of earth g 9.81 m/sec2

Viscous damping at the pendulum axis 𝐵𝑝 0.0024 N.sec/m.rad


Viscous friction of the active cart and 𝐵𝑐 0.002 N.sec/m
passive cart
Viscous friction of the motor shaft 𝐵𝑚 0.000018 N.sec/m.rad
Motor shaft moment of inertia 𝐽𝑚 3.90*10-7 kg. m2
Stiffness of the flexible joint K 142 N/m
78

Viscous friction coefficient of the flexible 𝐵𝑓 2.2 N.sec/m


joint
Coulomb friction coefficient of active cart 𝑏1 0.4 N.sec/m
Coulomb friction coefficient of passive 𝑏2 0.1 N.sec/m
cart
Table B.1: Electromechanical parameter values of inverted pendulum double-mass
system
79

Appendix B.2. Dynamic Modeling


80
81
82
83
84
85
86
87

Appendix B.3. PID Control of Inverted Pendulum Double-Mass

System
clear all;
num_xa=[5.341706650*10^30 1.478293225*10^31
5.151075339*10^32 -1.360763530*10^32 -3.339616015*10^34];
den_xa=[2.345456972*10^26 3.390322204*10^30
+5.923749250*10^31 +8.896148844*10^32 +3.971333590*10^33
-4.334657905*10^34 -2.687876812*10^35 0 0];
num_xc=[+1.184951311*10^31 7.707474102*10^32
-1.356059845*10^32 -3.339616012*10^34];
den_xc=[2.345456972*10^26 3.390322204*10^30
5.923749250*10^31 8.896148844*10^32 3.971333590*10^33
-4.334657905*10^34 -2.687876812*10^35 0];
num_theta=[4.057126150*10^22 2.618690515*10^24 0];
den_theta=[2.345456972*10^26 3.390322204*10^30
5.923749250*10^31 8.896148844*10^32 3.971333590*10^33
-4.334657905*10^34 -2.687876812*10^35];
xcsystem=tf(num_xc,den_xc)
theta_system=tf(num_theta,den_theta)
xasystem=tf(num_xa,den_xa)
88

Appendix B.4. LQR Control of Inverted Pendulum Double-Mass

System
1. State-Space Representation of the System by Omitting Inductance
89
90

2.Controllability and Observability


A=[0, 1, 0, 0, 0, 0;-129.9026065, -14.70083144, 129.902606,
2.012575593, 0, 0;0, 0, 0, 1, 0, 0;143.1812453, 2.218300983,
-143.1812453, -2.220317620, .942175447, -0.1077135627e-1;0,
0, 0, 0, 0, 1;637.3052461, 9.873743249, -637.3052461,
-9.882719379, 47.85834769, -.5471372821];
B=[0;1.576709633;0;0;0;0];
91

C=[1 0 0 0 0 0;0 0 1 0 0 0;0 0 0 0 1 0];


Mc=[B A*B A*A*B A*A*A*B A*A*A*A*B A*A*A*A*A*B]
det_Mc=det(Mc)
Mo=[C;C*A;C*A^2;C*A^3;C*A^4;C*A^5]
det_Mo=det(Mo(1:6,1:6))

3. LQR Controller
A=[0, 1, 0, 0, 0, 0;-129.9026065, -14.70083144, 129.902606,
2.012575593, 0, 0;0, 0, 0, 1, 0, 0;143.1812453, 2.218300983,
-143.1812453, -2.220317620, .942175447, -0.1077135627e-1;0,
0, 0, 0, 0, 1;637.3052461, 9.873743249, -637.3052461,
-9.882719379, 47.85834769, -.5471372821];
B=[0;1.576709633;0;0;0;0];
C=[1 0 0 0 0 0;0 0 1 0 0 0;0 0 0 0 1 0];
R=.15/36;
Q=[32 0 0 0 0 0;0 0.5 0 0 0 0;0 0 19 0 0 0;0 0 0 2 0 0;0 0
0 0 1700 0;0 0 0 0 0 0.4]
k=lqr(A,B,Q,R)
N=-1/(C(1,:)/(A-B*k)*B)
AA=A';
CC=C';
P=5*eig((A-B*k));
LL=place(AA,CC,2*P);
L=LL'
eig([A-B*k,B*k;0*A,A-L*C])
92

Appendix B.5. Robust Control of Inverted Pendulum Double-Mass

System
a1 = 47.85834769;
a2 = -.5471372821;
a3 = -637.3052461;
a4 = -9.882719379;
a5 = 637.305246;
a6 = 9.873743249;
b1 = 0;
a7 = .942175447;
a8 = -0.107713562e-1;
a9 = -143.1812453;
a10 = -2.220317620;
a11 = 143.1812453;
a12 = 2.21830098;
b2 = 0;
a13 = 129.9026065;
a14 = 2.012575593;
a15 = -129.9026065;
a16 = -14.70083144;
b3 = 1.57670963;
%Control Parameters
lamda1=-1;
lamda2=-50;
c1=0.1*abs(a1+a2+a3+a4+a5+a6)
c2=0.7*abs(a7+a8+a9+a10+a11+a12)-0.2
93

c3=0.2*abs(a13+a14+a15+a16)
K3=8;
eta3=17;
94

Appendix B.6. Adaptive Control of Inverted Pendulum Double-Mass

System
clear all;
a1 = 47.85834769;
a2 = -.5471372821;
a3 = -637.3052461;
a4 = -9.882719379;
a5 = 637.305246;
a6 = 9.873743249;
b1 = 0;
a7 = .942175447;
a8 = -0.107713562e-1;
a9 = -143.1812453;
a10 = -2.220317620;
a11 = 143.1812453;
a12 = 2.21830098;
b2 = 0;
a13 = 129.9026065;
a14 = 2.012575593;
a15 = -129.9026065;
a16 = -14.70083144;
b3 = 1.57670963;
%Control Parameters
lamda1=-1;
lamda2=-50;
c1=0.1*abs(a1+a2+a3+a4+a5+a6)
95

c2=0.7*abs(a7+a8+a9+a10+a11+a12)
c3=0.2*abs(a13+a14+a15+a16)
K3=9;
eta3=17;
KI=0.01*0;
KK=0;
deltac2=-0.5;
kc2=3;
deltaKP3=11.5;
KP3=1;
deltaeta3=1.1;
eta31=2;

You might also like