You are on page 1of 11

ANALYSIS OF A PENDULUM

WITH MATLAB SIMULINK


REPRESENTATION ANALYSIS
AND
CONTROL OF DYNAMICAL SYSTEMS
France, January 2015

PROFESSOR:

BRIERE Yves

CASARES
HUERTA Giovanni
SOTO LASTIRI Luis Daniel
Institut Suprieur de l 0 Aeronautique et de l 0 Espace
Toulouse

ISAE - AMA

PENDULUM
0.1

Modeling

We want to analize a pendulum as depicted in Figure 1. The dynamic behaviour of this pendulum
can be described by the following input-output differential equation:
= u(t) f (t)
mlg sin (t) ,
J (t)

(1)

where u(t) is the torque applied by the actuator (electrical motor) and f is the coefficient of the
viscous friction inside the pivot joint.
We first describe this differential equation as a SIMULINK block diagram with the following
data: (m = 1 kg, l = 0.2 m, J = ml2 , g = 9.81 m/s2 and f = 0.004 N ms). The block diagram
is shown as follows:

Figure 1: Block diagram representation of equation (1).

Now, we calculate, by a hand-made computation, the equilibrium conditions (control signal


ue and internal state vector xe ) imposing = e : As is equal to a certain fixed value given
by e , all its derivatives with respect to time are zero, in particular = e = 0 and = e = 0,
so in this way equation (1) takes the form:

ue mlg sin e = 0 .
e = arcsin

ue
mlg

(2)

and ue = mlg sin e .

The linear model around these equilibrium conditions, this is to say, the state-space representation (A, B, C, D), is obtained from the perturbations = e and u = u ue (where

<< 1 and u << 1). From them, it is possible to rewrite equation (1), which results:
J = mlg sin e + u f mlg sin(e + ) ,
but sin(e + ) = sin e cos + cos e sin , which for << 1 reduces to sin e + cos e .
Finally, the linearized equation is:
J = u f

mlg
cos e ,
J

(3)

which can be rewritten in the following matrix form:




 
 

0
1

0

=
+
u
1

mlg Jcos e Jf

J

(4)

Making the following change of variable: = 1 and 2 = 1 , we obtain a state-space


representation of equation (3):


0
1
0
1
1
2 = mlg cos e f 1 2 .
(5)
J
J
J
u
1
0
0


We identify A with

1
Jf

mlg Jcos e


,B=

0
1
J


, C = (1

0) and D = 0.

It is straightforward to calculate the eigenvalues of the 2 2 A matrix above. We only need


to solve the following characteristic equation:

s2 +

f
mlg cos e
s+
= 0,
J
J

(6)

f
1
where s denote the respective eigenvalues. Solving (6) gives: s = 2J
2J

p
f 2 4mlgJ cos e .

The transfer function corresponding to this linear model is obtained by applying the following
formula F (s) = D + C(sIn A)1 B, where A, B, C and D denote the matrices above.
Then,
1
F (s) =
.
(7)
Js2 + f s + mlg cos e

There will be three different transfer functions for each of the equilibrium conditions e =
0, 2 , . Therefore:
F1 (s) =

0.04s2

1
;
+ 0.004s + 1.962

F2 (s) =

0.04s2

1
;
+ 0.004s

F3 (s) =

0.04s2

1
,
+ 0.004s 1.962

where F1 (s) is the transfer function associated to e = 0, F2 (s) the transfer function associated
to e = 2 , and F3 (s) the one corresponding to e = .
For the Bode responses we evaluate the different transfer functions F1 , F2 , F3 . These are
plotted in the following figure:

Figure 2: Bode responses for e = 0, 2 and , respectively.

Now, we do the same analysis above but using macro-functions in the original non-linear
SIMULINK model. Doing that, we obtain the same transfer functions to the ones calculated
before with the theoretical linearized model. Results are given equivalently as

F1 (s) =

25
;
s2 + 0.1s + 49.05

F2 (s) =

25
;
s2 + 0.01s

F3 (s) =

25
.
s2 + 0.1s 49.05

