Discrete Approximation
of Continuous Systems
CSE 421 Digital Control
Lecture 3
1
Introduction
• One approach for Digital Controller Design is an
indirect one. The procedure is as follows:
1. Design a continuous-time controller H(s)
2. Find a discrete system H(z) approximating the
behavior of H(s) using numerical integration
3. Realize H(z) on a computer.
2
Example
• Given the first-order system
U (s) a
H (s) ,
E (s) s a
• Cross-multiplying and using inverse Laplace
transform we get
u (t ) au (t ) ae(t )
• We integrate to obtain u(t),
t
u (t ) au ( ) ae( )d
0
3
• In discrete time, we can express this integral in two
intervals: [0, kT−T] and [kT−T, kT]
kT T kT
u (kT ) au ( ) ae( )d au( ) ae( )d
0 kT T
kT
uk uk 1 au( ) ae( )d
kT T
area over kT T t kT
• This area may be approximated in three ways:
• Forward rectangular
• Backward rectangular
• Trapezoidal
4
a
Forward & backward rules sa
kT
u k u k 1 au ( ) ae( )d
kT T
u k 1 [au k 1 aek 1 ]T
(1 aT )uk 1 aTe k 1
U ( z) aT a
E ( z ) z (1 aT ) z 1
a
T
u k uk 1 [au k aek ]T
U ( z) aTz a
E ( z ) (1 aT ) z 1 z 1
a
Tz 5
Trapezoidal rule
kT
u k u k 1 au ( ) ae( )d
kT T
T
uk 1 [ au k 1 aek 1 auk aek ]
2
aT aT
z
U ( z) 2 2 a
E ( z ) aT aT 2 z 1
1 z 1 a
2 2 T z 1
6
Mapping between s and z plane
• Comparing the original H ( s) a ,
sa
with the three H(z) we obtained, the following
approximations for s are obtained.
• This may be viewed as mapping from the s-
plane to the z-plane.
7
Comparison of Integration
Rules
• It is instructive to see where in the z-plane these
approximations transform the left-half s-plane
(the region of stable s-plane poles).
• To this end, solve for the inverse mapping, then
substitute for s = jω.
8
Comparison of Integration
Rules
• The mapping of the left-half s-plane are as shown below.
• With forward rectangular rule, there is a possibility that a
stable continuous system results in an unstable discrete
approximation.
• With trapezoidal rule, stable continuous system H(s) will
result in a stable discrete system H(z) and vice versa.
• Among these three methods, only trapezoidal rule is used
in MATLAB. It is called “Tustin” approximation.
9
Example 1
• With MATLAB, find the discrete approximation of the
following continuous system. Use trapezoidal rule
approximation and a sample period T = 0.05.
10
H ( s)
s 10
numc = [0 10]; % numerator & denominator
denc = [1 10];
sysc = tf(numc,denc); % Create continuous LTI system
T = 0.05; % Sampling period
sysd = c2d(sysc,T,’tustin’) % Discretize using
trapezoidal rule; Rectangular rules are not supported
0.2 z 0.2
• Transfer function: H ( z)
z 0.6 10
Example 1, continued
• Sometimes you need to extract the numerator and
denominator from the LTI description of the
system.
• Using the result obtained above, here’s how to use
tfdata:
[numd,dend] = tfdata(sysd,’v’)
numd = 0.2 0.2
dend = 1.0 -0.6
• NOTE: Don’t forget the ’v’ or you’ll be in for grief!
11
Example 2
• The continuous-time PID controller has the transfer
function
U ( s) 1
K c 1 Td s
E (s) Ti s
• Where the gain Kc, the integral time Ti, and the
derivative time Td are the controller parameters.
• Derive the equivalent discrete-time controller
transfer function using the backward Euler
approximation.
12
Answer z 1
• First, we use the substitution s Tz
Tz z 1 (T / Ti ) z z 1
GPID ( z ) K c 1 Td K c 1 (Td / T )
Ti ( z 1) Tz ( z 1) z
z ( z 1) (T / Ti ) z 2 (Td / T )( z 1) 2
K c
z ( z 1)
• The discrete PID controller is given by the following
transfer function:
U ( z ) K 0 K1 z 1 K 2 z 2
1
,
E( z) 1 z
T Td T Td
K 0 K c 1 , K1 K c 1 2 d 2
, K K c
Ti T T T 13
Implementation of Difference
Equations in Real Time
• It is time to consider how to construct computer
programs that will realize the difference equations we
obtain.
• Consider the second-order discrete transfer function:
U ( z ) b0 b1 z 1 b2 z 2
H ( z)
E ( z ) 1 a1 z 1 a2 z 2
• with corresponding difference equation
uk a1uk 1 a2uk 2 b0 ek b1ek 1 b2 ek 2
• We assume that there is an interrupt occuring every T
seconds. When an interrupt occurs, variable FLAG is
set to one.
14
Implementation of Difference
Equations in Real Time
10 while (FLAG == 0) wait;
20 e = adc_in(); % Read error ek
30 u = a1*u1 + a2*u2 + b0*e + b1*e1 + b2*e2; % compute uk
40 dac_out(u); % Write output u(k) to D/A converter.
50 e2 = e1; % Propagate variables backwards for next sample
60 e1 = e;
70 u2 = u1;
80 u1 = u;
90 Goto 10; % Execute continuously. 15