Professional Documents
Culture Documents
Stabilization of An Inverted Pendulum: December 2, 2015
Stabilization of An Inverted Pendulum: December 2, 2015
December 2, 2015
By: Ricardo Cedillo A01361466
Divad Shriqui A01361461
Contents
1 Introduction
2 Abstract
3 Mathematical Representation
3.1 Kinematics Analysis . . . . . . . . . . . .
3.2 Dynamics Analysis of the Pendulum . . .
3.3 Dynamics Analysis of the Pendulums car .
3.4 Non-linear State-Space Representation . .
3.5 State-Space Linearization . . . . . . . . .
.
.
.
.
.
2
3
4
5
6
7
.
.
.
.
.
10
11
11
12
12
12
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
4 Controller Design
4.1 Pole Placement (Root Locus Method) . . . . . . . .
4.2 Convergence of the System . . . . . . . . . . . . . .
4.3 Convergence of the System at half the time . . . . .
4.4 Underdamped Convergence of the System at 20 Hz
4.5 Infinite Oscillation at 20 Hz . . . . . . . . . . . . .
5 Observer Design
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
13
6 Implementation in Matlab
6.1 Controller . . . . . . . . . . . . . . .
6.1.1 Block Diagram . . . . . . . .
6.1.2 Code . . . . . . . . . . . . . .
6.1.3 Responses in the time-domain
6.1.4 Validation . . . . . . . . . . .
6.2 State-Observer . . . . . . . . . . . .
6.2.1 Block Diagram . . . . . . . .
6.2.2 Code . . . . . . . . . . . . . .
6.2.3 Responses in the time-domain
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
13
13
13
13
15
17
19
19
19
20
7 Results
20
8 References
21
Introduction
The following work has been developed at the Monterrey Institute of Technology and Higher Education, Toluca; as part of a study project for the
Computerized Control Course dictated by Professor Luciano Chirinos.
The article presents a step to step solution to a classical Control Engineering problem, the stabilization of an Inverted Pendulum. The tools and their
application, along with the results obtained from this brief research will be
presented, developed and discussed in this document.
Abstract
Mathematical Representation
3.1
Kinematics Analysis
arad = 2 l
=
e 2 l
aP/c = l
r
aP = (
x + lcos
2 lsin)i (lsin
+ 2 lcos)j
3.2
Fi = maP i
T sin = maP x
T sin = m(
x + lcos
2 lsin)
T sin = m
x + mlcos
m 2 lsin
Fj = maP j
T cos mg = maP j
T cos = mg + m(lsin
2 lcos)
T cos = mg mlsin
m 2 lcos
In order to obtain an equation that will allow further examination of the
system, the following mathematical trick will be applied.Tsin and Tcos
will be multiplied by cos and sin respectively, and the later subtraction of
T sin cos = m
xcos + mlcos
m 2 lsin cos
Subtraction:
2
(mgsin mlsin
m 2 lsin cos )
2
2
0 = m
xcos + mlcos
mgsin + mlsin
0 = m
xcos mgsin + ml(sin
+ cos2 )
0 = m
xcos mgsin + ml
mgsin m
xcos
=
ml
3.3
Fi = M x
F T sin = M x
T sin = F M x
5
(1)
m
x + mlcos
m 2 lsin = F M x
F (M + m)
x + m 2 lsin
=
mlcos
(2)
mgsin m(
=
(3)
=
ml
2
mgsin((M + m) mcos ) F mcos m2 2 lsin cos m2 gsin cos2
(M + m) mcos2
=
ml
(M + m)gsin F cos m 2 lsin cos
=
(4)
(M + m)l mlcos2
3.4
3.5
State-Space Linearization
y = y + K(x x)
(6)
Where,
y = f (
x)
df
K=
dx
x=
x
(7)
(9)
Where,
y = f (x1 , x2 )
df
K1 =
dx1 x1 =x1 ,x2 =x2
df
K2 =
dx2 x1 =x1 ,x2 =x2
Implementing this method it is possible to linearize the system represented
by the space-state equations described in Section 3.4 using equation 9.
x2 x2 = K1 (x1 x1 ) + K2 (x2 x2 )
(M + m)gcosx1 + F sinx1 mx22 l(cos2 (x1 ) sin2 (x1 ))
dx2
=
+ ...
dx1
(M + m)l mlcos2 x1
dx2
(M + m)g
K1 =
=
dx1 x1 =0,x2 =0
Ml
dx2
=0
dx2
8
dx2
K2 =
=0
dx2 x1 =0,x2 =0
x2 = x2
=
x1 =0,x2 =0
F
Ml
So that,
x4 = x4 + K3 (x1 x1 ) + K4 (x2 x2 )
x4 =
F
(M + m)g
x1
Ml
Ml
=
x1 =0,x2 =0
F
M
So that,
x4 = x4 + K3 (x1 x1 ) + K4 (x2 x2 )
x4 =
mg
F
x1 +
M
M
9
x1
x2
=
x3
x4
x = Ax + Bu
0
1 0 0
(M + m)g
0 0 0
Ml
0
0 0 1
mg
0 0 0
M
y = Cx
x1
x2
+
x3
x4
0
1
Ml
0
1
M
u(t)
x1
x2
x3
x4
y(t) =
1 0 0 0
0 0 1 0
Controller Design
It is required to implement a proportional closed-loop controller for the stabilization of the system. For didactic purposes, the controller will be designed
for the following cases:
Convergence of the system.
Convergence of the system at half the time.
Underdamped convergence of the system at 20 Hz.
Infinite Oscillation at 20 Hz.
The Space-State equations for a proportional closed-loop controller are the
following:
x = (A BK)x
y = Cx
10
4.1
By definition, the poles of the open-loop system are given by the roots of the
A-Matrix. poles = |sI A|.
Analog to the open-loop system, the closed-loop system poles are given by
the roots of the (A BK) Matricial equation. poles = |sI (A BK)|.
For a second order system, the transfer function in the frequency domain is
given by the following equation:
H(s) =
Kn2
s2 + 2n s + Kn2
2 1n
There are four damping cases resulting of the combination of values for
and n :
Undamped case: Is the case where = 0, corresponding to the simple
harmonic oscillator. In that case the solution will look like exp(in t).
Underdamped case: Being s a complex number, the solution is then a
decaying exponential
combined with an oscillatory portion that looks
p
2
like exp(in 1 t). This case occurs for < 1.
Overdamped case: iF S is a real number, then the solution is simply a
decaying exponential with no oscillation. This case ocurrs for > 1.
Critically Damped case: The case where = 1 borders between the
overdamped and underdamped cases, and is referred to as critically
damped. This turns out to be a desirable outcome in many cases
ehre engineering design of a damped oscillator is required (e.g., a door
closing mechanism).
4.2
The pure convergence of the system refers to a critically damped pole placement design. If it is desired for the system to converge at, let us say 1
11
1
(For a critically damping case)
1
and n = 1 (For minimization of the oscillatory part). We have that:
p
p = (1)(2)) (1)2 (1)(2)
p = 2
This result states that the dominant pole should be located at p = 2.
4.3
For the convergence of the system at half the time, the pole should be located
twice as far from the origin as the previous pole. This statement implies the
location of the dominant pole at p = 4.
4.4
The Underdamped Convergence of the system at 20 Hz refers to a underdamped pole placement design with an arbitrary value of and a value of
2(20) for n . For instance if we want the system to converge oscillating at
20 Hz, we have that:
p
1
p = 40 1 (1/4)2 (40)
4
15
p = 10 40
4
Thisresult states that the dominant pole should be located at p = 10 +
15
i40
.
4
4.5
Infinite Oscillation at 20 Hz
Observer Design
6
6.1
Implementation in Matlab
Controller
6.1.1
Block Diagram
6.1.2
Code
The code in Matlab for the implementation of the different types of designed
controllers is the following:
L = 0.5
M = 10
13
m=1
g = 9.81
A = [0 1 0 0
(M+m)*g/(M*L) 0 0 1/M
0001
-m*g/M 0 0 -1/(M*L)]
B = [0
-1/M
0
1/(M*L)]
C = [1 0 0 0
0100
0010
0 0 0 1]
D = zeros(4,1)
p = eig(A)
p2 = [-2*pi
-4*pi
-16*pi
-32*pi]
p4 = [-4*pi
-16*pi
-32*pi
-64*pi]
pund = [-10*pi+40*sqrt(15)/4pi*j
-10*pi+40*sqrt(15)/4pi*j
-40pi*j
+40pi*j]
posc = [-40*pi*j
14
+40*pi*j
-40*pi*j
+40*pi*j]
n =[4
0
4
0]
K = place(A,B,p)
K2 = place(A,B,p2)
K4 = place(A,B,p4)
Kund = place(A,B,pund)
Kosc = place(A,B,posc)
6.1.3
15
16
Validation
To prove that the controller works, the full non-linear system was implemented using block diagrams and the controller was tested on the non-linear
plant. From the figures, we can appreciate that the controller stabilizes the
pendulum correctly.
17
18
6.2
State-Observer
6.2.1
Block Diagram
6.2.2
Code
LT = place(A,C,p)
L = LT
19
6.2.3
If we compare both results with and without the observer, we are able to see
that the observer works. However, the system with the observer converges at
a later point in time, in other words, the response with the implementation
of an observer has a time lag.
Results
It has been found that, the designed analog control for the inverted pendulum can theoretically affect the system to balance the pendulum into an
equilibrium point. The designed controller was implemented for the control
of both the linear and non-linear model, proving that the system works under any circumstances. The implemented State-Observer predicts correctly
the values of the State-variables, this was demonstrated by comparing the
response of the system with and without the controller
20
References
Classic Inverted Pendulum - Equations of Motion. Brianno Collers
YouTube Channel. From https://www.youtube.com/watch?v=5qJYZaKSic
Standup and Stabilization of the Inverted Pendulum. By Andrew K.
Stimac. From http://web.mit.edu/2.737/www/extra files/andrew.pdf
Ogata K.(2010), Modern Control Engineering. Chapter 10. Pags. 751757.
Damping Ratio. Wikipedia. From https://en.wikipedia.org/wiki/Damping ratio
21