Slides Control of Discrete Systems
Slides Control of Discrete Systems
ENSICA
Yves Briere
ISAE
General Introduction
1
Overview
Prerequisites :
Automatique ENSICA 1A et 2A
Traitement numérique du signal ENSICA 1A
(Control and signal processing, basics)
Tools :
Matlab / Simulink
References :
• « Commande des systèmes », I. D. Landau, Edition
Lavoisier 2002.
Planning
22 slots of 1h15
Overview
Control methods
Control by computer
2
I. Introduction
3
II. Discrete signals and systems
F4(z)
E(z)
U(z) S(z)
R(z) S(z) F1(z) F2(z)
–
T(z) F3(z)
Or, simply :
p(z)
u(z) e(z) s(z)
F(z)
–
7
4
II. Discrete signals and systems
s(k ) = {s 0 , s1 , s 2 ,...}
Z-transform : function of the complex z variable
∞
s(z ) = Z(s(k )) = ∑ s(k ) ⋅ z −k
k =0
∞
1 s(z ) = Z(s(k )) = ∑ s(k ) ⋅ z −k
k =0
4 ( )
Z c ⋅ s(k ) = s
k z
c
5 Z(s(k − 1)) = s(k = −1) + z −1 ⋅ s(z ) Delay theorem
6 Z(s(k + 1)) = z ⋅ s(z ) − z ⋅ s(k = 0 )
7 s(k = 0 ) = lim z→∞ (s(z ))
z −1 Final value theorem
8 s(k → ∞ ) = lim z→1 ⋅ s(z )
z
10
5
II. Discrete signals and systems
s(k) S(z)
δ(k) : unit impulse 1
z
u(k) : unit step
z −1
z
k.u(k)
(z − 1)2
z
c k ⋅ u (k )
z−c
z ⋅ sin (ω)
sin (ω ⋅ k ) ⋅ u (k )
z − 2 ⋅ z ⋅ sin (ω) + 1
2
11
Reminder : from « z » to « k »
First approach : use the z-transform equations (we don’t give here the
inverse z-transform equation, it is too ugly...)
12
6
II. Discrete signals and systems
The sequence of output and input samples are consequently simply related
by:
s(k ) + a 1 ⋅ s(k − 1) + a 2 ⋅ s(k − 2 ) + ... + a n ⋅ s(k − n ) =
b 0 ⋅ e(k ) + b1 ⋅ e(k − 1) + b 2 ⋅ e(k − 2) + ... + b m ⋅ e(k − m )
The delay theorem gives:
s(z ) b + b1 ⋅ z −1 + b 2 ⋅ z −2 + ... + b m ⋅ z − m
= F(z ) = 0
e(z ) 1 + a 1 ⋅ z −1 + a 2 ⋅ z −2 + ... + a n ⋅ z − n
Normalized : a0 = 1 13
14
7
II. Discrete signals and systems
Step response
b 0 + b 1 ⋅ z −1 + b 2 ⋅ z −2 + ... + b m ⋅ z − m
s(z ) =
1
×
1 + a 1 ⋅ z −1 + a 2 ⋅ z − 2 + ... + a n ⋅ z − n 1 − z −1
15
F(z ) =
( )(
e 0 ⋅ 1 + e1 ⋅ z −1 ⋅ 1 + e 2 ⋅ z −1 L 1 + e m ⋅ z −1 ) ( )
(1 + c 1 ⋅z −1
)⋅ (1 + c 2 ⋅z −1
)L (1 + c n ⋅z −1
)
Coefficients ci are either real or complex conjugates
For a stable system each ci coefficient must verify |ci| <1, in other words
each poles must belong to the unit circle.
F(z) can be decomposed in a sum of first order and second order systems
It is good to know how first and second order behaves
16
8
II. Discrete signals and systems
Imaginary Axis
2
0
1
0 -1
0 5 10 15 20 25 -3 -2 -1 0 1 2 3
5 0
0 -1
0 5 10 15 20 25 -3 -2 -1 0 1 2 3
10 0
0 -1
0 5 10 15 20 25 -3 -2 -1 0 1 2 3
100 0
0 -1
0 5 10 15 20 25 -2 0 2 4
Real Axis 17
π/T
0
π/T
-0.2
0.9π/T 0.1π/T
-0.4
0.8π/T 0.2π/T
-0.6
0.6π/T 0.4π/T
0.5π/T
-1
-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1
Real Axis
18
9
II. Discrete signals and systems
Imaginary Axis
2
0
0 -1
0 5 10 15 20 25 -3 -2 -1 0 1 2 3
0.5 0
0 -1
0 5 10 15 20 25 -3 -2 -1 0 1 2 3
zpk([],[0.2+0.9i 0.2-0.9i],1,1) Real Axis
2 Pole-Zero Map
1
Imaginary Axis
1 0
0 -1
0 5 10 15 20 25 -3 -2 -1 0 1 2 3
zpk([],[0.6+0.9i 0.6-0.9i],1,1) Real Axis
5 Pole-Zero Map
1
Imaginary Axis
0 0
-5 -1
0 5 10 15 20 25 -3 -2 -1 0 1 2 3
19
Real Axis
10
II. Discrete signals and systems
(
F(f ) = F z = e j⋅2⋅π⋅f
) f : normalized frequency (between 0 and 1)
f ∈ [0 1] F(f) : frequency response
15
10
Magnitude (dB)
-5
Bode diagram of a second order
-10
0
system. Note the linear scale for
-90
frequency.
Phase (deg)
-180
-270
-360
0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5
21
Frequency (Hz)
0
22
11
End of C1 C2
III. Sampling
continuous
systems
12
III. Sampled continuous systems
Discrete systems
Sampling is regular
Sampling is synchronous
The computer computes the control according to the
curr »ent measurement and a finite set of pas
measurements.
26
13
III. Sampled continuous systems
Sampling a continuous transfer function
Hypothesis :
The continuous transfer function is known
The ADC is a ZOH ☺
ZOH F(p)
27
Zero Holder Hold : the sampled input is blocked during one sampling
delay.
1
t
0 Te
28
14
III. Sampled continuous systems
Sampling a continuous transfer function
1 1 1
s(k ) = Z ⋅ F(s ) − z −1 ⋅ Z F(s ) = 1 − z −1 ⋅ Z F(s ) ( )
s s s
29
Tables Matlab
F(s) FBOZ(z)
1 1
Matlab
1 Te ⋅ z −1
−1 % Definition of a continuous s ystem :
s 1− z
sysc=tf(1,[1 1]) ;
b 1 ⋅ z −1
1 −1
% z_transfer function after sampling at Te
1 + a 1 ⋅ z
1+ T ⋅s T Te
Te=0.1;
− e −
b 1 = 1 − e a1 = − e
T T sysd=c2d(s ysc,Te,'zoh');
− L⋅s −1 −2 % Notation with z^-1
e b1 ⋅ z + b 2 ⋅ z
1+ T ⋅s −1
a 1 = −e −Te T
sysd.var iable='z
1 + a1 ⋅ z
L < Te
b1 = 1 − e
(L−Te ) T
b 2 = e −Te T
(e LT
)
−1
30
15
III. Sampled continuous systems
Sampling time delay equivalence
A sampling time of Te can be approximated as a delay of Te/2 :
instability in closed loo^p.
Nyquist Diagram
2
1.5
0.5
Imaginary Axis
0
>> F=2*s/(1+s+s^2)/s/(1+s)
>> G=F;
-0.5 >> G.ioDelay=0.5
>> nyquist(F,G)
-1 G F
-1.5
-2
-1.5 -1 -0.5 0 0.5 1 1.5 2
Real Axis
31
Sampling time : 5 Hz
32
16
III. Sampled continuous systems
Choice of sampling frequency
Bode Diagram
10
F F/(1+F)
5
Magnitude (dB)
0 System: untitled1
Frequency (Hz): 0.269
-5 Magnitude (dB): -7.36
System: F
System: untitled1 Frequency (Hz): 0.196
-10 Frequency (Hz): 0.0215 Magnitude (dB): -3
Magnitude (dB): -4.36
-15
-20
-45
-90
Phase (deg)
-135
-180
-225
-270
-1
10
33
Frequency (Hz)
0.97
0.5
Imaginary Axis
-1.5
0.88
-2
17
III. Sampled continuous systems
Choice of sampling frequency
0.9
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
2 4 6 8 10 12 14
35
0.9
0.8
0 .1 5
0.7
0 .1
0.6
0 .0 5
0.5
0.4 0
0.3
-0 .0 5
0.2
-0 .1
0.1
0 0 5 1 0 1 5
0 5 10 15
36
18
III. Sampled continuous systems
First approach : discretise a continuous controller
Transfer function :
ε(z ) − z −1 ε(z ) 1 − z −1
e(z ) = k p ⋅ ε(z ) + k D ⋅ = k p + k D ⋅ ⋅ ε(z )
Te Te
1 − z −1
S to z equivalence : s=
Te 37
Method s to z equivalence
Euler's forward 1 − z −1
s=
method z −1 ⋅ T e
Euler's backward 1 − z −1
s=
method Te
2 1 − z −1
Tustin method s= ⋅
T e 1 + z −1
38
19
III. Sampled continuous systems
First approach : discretise a continuous controller
0.8
Blue : zoh
0.6 Green : tustin
0.4
0.2
-0.2
-0.4
-0.6
(No problem if sampling
time is small)
-0.8
-1
-1.5 -1 -0.5 0 0.5 1 39
s z
(a) (b)
z z
(a) : continuous
1
(b) : Euler forward
(c) : Euler backward
(d) : Tustin
(c) (d)
40
20
III. Sampled continuous systems
End C3 C4
41
IV. Identification of
discrete systems
21
IV. Identification of discrete systems
Introduction
Before the design process of a controller one must have a discrete model of the
plant
For a full course on this topic see 3d year course “airplane identification”
43
Try to fit as well as possible a model (first order, second order with delay,
etc...)
... « fit as well as possible » ...
criteria ?...
optimisation ?…
44
22
IV. Identification of discrete systems
Naive approach
Example : real step test (o) and simulated first order step (x)
1.4
1.2
0.8
0.6
0.4
0.2
0 45
0 1 2 3 4 5 6 7 8
1 N
J= ∑ (y reel (t ) − y mesuré (t ))2
N t =1
>> t=0:0.1:8;
>> p=tf('p'); After some iterations one obtain J
>> sysreal=tf(1/(1+2*p)/(1+0.6*p)*(1+0.5*p))
minimal with tau=1.81 s
+0.02*randn(length(t),1);
>> yreal=step(sysreal,t)+0.02*randn(length(t),1);
>> ysimul=step(1/(1+2*p),t);
Better model with a delay, two
parameters to tune
>> plot(t,yreal,'bo',t,ysimul,'rx')
>> eps=yreel-ysimul;
>> J=1/length(eps)*eps'*eps;
46
23
IV. Identification of discrete systems
Naive approach
Drawbacks :
Test signals with high amplitude (is the system still linear ?)
Reduced precision
Perurbation noise not taken into account
Perturbation noise reduces the performance of the identification
long, not very rigorous...
Advantage :
easy to understand...
47
48
24
IV. Identification of discrete systems
perturbations
u(t) y(t)
ADC Physical system DAC
ŷ(t)
Numerical model
ε(t)
49
A⋅ y = B⋅u + e
White noise
( )
y predict ( t + 1) = − a1 ⋅ y ( t ) + a 2 ⋅ y ( t − 1) + ... + a n a ⋅ y ( t − n a + 1) +
...............................b1 ⋅ u ( t ) + b 2 ⋅ u ( t − 1) + ... + b n b ⋅ u ( t − n b + 1)
50
25
IV. Identification of discrete systems
Example of an Identification Process
Example : orders na = 3 et nb = 2
51
(
y predict ( t + 1) = − a1 ⋅ y ( t ) + a 2 ⋅ y ( t − 1) + ... + a n a ⋅ y ( t − n a + 1) + )
...............................b1 ⋅ u ( t ) + b 2 ⋅ u ( t − 1) + ... + b n b ⋅ u ( t − n b + 1)
52
26
IV. Identification of discrete systems
Least Square Algorithm
t
θˆ = F(t )∑ (y(i ) ⋅ φ(i − 1))
i =1
With :
i =1
53
(
θ ( t ) = θ ( t − 1) + F ( t ) ⋅ ϕ ( t ) ⋅ y ( t ) − θT ( t − 1) ⋅ ϕ ( t ) )
with :
−1 −1
F ( t ) = F ( t − 1) + ϕ ( t ) ⋅ ϕ ( t )
T
27
IV. Identification of discrete systems
Identification algorithms (general)
( )
θ(t ) = θ(t − 1) + F(t ) ⋅ ϕ(t ) ⋅ y(t ) − θ T (t − 1) ⋅ ϕ(t )
avec
F(t ) = λ ⋅ F(t − 1) + ϕ(t ) ⋅ ϕ(t )
−1 −1 T
55
56
28
IV. Identification of discrete systems
Identification method
2. Excitation signal
Le signal doit être riche en fréquence
Signal can (and must) be of small amplitude (a few %)
0.5
Matlab / System Identification Toolboxe
0
-1.5
0 5 10 15 20
∆t
2∆t
57
5. Apply algorithm
Example : rls
6. Validate
Validation criteria ?
Iterate
58
29
IV. Identification of discrete systems
Validation criteria
2. The model behavior must be the same than the original for perturbations
The model :
y(t + 1) + a1 ⋅ y(t ) + a 2 ⋅ y(t − 1) + ... + a n a ⋅ y(t − n a + 1) =
b1 ⋅ u (t ) + b 2 ⋅ u (t − 1) + ... + b n b ⋅ u (t − n b + 1) + e(t )
With the estimated model (ai, bi) one can estimate the error !
e est (t ) = y est (t + 1) − y(t + 1)
e est (t ) = a1 ⋅ y(t ) + a 2 ⋅ y(t − 1) + ... + a n a ⋅ y(t − n a + 1)
............... − b1 ⋅ u (t ) + b 2 ⋅ u (t − 1) + ... + b n b ⋅ u (t − n b + 1)
............... − y(t + 1)
Check that eest(t) is a white noise !
59
60
30
IV. Identification of discrete systems
3. Validate :
prédiction
61
62
31
IV. Identification of discrete systems
Non parametric identification
63
V. Closed loop
systems
32
V. Closed loop systems
Reminder
P(z)
F4(z)
E(z)
U(z) S(z)
R(z) S(z) F1(z) F2(z)
–
T(z) F3(z)
Equivalent !
p(z)
u(z) e(z) s(z)
F(z)
–
66
33
V. Closed loop systems
Static gain
As seen before :
i=m
∑ bi
i=0
G0 = i=m i=n
1 + ∑ bi + ∑ a i
i =0 i =1
Condition to have a unitary closed loop static gain (no static error) :
i=m
∑ bi s(z ) B(z )
F(z ) =
1
G0 = i =0
=1 = ⋅
i=m i=n e(z ) 1 − z −1 A' (z )
1 + ∑ bi + ∑ a i
i =0 i =1
Integrator
67
S yp (z ) =
s(z )
=
A z −1 ( )
( ) ( )
p(z ) A z + B z −1
−1
68
34
V. Closed loop systems
Stability : poles
System is stable is the poles belong to the unit circle
Compute closed loop transfer function
Jury criteria (equivalent to Routh)
Compute poles
Draw the root locus
p(z)
e(z)
u(z) s(z)
K F(z)
–
69
0.6
0.2π/T
0.8π/T
0.4
0.1π/T
0.2
p(z)
0.9π/T System: sys
e(z) Gain: 0.0169
π/T
u(z) s(z)
Pole: 0.564 + 0.281i
0 K F(z) Damping: 0.706
π/T Overshoot (%): 4.35
– System: sys
Gain: 0.0162
Frequency (rad/sec): 0.654
0.9π/T 0.9
-0.2 Pole: 0.196
Damping: 1 0.8
0.1π/T
Overshoot (%): 0 0.7
-0.4 Frequency (rad/sec): 1.63 0.6
0.8π/T
0.5
0.4 0.2π/T
-0.6 0.3
0.2
-0.8 0.7π/T 0.1 0.3π/T
0.6π/T 0.4π/T
0.5π/T
-1
-0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1
70
35
V. Closed loop systems
Stability : frequency criteria
Nyquist criteria : as in the continuous case
Nyquist Diagram
1.5
Imaginary Axis
f=0
f=0.5
1
0.5
(-1,0)
-0.5
-1
-1.5
-1 -0.5 0 0.5 1 1.5
Real Axis
71
1/∆G
(-1,0)
- Module margin ∆M
- Gain module ∆G
∆M ∆P
- Phase module ∆P
72
36
V. Closed loop systems
end C5 C6
73
VI. Control of
sampled systems
37
VI. Control of closed loop systems
Hypothesis
Requisites :
Synchronous sampling
Regular sampling
Sampling time adapted to the desired closed loop performance
75
R, S et T are polynoms
76
38
VI. Control of closed loop systems
Discretization of a continuous controller
77
78
39
VI. Control of closed loop systems
PID 1
T ⋅ s
K PID (s ) = K ⋅ 1 +
1
Continuous PID : + d
Ti ⋅ s Td
1 + ⋅ s
N
1 − q −1
Td ⋅
Te
K PID (q ) = K ⋅ 1 +
1
Discretization (Euler) : −1
+ −1
1 − q T 1 − q
Ti ⋅ 1+ d ⋅
Te N Te
79
80
40
VI. Control of closed loop systems
PID 1
( )
P = A ⋅ S + B ⋅ R = A ⋅ 1 − z −1 ⋅ S'+ B ⋅ R
A,B,P R S’
81
82
41
VI. Control of closed loop systems
PID 2
R is replaced by R(1) :
B
H CL = R (1) ⋅
P
83
( )
A q −1 = 1 + a1 ⋅ q −1 + ... + a n ⋅ q − n A
A
( )
−1 −1 −n
B q = b1 ⋅ q + ... + bn B ⋅ q B = q ⋅ B q
−1 * −1
( )
Tracking performance
H CL =
( ) ( )
q − d ⋅ B q −1 ⋅ T q −1
P (q ) −1
P (q ) = A (q ) ⋅ S(q ) + q
−1 −1 −1 −d
( ) ( )
⋅ B q −1 ⋅ R q −1 = 1 + p1 ⋅ q −1 + ... + pn P ⋅ q − n P
A (q )⋅ S(q )
−1 −1
=
P (q )
Regulation performance : S yp −1
84
42
VI. Control of closed loop systems
Pole placement
Static gain :
S = (1-q-1).S’
Static gain :
S = (1-q-1).S’
86
43
VI. Control of closed loop systems
Pole placement
Tracking : choice of T
87
Tracking : choice of T’
( ) ( )q P⋅(qB(q) )
−d −1
S yy* q −1 = T' q −1 −1
With :
( ) PB(q(1) )
−1
T' q −1 =
One obtain :
( )
S yy* q −1 = q −d ⋅
( )
B q −1
B(1)
88
44
VI. Control of closed loop systems
Placement de pôle
89
Tracking : choice of T’
( ) ( ) qP(q⋅ q )⋅ B⋅ B(q(q ) )
−d −1 * −1
Syy* q −1 = T' q −1 −1 * −1
With :
( ) ( )
T' q −1 = P q −1
One obtain :
( )
Syy* q −1 = q − (d +1)
90
45