Finally, for the last part of this modeling section, we simulate the responses to initial conditions
= 0) = 0 ) for different values 0 = 1 rad/s, 0 = 15 rad/s,
on angular rate ((t = 0) = e , (t
as for the linear model using the macrofunction initial as well as for the non-linear SIMULINK
model. The corresponding graphs are depicted in Figure 3.

0.2

Closed-loop analysis

We assume that is measured by an optical encoder (sensor) and we consider the control law
u = K(s)(ref ), where ref is the reference input in the pendulum position and K(s) is the
controller. Two controllers are considered to stabilize the pendulum around = :
K1 (s) =

0.6s + 6
0.02s + 1

and K2 (s) =

0.2s + 6
.
0.02s + 1

Figure 3: Responses to an initial condition 0 = 15 rad/s and e = 0. The graph in the top
corresponds to the linear model, as opposite to the one in the bottom which corresponds to the
non-linear SIMULINK model.

We define the controllers using the function tf in Matlab. Specifically, we have to insert the
following line: K1=tf([0.6 6],[0.02 1]) for K1 and K2=tf([0.2 6],[0.02 1]) for K2 .
For calculating a state-space representation of K1 (s), we use the function ssdata: [a,b,c,d]=ssdata(K1),
which gives the values of a=-50, b=32, c=-37.5, d=30. The same is done for the controller
K2 (s): [a,b,c,d]=ssdata(K2), obtaining a=-50, b=16, c=-12.5, d=10.
We now plug the controller K1 (s) into the nonlinear SIMULINK model, and it is indeed
verified that the closed-loop system is stable around e = . For the controller K2 (s), we can
see as well an stability behaviour, but it oscillates more around the final equilibirum point.
Figure (4) shows this stability behaviour for both controllers.

For the calculation of the eigenvalues of the linear closed-loop system, we looked for the
15s+150
poles of the transfer fuction FK1 F2 (s)K1 (s) = 0.02s3 +1.002s
2 0.881s49.05 and of FK2
5s+150
F2 (s)K2 (s) = 0.02s3 +1.002s2 0.881s49.05 . We obtained the same eigenvalues for both cases:
s1 = 50, s2 = 6.9537, s3 = 7.0537.
Analyzing the graphs in Figure 4 as well as the transfer functions obtained for each of the
controllers, we can conclude that the controller K1 is the best one, as the amplitude of the
response is much smaller (' 3.9) than the one corresponding to K2 (' 4.4). Moreover, the
time required for K1 to go back to the initial equilibrium state is much less than the time
required by the controller K2 , which oscillates more indeed.

Figure 4: Closed-loop system behaviour with controllers K1 (s) and K2 (s) plugged. The graph
above corresponds to K1 and the one in the bottom corresponds to K2 .

0.3

Control

We consider the linear model around e = .


0.3.1

Stabilization and disturbance rejection

Using the Matlab function sisotool, we designed a first order controller K1d (s) =
order to accomplish the following requirements:

Kp +Kv s
1+ s

in

S1. The closed-loop dominant dynamics is governed by a second order dynamics s2 + 2s +


2 , with > 12 rad/s.
S2. The damping ratio of closed-loop poles must be greater than 0.65
S3. |gain margin| > 6 dB
S4. phase margin > 30 deg
S5. |K(j)| < 40 , for all > 10 rad/s.
=
The controller adapted to these requirements could be: K1d (s) = 40.268(s+9.39)
s+50
Identifying each of the terms of K1d , we obtain the values for Kp , Kv and :
Kp = 7.5623304 ;

Kv = Kv (s) = 0.80536s ;

1
= 0.02 .
50

40.268s+378.11652
.
s+50

Figure 5: Tunning of the K1 controller with sisotool.

We plugged now this controller K1d into the original non-linear SIMULINK model and verified
that this controller is certainly better than the controllers K1 , and consequently, than K2
discussed previously in the closed-loop analysis section. This can be seen from the Figure 6
depicted hereunder, where K1 and K1d responses are plotted.

Controller K1d shows a better behaviour regarding disturbance rejections and a non-oscillating
response. Moreover, the time required for the output response to stabilize is even smaller than
the time required by K1 and, of course, by K2 .
0.3.2

Taking into account avionics

It is considered now an actuator (basically a motor) which can be modeled by a second order
transfer function with a pulsation of 50 rad/s, a damping of 0.7 and a unit DC gain.
In order to comply with the specifications [S1.]-[S5.], we had to retune the controller in order
to take into account the avionics (Figure7).

Figure 6: Different responses for e = and 0 = 15 rad/s, corresponding to controllers K1 and K1d ,
from top to bottom, respectively.

Figure 7: Tunning of the Kav controller with sisotool.

In this way we obtained from sisotool the new controller Kav :


Kav =

0.3.3

52.263(s + 7.225)
s + 92.36

Reference input tracking

The step response of F (s) (the linearized system) with the controller K1d (s) is shown in the
Figure 8.

Figure 8: Step response of the linear system F (s) with the controller K1d .

We then designed a new second order controller Ci (s) K2order (which includes one integrator in order to cancel the static error) satisfying the specifications [S2.]-[S5.]. This has the
following form:
74.48(1 + 0.072s)(1 + 0.97s)
K2order =
,
s(1 + 0.004s)
where we can identify the respective gains: Kp = 76.955, Ki = 74.4794 and Kv = 4.8890, and
= 0.004 (obtained with the piddata command). With the obtained gains from the second
order controller we implemented a PID configuration as it is shown in Figure 9. As for the
design of the second order controller the tunning is shown in Figure 10.
Finally, we plotted the response of the new controller on the non-linear SIMULINK model
(Figure 11) and we checked the behaviour of the PID control implementation on this nonlinear SIMULINK model (Figure 12).

Figure 9: PID configuration of the second order controller.

Figure 10: Tunning of the second order controller with sisotool.

Figure 11: Comparison of step responses between the first order controller K1d and the second
order controller K2order .

Figure 12: Comparison between the behaviour of the non-linear model with second order controller
without and with PID configuration.

You might also like