Sie sind auf Seite 1von 44

Discrete-time approximations of

continuous controllers; discrete


PID controller
Discrete approximation of a continuous
controller

e(t) u(t)
y(t)
r (t) +
Controller Process
_

y(t)
Approximation of the transfer function
The aim in the approximation of a continuous transfer
function is to develop a discrete system, which
corresponds to the continuous transfer function. This
has earlier been done, but then assuming a zero order
or first order hold.
But the hold assumtion is not always valid (the output
signal y changes arbitrarily and the controller measures
the signal as such). Usually a discrete approximation
starts from the approximations of the derivative and the
integral, assuming that the signal is smooth.
Approximations of the derivative
Starting from the definition of the derivative
df  (tn )  f (tn )  f (tn  t ) f(t) .
 f  (tn )  lim . f + (t n )
dt t 0 t f - (t n )
df (tn )  f (t  t)  f (tn )
 f (tn )  lim n
dt t 0 t t

tn
The results are the same for smooth functions

f ( t )  f ( t )  f ( t )
Approximations of the derivative
From these definitions the backward and forward
approximations are obtained. The ”Euler method” is
the same as forward derivation.
1
f ( kh )  f ( kh  h ) 1  q
p  f ( t )  f ( t )  f ( kh)   f ( kh)
h h
f ( kh  h)  f ( kh) q  1
p  f (t )  f (t )  f ( kh)   f ( kh)
h h
Approximations are
1  q 1 q  1 1  q 1 q  1
p  p  1 
h qh q h h
Approximations of the integral
Correspondingly, integrals can be approximated as
sums
f(t) f(t)

hhh hhh h h h h h h h h
t t

z z k 1
t k t
1 1
f (t )  f ( )d   f (ih)  h  f (t )  f ( ) d   f (ih)  h
p  i  p  i 
Approximations of the integral
 
c h
k
h

i 
f (ih)  h   q  f ( kh) h  f ( kh) h  q
j 0
j

j 0
1 j

1 q 1
f ( kh)

k 1  
q 1h
 f (ih)  h   q
i  j 0
 ( j 1)
 f ( kh)h  q h  f ( kh)  q
1

j 0
j

1 q 1
f ( kh)

The same approximations can also be derived


recursively. For example

z
t k
Int f ( t )  f ( ) d   f (ih)  h
i 

Approximations of the integral

z
kh k
 Int f ( kh)  f ( )d   f (ih)  h
i 

k 1 k
 Int f ( kh  h)   f (ih)  h   f (ih)  h  f ( kh  h)  h
i  i 

 Int f ( kh)  f ( kh  h)  h
 Int f ( kh  h)  Int f ( kh)  f ( kh  h)  h
 (q  1)  Int f ( kh)  qf ( kh)  h
qh h
 Int f ( kh)  f ( kh)  1
f ( kh)
q 1 1 q
Approximations of the integral
The integral approximations are
1

h

qh 1 q 1h h
and  
p 1  q 1 q  1 p 1  q 1 q  1

By comparing to the approximations of the derivative,


we see that they are analogous.

1  q 1 q  1 1  q 1 q  1
p  p  1 
h qh q h h
Approximations of the integral
Let us derive one more integral approximation. The
use of the trapetsoidal rule to the integral leads to the
Tustin approximation or the bilinear approximation.
The result is:

z 1 k 1
t
1 1 k
f ( t )  f ( )d   f (ih)  h   f (ih)  h
p 
2 i  2 i 
1 qh 1 h h q 1
  f ( kh)   f ( kh)   f ( kh)
2 q 1 2 q 1 2 q 1
1 h q  1 h 1  q 1 2 q  1 2 1  q 1
     p   
p 2 q  1 2 1  q 1 h q  1 h 1  q 1
Approximations of differential equations
Each derivative operator p is substituted by the shift
operator q or by a function of it.

Approximation of 1  q 1 q  1
p 
backward h qh
differentiation
1  q 1 q  1
Euler approximation p  1 
q h h

Tustin approximation 2 1  q 1 2 q  1
p  1
 
h 1 q h q 1
Approximations of the transfer functions
When playing with transfer functions and pulse transfer
functions, then instead of p and q the variables s and z
are used.

H ( z)  GG
F 1 z I 1

J  GG
F z  1I
J
H h K zh K H
Backward differences bd

F
H ( z)  GG
1 z I
1

J  GG
F z  1I
J
Euler approximation e
H hz K H h K
1

F
H ( z)  GG 
2 1 z I
J
1
F
G 2 z  1I
J
Tustin approximation t
H h 1  z K h z  1K

1
G
H 
Approximations of the transfer function,
example

For a given system develop a discrete approximation


