Week 1
Review
Contents
I
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
1
1
3
6
8
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
10
10
10
12
13
14
16
19
21
I
I.1
.
.
.
.
.
.
.
.
.
.
.
.
u
M
Friction ~ bv
Figure 1: Sketch of a cart moving on a surface with viscous friction
Figure 1 shows a scheme for one of the simplest mechanical systems: a cart having mass M , moving on
wheels on a surface with dynamic friction coefficient b. The cart could represent a vehicle or a dolly used to
move loads in a factory. We want do describe the dynamics of its speed. Suppose the cart has an engine,
which produces a force u in the direction shown in the figure.
We start from the fundamental laws:
M a = u bv
Elisa Franco
dv
dt .
v =
b
u
v+
M
M
vN (t) = v0 e M t
When initial conditions are zero, but we have an input u 6= 0, we find the forced response using the convolution1 integral:
Z
t
vF (t) =
e M (t )
1
u( )d
M
Note: If you never heard of convolution - that is how forced response solutions to ODEs are computed. Do not
worry too much about it, since we will hardly use convolution throughout this course. The overall solution is:
b
M
t
Z
+
e M (t )
1
u( )d
M
Z t
b
1
v(t) = v0 e
+
e M (t ) d
M 0
Z
b
1 bt t b
M
t
M
= v0 e
+
e
e M d
M
0
b
1 b t M h b i =t
= v0 e M t +
e M
eM
M
b
=0
h
i
b
b 1
b
M
t
M
t
t
= v0 e
+e
eM 1
b
i
b
b
1h
1 e M t
= v0 e M t +
| {z }
|b
{z
}
b
M
t
as
1b
as
As you probably remember from your Linear Systems course, there are better ways to find solutions to linear
ODEs. The Laplace transform method will be our standard choice in the following weeks.
We call this system a FIRST ORDER system, since there is only ONE dynamic variable, an the natural response
dynamics are ALWAYS of exponential type, regardless of b, M and u.
The only dynamic variable is called the STATE of the system. We were able to find analytically the state for this
simple case. As you can see, v(t) only depends on INITIAL CONDITIONS, INPUT and PARAMETERS. We
say that the system is CAUSAL, as it does not depend on future values of the external inputs. In addition, we
say that the system is LINEAR TIME INVARIANT, because the dynamics are linear, and because the solution
does not depend on the specific times at which we begin or finish observing it, but only on their difference.
For first order system, whose natural response is of type ept we can define a characteristic timescale = p1 .
At t = , the steady state of the system has reached a value (1 e1 ) = %63 of its steady state value. Finally,
1
Convolution integral: given f (t), g(t), with f (t) = g(t) = 0 for t 0: h(t) , f (t) ~ g(t) =
Rt
0
f ( )g(t )d
Elisa Franco
engineers like to represent dynamical systems with simple block diagrams: see figure 2.
1 +
M -
b
M
I.2
Mass-spring-damper systems
1. A mass-spring system (Figure 3). Suppose a mass M hangs from support with a spring having spring
constant k. For example, M could represent a cable cart or a load on a crane. We assume that the
resting length of the spring is zero. We are interested in describing mathematically the dynamics of the
mass. A static description would not give us a lot of useful information: for example, suppose M changes
suddenly. Does the system oscillate? If it does, how long? What happens if M changes very slowly over
time or very fast?
k
r(t)
M
Mg
M a = M g kr
M v = M g kr,
v = r
M r = M g kr
We want to reduce this equation to a first order differential equation.
We define two variables x1 = r and x2 = r , and we find:
x 1 = x2
x 2 = g
k
k
r=g
x1
M
M
0
x 1
=
k
x 2
M
1 x1
0
+
g
1
0 x2
Elisa Franco
Variables x1 and x2 are the STATES of our system. Because we have two states, this is a SECOND
ORDER system. Second order systems can oscillate, in contrast with first order systems which we just
saw in the first example. We will learn more about this in the next lectures.
By solving the differential equation we can find x1 (t) and x2 (t), which depend only on the initial conditions,
the parameters of the system, and on the external inputs (in this case only gravity).
In general, we will write linear dynamical system in state space form as:
x = Ax + Bu,
where:
B is a matrix in Rnm (describes how external inputs affect the dynamics of the states)
2. A mass-damper system (Figure 4). In this case, we assume that viscous friction slows the system
proportionally to the speed. This is a standard assumption when we model hydraulic dampers commonly
used in industry.
b
r(t)
M
Mg
M a = M g bv
v = r,
a = v = r
M r = M g br
Now as done before, define two variables x1 = r and x2 = r , and we find:
x 1 = x2
x 2 = g
b
b
b=g
x2
M
M
In matrix form:
0
1
x 1
x1
0
=
+
g x = Ax + Bu
x 2
x2
1
0 Mb
Elisa Franco
r(t)
M
Mg
M a = M g kr bv
M r = M g kr br
We define two states as before
x 1 = x2
x 2 = g
b
k
b
b=g
x1
x2
M
M
M
In matrix form:
0
x 1
=
k
x 2
M
1
Mb
0
x1
g x = Ax + Bu
+
1
x2
4. A mass-spring-damper system with an active element (Figure 6). The active element can be, for example,
a motor that we can control. Thus, it is a new external input. (This is useful for your homework Matlab
project!)
k
r(t)
F
F
M
Mg
M v = M g kr bv + F
Elisa Franco
In matrix form:
0
x 1
=
k
x 2
M
1
Mb
0
x1
0
0
+
g+ 1 F =
k
x2
1
M
M
1
Mb
x1
0
+
x2
1
0
1
M
g F
0
1
0
x 1
x1
0
=
+
g + K (xd1 x1 )
k
x 2
x2
1
M
Mb
M
0
1
x1
0 0
g xd1
+
=
1
b
k+K
x2
1 M
| M {z M }
New matrix!
5. Finally, we can represent with simple schemes all the dynamic relationships we just described with ODEs:
xd1
+
K
k
M M
g
+ + -
Equivalent scheme
x1
xd1
b
M
x1
x2
+ - 1
+ - M
x2
Figure 7: Mass-spring-damper system: block diagram. Note: the common factor 1/M can be moved in the
diagram as long as the overall physical interconnections are consistent.
I.3
Electrical circuits
Electronic devices are present in almost every technological application! Control theory developed around
analysis of electrical circuits.
1. Resistances, capacities and inductors. These are the fundamental elements of any circuit, and are characterized by specific dynamic relationships between their currents and voltages.
Resistance
V = Ri
Inductor
V =L
di
dt
Capacity
i=C
dV
dt
Elisa Franco
V (t)
V (t)
V (t)
i(t)
i(t)
_
i(t)
_
_
Figure 8: Fundamental elements of electrical circuits
u(t)
i(t)
di
1
R
= u i
dt
L
L
This is a first order system and has exponential dynamics.
3. An RC circuit: derive its state space representation as homework.
u(t)
i(t)
u = VL + VC = L
di
+ VC
dt
u = LC
d2 VC
+ VC
dt2
We have now a second order differential equation; as done for the mechanical system, we define x1 = VC ,
dVc
dt :
x1 =
x 1 = x2
x 2 =
1
1
x1 +
u
LC
LC
Elisa Franco
u(t)
i(t)
x 1
0
=
1
x 2
LC
1 x1
0
+ 1 u = Ax + Bu
0 x2
LC
Notice the similarity of the A matrix structure with that of the mass-spring example.
5. An RLC circuit: derive its state space representation as homework.
u(t)
i(t)
I.4
Main file:
%MAIN FILE
clear all
close all
% DEFINE PARAMETERS:
par.k= 14.8e3;
par.b= 800;
% N/m
% Ns/m
par.M= 400;
% Kg
%
%
%
%
Elisa Franco
% INITIAL CONDITION
x0=[10 1];
% TIME DURATION OF THE SIMULATION
tspan=[0:.1:10];
%OPTIONS FOR THE SOLVER
options = odeset(RelTol,10^-11,AbsTol,10^-13);
[t,x]=ode45(@MassSpringDamper,tspan,x0,options,par);
plot(t,x(:,1),b,LineWidth,3)
hold on
plot(t,x(:,2),r,LineWidth,3)
hold on
% PLOT, PRINT AND SAVE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
legend(Position, Speed)
legend boxoff
Fsize=16;
FontForPlot=Arial;
set(gca,Fontsize,Fsize, FontName,FontForPlot) % SETS FONT AND FONTSIZE FOR AXES
xlabel(Time, [s],Fontsize,Fsize, FontName,FontForPlot)
ylabel(Response,Fontsize,Fsize, FontName,FontForPlot)
Function file
Must be saved with the same name as the function! In this case, save as MassSpringDamper.m
function dx=MassSpringDamper(t,x,par)
% F(1) AND F(2) ARE THE DYNAMICS OF THE SYSTEM
F(1)= x(2);
F(2)= -(par.k/par.M)*x(1) - (par.b/par.M)*x(2);
dx=F; % MUST RETURN A COLUMN VECTOR
10
Elisa Franco
II
Laplace transforms are useful to solve linear time invariant differential equations. Differential equations are
turned into algebraic equations; the solution in the time domain can be found by decomposing the algebraic
solution in the Laplace domain into terms that are easy to reverse-transform.
II.1
Definition
Laplace Transform (LT): bijective (invertible) transformation that maps functions of time f (t) with functions of
complex argument F (s), s = + j C.
L
Functions of time
Differential equations
t R
s C
L1
THE SCHEME ABOVE IS THE MOST IMPORTANT THING YOU SHOULD REMEMBER ABOUT LAPLACE
TRANSFORMS!
Given f (t), piecewise continuous and bounded, f (t) 6= 0 for t 0
Z
F (s) = L[f (t)] ,
f (t)est dt
II.2
Notation: I will indicate as 1(t) a step function, which is zero for negative time, and equal to one for t 0.
When we multiply a function by 1(t), for instance et 1(t), it means we consider the function only for t 0.
1. LT of Diracs function:
11
Elisa Franco
Diracs delta function, can be defined in many ways... Intuitively, it is a very large signal with a very
short duration. Also called impulse.
(x x0 ) = lim0
(xx0 )2
2
x0
f ( ) ( 0 )d = f (0 )
0
+
Z
L [(t)] =
(t)e
st
dt =
(t)est dt = 1
L [1(t)] =
0
1
1
1(t)est dt = [est ]
0 =
s
s
h
i Z
kt
L e 1(t) =
kt st
e e
dt =
e(ks)t dt =
1
1
=
[e(ks)t ]+
0
ks
sk
n!
sn+1
}=
n!
sn+1
ejt ejt
1
1
1
1 2j
1(t) =
=
L
= 2
2
2
2j
2j s j s + j
2j s +
s + 2
ejt + ejt
1
1
1
1 2s
s
1(t) =
+
=
= 2
L
2
2 s j s + j
2 s2 + 2
s + 2
12
Elisa Franco
II.3
1. Linearity The integral operation is linear, therefore the LT inherits such property:
L f 0 (t) = sL [f (t)] f (0 )
This can be extended to the derivative of order n:
n1
X
dn
n
f
(t)
=
s
L
[f
(t)]
L
snk1 f k (0 )
dtn
k=0
4. Frequency shift Given F (s), the LT of f (t), and k C. Then, the LT of function ekt f (t) is:
h
i
L ekt f (t) = F (s k)
In fact:
ekt f (t)est dt =
f (t)e(sk)t dt
Z +
Z +
d
d
f (t)est dt =
f (t) est dt
ds 0
ds
0
Z +
Z +
=
f (t)test dt =
tf (t)est dt = L [tf (t)]
d
F (s) =
ds
dn
F (s)
dsn
f ( )g(t )d
Z(s) = F (s)G(s)
LAPLACE TRANSFORMS CONVERT CONVOLUTION INTEGRALS IN SIMPLE PRODUCTS!
Application: remember the general expression for the forced response of an linear time invariant system?
Z
xF (t) =
A(t )
Bu( )d =
where h(t) := eA(t ) is the state transition matrix and w(t) := Bu(t). We find:
13
Elisa Franco
7. Time shift If f (t) admits a LT, the introduction of a time shift t0 > 0 still yields a LT with the same ROC
and :
st
f (t t0 )e
Z
dt =
t0
1 s
F
, a R+
a
a
L [f (at)] =
st
f (at)e
f (t)es a d
II.4
dt =
1 s
F
a
a
Given F (s) = L [f (t)], its Inverse Laplace Transform (ILT) is denoted as f (t) = L1 [F (s)]; the operator
L1 is linear. The general formula is:
f (t) =
1
2 j
+j
F (s) est ds
where
> 0 delimits the ROC and the integration is along the vertical line =
.
There is a lot of theory on the ILTs. This is outside of the scope of this course.
Our approach to inverting LTs will be to try to reduce a general complex function to a sum of
elementary, known LTs which we can straightforwardly invert.
Most LTs we will encounter are rational polynomial functions which can be expanded in partial fractions.
PARTIAL FRACTION EXPANSION
(a) Example 1 Antitransform
G(s) =
s2
1
3s + 2
s1,2 =
98
=
2
(
2
1
1
A
B
A(s 1) + B(s 2)
=
+
=
3s + 2
s2 s1
(s 2)(s 1)
(
A+B =0
s(A + B) (A + 2B) = 1
A + 2B = 1
G(s) =
s2
14
Elisa Franco
So we find A = 1, B = 1. Therefore:
G(s) =
1
1
s2 s1
Which was easy to find using the Laplace transform of the exponential function.
(b) Example 2 Antitransform:
G(s) =
1
s(s2 + 1)
G(s) =
1 1
s
1
= 2
+
2
ss +1
s +1 s
G(s) =
s2
1
+ 2s + 2
1
1
=
+ 2s + 2
(s + 1 j)(s + 1 + j)
1
=
(s + 1)2 + 1
G(s) =
s2
g(t) = et sin t
II.5
( d2 y
+ 3 dy
dt + 2y(t) = (1 + 3t)u(t)
y(0 ) = 1, dy
=0
dt |
dt
t=0
1
3
s2 Y (s) s y(0 ) y(0
) + 3 [s Y (s) y(0 )] + 2 Y (s) = + 2
s s
2
1
3
s Y (s) s + {3 [s Y (s) 1]} + 2 Y (s) = + 2
s s
1
3
(s2 + 3 s + 2)Y (s) s 3 = + 2
s s
s+3
1
Y (s) = 2
+ 2
s + 3s + 2 s + 3s + 2
1
3
+ 2
s s
= YN (s) + YF (s)
15
Elisa Franco
Natural response YN .
The roots of the denominator are: s1 = 1, s2 = 2. Then:
YN =
C1
C2
+
(s + 1) (s + 2)
Find C1 and C2 :
YN =
C1 (s + 2) + C2 (s + 1)
s(C1 + C2 ) + 2 C1 + C2
s+3
=
= 2
2
2
(s + 3s + 2)
(s + 3s + 2)
s + 3s + 2
(
C1 + C2 = 1
2 C1 + C2 = 3
We get C1 = 2, C2 = 1.
YN =
1
2
(s + 1) (s + 2)
YF =
C3,1 C3,2
C1
C2
+
+ 2 +
(s + 1) (s + 2)
s
s
3
7
1
yF (t) = t 1(t) + 2 et e2t
2
4
4
9. Lets recap:
(a) We have a method to write down systems in state space form and solve the ODEs.
(b) We have seen how to find the solution to an ODEs applying directly the Laplace transform method
to the differential equation.
Now lets use this method to analyze a model of a physical system and find the solution to the ODEs.
Consider a modification of our mass-spring system, operating on a horizontal plane with dynamic friction
- Figure 14.
kl0
u(t)
l(t)
d2 (l l0 )
d(l l0 )
+ k(l l0 ) + b
= u(t)
dt2
dt
16
Elisa Franco
d
(l l0 ) is a term describing viscous friction.
b dt
Defining y = (l l0 ):
d2 y
dy
+ky +b
= u(t)
2
dt
dt
+ by(0) + U (s)
Y (s) =
U (s)
(sM + b)y(0) + M y(0)
+
2
2
M s +{zbs + k
} |M s +{zbs + k}
|
natural response
II.6
forced response
F (s) =
N (s)
, N (s), D(s) polynomials in s = + j
D(s)
deg(D) = nd , deg(N ) = nd , nn < nd
F (s) =
IMPORTANT DEFINITIONS:
F (s) =
C1,m1
C1,1
+ ... +
+
(s p1 )
(s p1 )m1
C2,1
C2,m2
+
+ ... +
+
(s p2 )
(s p2 )m2
Cn,1
Cn,mn
+
+ ... +
(s pn )
(s pn )mn
Linearity:
1
[F (s)] =
mi
n X
X
i=1 k=1
Ci,k
(s pi )k
Ci,k
Ci,k
=
t(k1) epi t 1(t)
k
(k 1)!
(s pi )
17
Elisa Franco
NOTE: Repeated poles are associated to exponential functions multiplied by a power of time factor. What drives
the convergence of each term is the sign of the real part of the pole. (Exponential functions converge or diverge
faster than any power.)
Going back to the use of Laplace transforms to solve linear time invariant systems.: recall our definition of
eigenvalues of the A matrix in state space form. The poles are a subset of the eigenvalues of A.
p<0
p=0
k=1
0.8
Real poles:
p>0
1.5
1
1
0.5
10
0.5
0
10
10
10
10
0.4
10
0.3
k=2
1
t(k1) ept
(k 1)!
2.5
1.5
x 10
0.2
0.1
0
10
0.5
10
0
5
0.4
50
15
x 10
40
0.3
k=3
x 10
1.5
0.4
2.5
0.6
0.2
10
30
0.2
20
0.1
0
10
0
Time
10
Time
10
Time
18
Elisa Franco
k=1
<0
Complex poles
0.5
0.5
0.5
0.5
x 10
>0
2
1
0
10
1
0
10
10
10
10
k=2
1
t(k1) e(+j)t
(k 1)!
0.4
10
0.2
0.2
0.4
10
x 10
2
1
0
10
1
0
10
0
6
0.4
50
1.5
x 10
0.2
k=3
L1
=0
0.5
0
0
0
0.2
0.4
0.5
0
Time
10
50
Time
10
Time
19
Elisa Franco
III
Block diagrams
As a consequence of the convolution property of Laplace transforms (convolution integrals become products!)
we can represent dynamical systems in a very simple and convenient way.
As an example, consider again the mass-spring-damper system in Fig. 15:
k
r(t)
M
Mg
M r = M g kr br
Assuming zero initial conditions, and applying the derivative rule:
M s2
M
+ sb + k
R(s)
Figure 16: Mass-spring-damper system: block diagram in the Laplace complex domain
With Laplace transforms we can represent interconnected systems of differential equations with blocks. And
(because of the convolution property) there are some useful simplification rules. These block diagrams are
much simpler than the diagrams in the time domain - see, for instance, Fig. 7.
1) Series, Figure 17
U (s)
H1 (s)
H2 (s)
Y (s)
U (s)
H1 (s) H2 (s)
Y (s)
20
Elisa Franco
H1 (s)
U (s)
Y (s)
U (s)
H1 (s) + H2 (s)
Y (s)
H2 (s)
Figure 18: Representation of blocks in parallel the Laplace domain
If our error is E(s) = Yd (s) H(s)Y (s), where Yd (s) is the desired output in the Laplace domain, we have that
Y (s) = G(s) [Yd (s) H(s)Y (s)]. Therefore, we collect Y (s) and derive:
Yd (s)
+
_
E(s)
G(s)
Y (s)
Y (s) =
G(s)
Yd (s)
1 + G(s)H(s)
Yd (s)
G(s)
1 + G(s)H(s)
Y (s)
H(s)
Figure 19: Representation of blocks in a negative feedback interconnection, in the Laplace domain
21
Elisa Franco
III.1
Exercises
Exercise 1:
F (s) =
s+3
s+5
Exercise 2:
F (s) =
s+1
s2 + 2s + 5
F (s) =
12
(s + 2)2 + 9
Exercise 3:
Exercise 4:
F (s) =
Solution: f (t) = e3t (cos(4t) +
1
2
sin(4t))
(s 1)
(s2 6s + 25)