Sie sind auf Seite 1von 21

Stabilization of an Inverted Pendulum

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

This paper presents a brief research on the mathematical and computational


tools, and their application in Analog Modern Control Theory for the solution
of a well known problem, the stabilization of an inverted pendulum.

Mathematical Representation

The mathematical representation of the system was obtained by performing


an analysis of the dynamics of the Inverted Pendulum.

3.1

Kinematics Analysis

arad = 2 l
=
e 2 l
aP/c = l
r

i sinj) 2 l(sini + cosj)


aP/c = l(cos
aP = aC + aP/c

i sinj) 2 l(sini + cosj)


aP = xi + l(cos
3

aP = (
x + lcos
2 lsin)i (lsin
+ 2 lcos)j

3.2

Dynamics Analysis of the Pendulum

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

the resulting equations Tsincos - T cossin will provide us a formula that


describes the behavior of the pendulum.
2

T cos sin = mgsin mlsin


m 2 lsin cos
2

T sin cos = m
xcos + mlcos
m 2 lsin cos

Subtraction:
2

T sin cos T cos sin = m


xcos + mlcos
m 2 lsin cos
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

Dynamics Analysis of the Pendulums car

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)

Equations 1 and 2 are now equalized:


mgsin m
xcos
F (M + m)
x m 2 lsin
=
ml
mlcos
2
mgsin cos m
xcos = F (M + m)
x + m 2 lsin
x[(M + m) mcos2 ] = F + m 2 lsin mgsin cos
F + m 2 lsin mgsin cos
(M + m) mcos2
Substituting x into equation 1 we obtain:
x =

mgsin m(
=

(3)

F + m 2 lsin mgsin cos


)cos
(M + m) mcos2
ml

F mcos + m2 2 lsin cos m2 gsin cos2


mgsin
(M + m) mcos2

=
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

Non-linear State-Space Representation


x1 =
x2 =

(M + m)gsin F cos m 2 lsin cos


(M + m)l mlcos2
x3 = x
F + m 2 lsin mgsin cos
x4 =
(M + m) mcos2
6

3.5

State-Space Linearization

In order to obtain a linearized mathematical model for a non-linear system,


it is supposed that the state variables only deviate slightly from an ideal
operation condition. Considering a system with a x(t) input and a y(t)
output. The relationship between x(t) and y(t) is obtained by the following
equation:
y = f (x)
If the ideal operation condition corresponds to x and y, the equation expands
into Taylor Series around this point as shown below:
y = f (x)
1 d2 f
df
(x x) +
(x x)2 + ...
(5)
dx
2! dx2
df d2 f
,
, ... are evaluated at x = x. If the variation
Where the derivatives
dx dx2
x x is small, it is possible not to consider higher order terms in x x. Then
equation 5 can be rewritten as:
y = f (
x) +

y = y + K(x x)

(6)

Where,
y = f (
x)

df
K=
dx

x=
x

Equation 6 can be rewritten as


y y = K(x x)

(7)

which indicates that y y is proportional to x x. Equation 7 provides a


linear mathematical model for a non-linear system described by y = f (x)
around the operation point x x,y y.
Considering a non-linear system which output is a function of two inputs x1
and x2 , such as:
y = f (x1 , x2 )

In order to obtain a linearized approximation for this non-linear system, it


is possible to expand the last equation into a Taylor series expansion around
the ideal operation point x1 , x2 so that the equation becomes:


df
df
(x1 x1 ) +
(x1 x2 )
y = f (x1, x2 ) +
dx1
dx2


d2 f
d2 f
1 d2 f
2
2
(x1 x1 ) + 2
(x1 x1 )(x2 x2 ) + 2 (x2 x2 ) + ...
+
2! dx21
dx1 dx2
dx2
(8)
Where the partial derivatives are evaluated at x1 = x1 , y1 = y1 . Normally,
around the operation point it is possible not to consider higher order terms.
The mathematical model of this non-linear system around the ideal operation
condition is given by:
y y = K1 (x1 x1 ) + K2 (x2 x2 )

(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

The same applies for x4 :


x4 x4 = K3 (x1 x1 ) + K4 (x2 x2 )
mx22 lcosx1 mgsin(cos2 (x1 ) sin2 (x1 ))
dx2
=
+ ...
dx1
(M + m) mcos2

dx2
mg
K3 =
=

dx1 x1 =0,x2 =0
M
dx4
=0
dx2

dx4
K4 =
=0
dx2 x1 =0,x2 =0


x2 = x2

=
x1 =0,x2 =0

F
M

So that,
x4 = x4 + K3 (x1 x1 ) + K4 (x2 x2 )
x4 =

mg
F
x1 +
M
M
9

Finally, if considering that F = u(t), we obtain that,

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

Pole Placement (Root Locus Method)

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

Where the poles are given by:


p = n

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

Convergence of the System

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)

seconds. Then we must use a value of =

p = 2
This result states that the dominant pole should be located at p = 2.

4.3

Convergence of the System at half the time

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

Underdamped Convergence of the System at 20


Hz

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

The Infinite Oscillation of the system at 20 Hz refers to a underdamped


pole placement design without a real part for the pole. For instance, the
imaginary part of the pole should be:
p = i40
12

Observer Design

A State-Observer estimates the State-variables based on measurements at the


control and output variables. The observer is a sub-system that reconstructs
the state vector of the plant, its mathematical model is basically the same
as that of the plant. However, it includes an additional term that holds the
estimation error that compensates the inaccuracies in the A and B matrices
and the lack of an initial estimated state. The mathematical model of the
observer is defined as:
x = A
x + Bu + L(y C x)
x = (A LC)
x + Bu + Ly
Analog to the open-loop system, the observers poles are given by the roots
of the (AT C T K) Matricial equation. poles = |sI (AT C T K)|.
Where L = K T .

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

Responses in the time-domain

Convergence of the system

By examining the chart, it is possible to appreciate that the system converges


fully at an approximate time 1 second, just as designed.

15

Convergence of the system at half the time

By examining the chart, it is possible to appreciate that the system converges


fully at an approximate time 0.5 seconds.
Underdamped convergence of the system at 20 Hz

16

By examining the chart, it is possible to appreciate that the system converges


fully at an arbitrary time and oscillates at an approximate value of 20 Hz.
Infinite Oscillation at 20 Hz

By examining the chart, it is possible to appreciate that the system never


converges and oscillates at an approximate value of 20 Hz, just as designed.
6.1.4

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

Responses in the time-domain

Comparison between the closed-loop systems response and the


closed-loop systems response implementing the State-Observer and
validation

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

Das könnte Ihnen auch gefallen