and pulse transfer function.
Continuous differential system : y ( t )  2 y ( t )  u( t )
1
The corresponding transfer function: G ( s) 
s2
First, the ZOH equivalent is calculated
(1  e 2 h )
1
y ( k  1)  e 2 h y ( k )  21 (1  e 2 h ) u( k ) H zoh ( z )  2
z  e 2 h
Approximations of the transfer function,
example

By using the backward difference approximation

q 1
y (t )  2 y (t )  u (t )  y (kh)  2 y (kh)  u ( kh)
qh
 (q  1) y (kh)  2hqy ( kh)  hqu (kh)
 y (kh  h)  y ( kh)  2hy (kh  h)  hu (kh  h)
 (1  2h) y (kh  h)  y (kh)  hu (kh  h)
1 h
 y (kh  h)  y (kh)  u (kh  h)
1  2h 1  2h
Approximations of the transfer function,
example
the Euler approximation
q 1
y (t )  2 y (t )  u (t )  y (kh)  2 y (kh)  u (kh)
h
 (q  1) y (kh)  2hy ( kh)  hu ( kh)
 y ( kh  h)  y ( kh)  2hy ( kh)  hu (kh)
 y (kh  h)  (1  2h) y (kh)  hu (kh)
the Tustin approximation
2 q 1
y (t )  2 y ( t )  u( t )   y ( kh)  2 y ( kh)  u( kh)
h q 1
Approximations of the transfer function,
example
 2(q  1) y(kh)  2h(q  1) y(kh)  h(q  1)u(kh)
 y(kh  h)  y(kh)  hy(kh  h)  hy(kh)  12 hu(kh  h)  12 hu(kh)
 (1  h) y(kh  h)  (1  h) y(kh)  12 hu(kh  h)  12 hu(kh)
1 h 1
h 1
2h
 y(kh  h)  y(kh)  2
u(kh  h)  u(kh)
1 h 1 h 1 h

The pulse transfer functions can be derived


1 FG z  1IJ  1  zh
G ( s) 
s2
 Hbd ( z )  G
H zh K FG z  1IJ  2 z  1  2zh
H zh K
Approximations of the transfer function,
example
h
z
 1  2h
zh
 Hbd ( z ) 
(1  2h) z  1 z  1
1  2h
For the other approximations
1 FG IJ
z 1 1 h
G ( s) 
s2
 He ( z )  G
H K FG IJ
h

z 1

z  1  2h
H K
h
2
h h

1 F 2 z  1I h  1
H ( z)  GG  J
2
z
h 1
2

G ( s) 
s2
 t
H h z  1K z  h  1

h 1
Approximations of the transfer function,
example
Compare the different
approximations by simulation.
Try the step function input
(ZOH-assumption is valid)
1

0.8

0.6

0.4

0.2

-0.2

-0.4

-0.6

-0.8

-1

0 2 4 6 8 10 12 14 16 18 20
Approximations of the transfer function,
example
With high sampling frequencies all approximations work well;
however, this is not the case for lower sampling rates.
h=0.01 h=0.1

0.5 0.5

0 0

-0.5 -0.5

0 5 10 15 20 0 5 10 15 20

h=0.5 h=1

0.5 0.5

0 0

-0.5 -0.5

0 5 10 15 20 0 5 10 15 20
Approximations of the transfer function,
example

The ZOH-
approximation
works well for
all sampling
rates, because
the input signal
happens to be
constant
between the
sampling
instants.
Approximations of the transfer function,
example

The backward
difference
approximation
seems to work
well.
Approximations of the transfer function,
example

The Euler
approximation
gives an
unstable
response for
low sampling
rates.
Approximations of the transfer function,
example

The Tustin
approximation
works
reasonably
well
Approximations of the transfer function,
example

For smooth
signals all ZOH B.D

approximations 0.5 0.5

give a good
0 0
response. A
sinusoidal -0.5 -0.5

signal with 0 5 10 15 20 0 5 10 15 20

sampling Euler Tustin

interval h = 1. 0.5 0.5

0 0

-0.5 -0.5

0 5 10 15 20 0 5 10 15 20
Stability of the approximated transfer functions

As shown, the approximation of a stable transfer function


may be unstable (in the above example the Euler
approximation). Each pole sP is mapped into the discrete
pole zP according to the approximation.
  1  1
sP h
zP,ZOH  esPh 1 z 1 s h z  2
z P ,BD  P ,Euler P P ,Tustin
1  21 sP h
1 s h P

With high sampling rates all the approximated transfer


functions behave identically (approach the continuous
system); their poles approach the point 1.
lim z P ,i  1
h 0
Stability of the approximated transfer functions
Regardless of the method used, the discretized pulse transfer
function is stable only if its poles are located inside the unit
circle. It is therefore interesting to consider how the LHP (left
half plane) is mapped into discrete domain. In the figure
below the shadowed areas denote those points, into which
the LHP is mapped.

ZOH BD Euler Tustin


Stability of the approximated transfer functions

Only for the ZOH and Tustin method stability is identical in


the continuous and discrete time case. Backward derivation
maps stable systems to stable systems, but it also gives to
some unstable systems a stable discrete equivalent. The
Euler method maps a group of stable continuous systems
into unstable equivalents (as shown in the simulations).
Frequency folding
Many control design methods are based on the study of the
frequency response (like the analysis of lead and lag
compensators). Approximations on the other hand fold the
frequency scale, which means that the response in a critical
frequency may give inproper information.
Consider an example case. For the Tustin approximation it
holds that
F 2 1 z I
H ( z)  GG 
1

J F 2 z  1I
 GG  J
t
H h 1  z K h z  1K
1
H
Frequency folding
Compare the frequency response of the continuous process
G(s) to that of a Tustin equivalent H(z).
Continuous response: F ( )  G (i )
Discrete response: F ( )  H (eih )
By the Tustin approximation:

F
H (e )  G G 
2 e  1I
i h F i h
2 e e
 i2h
I  GF 2  i sin( ) I
h
J  GG  JK GH h cos( ) JK
2
i h

H h e  1K H h e  e
2
i h i h
2
 i2h h
2

 Gbi  tan( ) g
2
h
h
2 G (i )  G bi  tan(
2
h
h
2 )g
Frequency folding
That means that if the continuous system performance has
been optimized at a certain frequency w’, the Tustin
approximation folds the frequency scale into the frequency w,
for which it holds:
2
 '  tan
FG IJ
h 2
   tan 1
 ' hFG IJ
 ' 1
(FG
 ' h ) 2
IJ
h H K
2 h 2 H K H
12 K
It is easy to modify the Tustin approximation such that the
frequency folding is removed at a given frequency w1.
F
(z)  G G
 z  1I
H tan( h / 2 ) z  1 JK

1
H t , pw
1
Discrete PID-controller
The discrete PID-controller is the most frequently used
controller in process industry today. It can easily be derived
from the continuous PID-controller. The “textbook version”
of the continuous PID-algorithm is
F
u(t )  K G e(t )  z e( s)ds  T
t
de(t ) I
H T
1
I 
D
dt K J  P ( t )  I ( t )  D( t )

F
 U ( s)  G ( s) E ( s)  K G1 
1 I
 T sJ E ( s)  P( s)  I ( s)  D( s)
PID
H Ts K I
D

Ideal derivation cannot (and must not) be realized in a PID-


controller. Practical systems always contain high frequency
disturbances (e.g. white noise), which are attenuated by
derivation.
Discrete PID-controller
Because of that a lag term is usually added to the derivation.

TD s TD i 
TD s  TD i
1  TD i N
1  TD s N
 

Other practical modifications are:


- Derivate only the output (not the reference, not the error
signal)
- Only part of the set point (b) affects the gain.
Discrete PID-controller
F
U ( s)  K G bY REF ( s)  Y ( s) 
1
(YREF ( s)  Y ( s)) 
TD s IJ
H TI s 1  TD s N
Y ( s)
K
 Pm ( s)  I ( s)  Dm ( s)

For the “textbook version”


R| R|
P(t )  Ke(t ) P( kh)  Ke( kh)
|| K ||
S|I (t )  T z e(s)ds
t k 1
 S|I (kh)  T  e(ih)h  K e(kh)
K
I i 
1
TI

||D(t )  KT de(t ) ||D(kh)  KT e(kh)  e(kh  h)  K


I  h

e( kh)
T
TD

T D
dt
D
h h
Discrete PID-controller
The Euler approximation cannot be used, because the
controller would not be causal (a future value would be
needed to calculate the derivative). For the integral part the
Euler approximation is usually used. A discrete PID-
controller is obtained by substituting the integral of the error
by a sum, the derivative by a difference, and by dividing the
parameters TI and TD with the sampling interval h.

F
u( kh)  K G e( kh)  e( kh) 
1 TD I
e( kh)J
H TI
h
h
K
Discrete PID-controller
As a pulse transfer function the controller is
F
U ( z)  K G1  
1 1
 TD z 1 IJ
E ( z )  H PID ( z ) E ( z )
H z 1
TI
h
h
z K
The algorithm is called absolute, because it calculates the
total value of the controller output. That means the
calculation of a sum at each time instant, which is not
effective algorithmically. The velocity form of the algorithm is
much more effective, because only the change of the
controller output is calculated at each step. Hence it is not
necessary to calculate a large sum.
Discrete PID-controller
The change becomes: u( kh)  u( kh)  u( kh  h)
F k 1
u( kh)  K G e( kh)   e(ih)  be( kh)  e( kh  h)gJ
1 TD I
H TI
h i 
h
K
F k 1
 u( kh)  K G e( kh)  e( kh  h)   e(ih)   e(ih)
1 1 k 2

H TI
h i 
TI
h i 

 be( kh)  e( kh  h)g  be( kh  h)  e( kh  2h)gi


TD
h
TD
h

F I
 K G e( kh)  e( kh  h)  e( kh  h)  be( kh)  2e( kh  h)  e( kh  2h)gJ
1 TD

H TI
h
h
K
F F I
 K G d1  ie( kh)  G  2  1J e( kh  h)  d ie( kh  2h)J
TD 1 TD TD
I
H h
H TI
h Kh h
K
Discrete PID-controller
The velocity form can also be z-transformed
F TD F
U ( z )  K G d1  i  G  2
1 TD I 1I
 1J  d i J E ( z )
1 TD

H h
H TI
h
h
Kz z Kh 2

It must be noticed that the above PID-algorithms are not the


only interpretation of a discrete PID-algorithm. If backward
integration is used in the integral part, the formula below
follows.The structure of the used discrete PID algorithm must
always be told together with the tuning values.

FG z  1IJ  K FG1  1 z  IJ
z 1
H PID ( z )  G PID
H zh K H z  1
TD
TI
h
h
z K
Discrete PID-controller
The discretization of a practical PID-controller is as
straightforward.
R|
R| ||
|| P ( s)  KbbY ( s)  Y ( s)g
m REF || P ( z)  KbbY ( z)  Y ( z)g
m REF

S| I ( s)  T s E ( s)
K
 S| I ( z)  T z  1  K z  1
K h
TI
1 1

|| D ( s)   KT s Y ( s) ||
I I h

D z 1
m
T 1 T s N
D
m || D ( z)   KT Tzhz  1 Y ( z)
D

|T 1
D
N zh
Discrete PID-controller
If a difference equation form is needed

 P (kh)  K  by (kh)  y (kh) 


 m REF

(1  q ) I ( kh)  K TI q  yREF ( kh)  y ( kh) 
1 h 1


 
1  TD
Nh (1  q 1
) D m 
( kh )   K TD
h (1  q 1
) y ( kh)

Pm ( kh)   byREF ( kh)  y ( kh) 


I (kh)  I (kh  h)  K h
TI  yREF (kh  h)  y (kh  h) 
TD
K ThD K ThD
Dm ( kh)  Nh
Dm (kh  h)  y ( kh)  y ( kh  h)
1 TD
Nh 1  Nh
TD
1  Nh
TD
Discrete PID-controller
All modifications of the PID-controller can be realized with a
discrete PID-controller. The most important ones for the
integrator are the antiwindup-operation for saturating
actuators, a soft mode change when switching from manual
to automatic operation (and vice versa), and bumpless
parameter value changes in self-tuning and adaptive PID
algorithms. For instance, when an actuator saturates the
integrator continues to grow into very high values. After the
normal operation conditions have been restored it takes time
for the integrator to return to normal values. During this time
the controller does not operate well. That phenomenon is
called ”integrator windup”. For cure, some ”antiwindup”
mechanism is used. The simplest antiwindup is simply to
stop integration, when the actuator saturates.
”Integrator windup” and ”antiwindup”

y The dashed line shows the out-


put of a controlled system
under integrator windup. The
solid line shows the response
when antiwindup is used.
u

The antiwindup-operation must


not be forgotten when realizing
practical control algorithms!
”Integrator windup” and ”antiwindup”
y
KTd s
Actuator
e +
+ v u Example of an
K
+ antiwindup
K +
1 - + circuit
Ti + s
es
1
Tt

When the actuator performs normally, an orinary PID operation


takes place (note: the derivative part acts only on the output sig-
nal). Under saturation the signal es deviates from zero, and
corrects the value of the integrator towards the ”correct”
direction (compare to the figure in the previous page).
Tuning of a discrete PID-controller
Discrete and continuous PID-controller behave identically
with a high sampling frequency. Well-known tuning rules of
the continuous PID-controllers can then well be used:
- Step response method (the step response of the open-
loop process is measured and the dead time, time
constant and static gain are measured; the PID tuning
parameters are determined based on these values)
- Frequency limit method (the process is controlled (closed
loop) by a P-controller; the gain of the controller is
increased until the system oscillates in the stability boundary)
Choice of the sampling rate
In most commercial unit controllers the sampling rate is high
and fixed (e.g. the sampling interval 200 ms).
If it must and can be chosen, for the PI-controller a rule of
thumb says
h h h
 0.10.3,  0.31,  0.10.3
TI L Tu
where L is the dead time and Tu the period of the oscillation
(frequency limit method)
For PID the sampling rate must be higher
hN h
 0.20.6, N  10,  0.010.06
TD L

Das könnte Ihnen auch gefallen