difference equations

advertisement
Lecture 2:
Linear Discrete Systems
1
Introduction
• The primary new component of discrete or digital systems is
the notion of time discretization. No longer are we dealing
with variables which are functions of time, now we have
sequences of discrete numbers.
• These discrete numbers may come from sampling a
continuous variable, or they may be generated within a
computer. In either case, the tools that were used in the
analysis of continuous variables will no longer work. We need
new methods.
• The z-transform bears exactly the same relationship to a
discrete variable that the Laplace transform bears to a
continuous variable. This is the new tool we need, and the
whole of transform-based digital control system design turns
on the z-transform.
2
Objectives
In these slides, we study the following topics:
•
•
•
•
Difference equations,
The z-transform,
The discrete transfer function.
The correspondence between discrete signals and the
continuous signals from which they were obtained (i.e.
the mapping linking the s and z planes).
• Relationship between z-plane pole locations and
transient response and stability.
3
Difference Equations
• While physical systems are modeled by (continuous) differential
equations, discrete systems are represented by difference
equations.
• Consider the block diagram shown, where an A/D converter
samples a continuous variable e(t) to produce discrete variable
e(kT), then a computer processes these samples e(kT) to produce
discrete output u(kT).
4
• To generate the kth output sample uk, the computer can make
use of past inputs and outputs as follows:
uk  f (uk 1 , uk  2 ,  , uk  n , ek , ek 1 ,  , ek  m )
• If the function f is linear, the relationship becomes a linear
difference equation given by
uk  a1uk 1  a2uk  2    anuk  n  b0 ek  b1ek 1    bm ek  m
• If the initial conditions and input are given, the output can be
calculated simply by evaluating the difference equation
recursively.
5
Example 1
• Consider the following difference equation which has
no input
uk  uk 1  uk  2 ,
with u0  u1  1


Initial conditions
• This equation computes the sequence known as
Fibonacci numbers.
• By recursive substitution in the difference equation,
the values of u2, u3, u4,… can be found as shown. You
would probably say that this system is unstable.
• Although any difference equation with a given input
can be “solved” in this manner, we need a better way
to solve or predict the behavior of difference
equations and discrete systems.
6
Solving Difference Equations
• Remember that to solve a linear differential equation, we
assume a solution of the form u(t) = Aest where s is a complex
variable.
• Similarly, let us assume that the solution of difference
equation takes the form u(k) = Azk where z is a complex
variable and k is the sample index. Substituting in the
previous difference equation yields:
uk  uk 1  uk  2
 Az k  Az k 1  Az k  2
 1  z 1  z  2  0
 z 2  z  1  0  characteristic equation
• The two roots of the characteristic equation are
z1  0.618, z 2  1.618
7
• The solution is therefore
uk  A1 (0.618) k  A2 (1.618) k
• where A1 and A2 are found from initial conditions to be 0.276 and
0.724, respectively. Hence the solution is
uk  0.276(0.618) k  0.724(1.618) k
• Of note here is the behavior of the two “modes” in the solution. The
mode associated with root -0.618 will decay, but the mode
associated with root 1.618 will grow.
• Since z is a complex variable, we can speak of the z-plane, a complex
number plane.
• An observation on stability that will be of fundamental importance
is “if any root of the characteristic equation of a discrete system has
magnitude > 1 (|z| > 1), i.e. lies outside the unit circle of the zplane, that system will be unstable”.
8
Example 2
Consider the numerical integration of a
continuous time variable, as shown
graphically.
We want the integral of the function e(t)
from t = 0 to t as given by
t
I   e( )d
0
using only samples e0, e1, . . ., ek−1 , ek.
We assume that the integral from t = 0 to
t = tk−1 is known, and is uk−1. Thus we just
want a procedure to take the “next step.”
9
• Although there are numerous methods, here we use
trapezoidal integration, in which we approximate the integral
by computing the area A of the trapezoid in the previous
figure. Thus
 ek  ek 1 
A  (t k  t k 1 )

2 

• Assume constant step size, so tk − tk−1 = T, thus
T
uk  uk 1  (ek  ek 1 )
2
• This is a linear difference equation for trapezoidal integration.
10
The z-Transform
• The z-transform has the same role in the analysis and design
of discrete systems as the Laplace transform has in continuous
systems.
• Given a discrete variable e(k) or ek with values e0, e1, . . .,
ek−1, ek, . . ., the z-transform of this variable is given by

E ( z )  Z {ek }   ek z  k  e0  e1 z 1  e2 z  2  e3 z 3  ...,
k 0
• That is the coefficients of this power series are the samples ek
at different sampling instants.
11
Discrete Transfer Function
• Discrete systems can be modeled with transfer functions, just
like linear continuous systems.
• Recall that for continuous systems, the transfer function G(s)
represents the Laplace transform of the output Y(s) over the
Laplace transform of the input U(s), and is a ratio of
polynomials b(s) and a(s).
Y ( s ) polynomial b(s)
G (s) 

U ( s ) polynomial a (s)
• The order of b(s) must not be greater than the order of a(s) or
the system will be non-causal.
• Similarly, a discrete transfer function is given by
Y ( z ) b( z )
G( z) 

U ( z ) a( z )
12
a ratio of polynomials in z
• Let’s apply the z-transform to the difference equation for trapezoidal
integration. We can do this by multiplying the difference equation by z−k and
summing from 0 to ∞.
uk  uk 1 

T
(ek  ek 1 )
2

T 
k
k
u
z

u
z

(
e
z

e
z
)




k
k 1
k
k 1
2
k 0
k 0
k 0


 




 k 0
k

k

U (z)
E(z)

u
k 0
k 1
z
k

  ul z
l  1
l 1
z
1

u z
l  1
l
l



z
1

u z
l 0
l
l
 z 1U ( z )
u 1  0
 U ( z )  z 1U ( z ) 
U ( z ) T 1  z 1


E ( z ) 2 1  z 1
T
( E ( z )  z 1 E ( z ))
2
T z 1

 Transfer function
2 z 1
• Note that the transfer function can be expressed using either positive or
negative powers of variable z. Each form is preferable for certain uses, as we will
see later.
13
General form of Discrete Transfer Function
• In general, a discrete transfer function H(z) relating input E(z) and
output U(z) will be
U ( z ) b0 z n  b1 z n 1    bm z n  m
H ( z) 

E( z)
z n  a1 z n 1    an
b0  b1 z 1    bm z  m

1  a1 z 1    an z  n
• where the “1” in the denominator of the negative-power form of
H(z) is required.
• Given the transfer function H(z) and the z transform of the input
U(z), we can find the (z-transformed) output as
U ( z)  H ( z)E( z)
14
Poles and Zeros of Discrete Transfer Function
Since z is a complex variable (like s), so is H(z), and we can define
the poles and zeros of H(z) as
• poles: locations in z-plane where denominator polynomial a(z) = 0
• zeros: locations in z-plane where numerator polynomial b(z) = 0
To find poles and zeros it is easier to use the version of H(z) with
positive powers of z. The poles and zeros may be real or
complex. If complex, they occur in conjugate pairs.
15
The Unit Delay
U ( z ) b0  b1 z 1    bm z  m

E ( z ) 1  a1 z 1    an z  n
• If we let b1 = 1 and all other bn = 0; also let all an = 0, then the
transfer function degenerates to
U ( z)
 z 1  H ( z )
E( z)
• Doing the same thing to the general difference equation
uk  a1uk 1  a2uk  2    anuk  n  b0 ek  b1ek 1    bm ek  m
• yields
uk  ek 1
• which says the present value of the output equals the input delayed
by one sample, or the previous input. Thus a transfer function of z−1
is a delay of one sample period, or a unit delay. These may be placed
in series to effect a delay of multiple samples.
16
Block Diagrams of Discrete Systems
• All linear difference equations are composed of delays, multiplies, and adds,
and we can represent these operations in block diagrams. A block diagram
will often be helpful in system visualization.
• Example: Consider the difference equation for trapezoidal integration,
uk  uk 1 
T
(ek  ek 1 )
2
• This difference equation is represented by the block diagram shown.
17
Going from transfer function to difference equations
• Consider a transfer function
U ( z ) b0  b1 z 1    bm z  m b( z )
H ( z) 


1
n
E ( z ) 1  a1 z    an z
a( z )
• By cross multiplying, we get
(1  a1 z 1    an z  n )U ( z )  (b0  b1 z 1    bm z  m ) E ( z )
• And taking inverse z-transform, we obtain
• or
uk  a1uk 1    anuk  n  b0 ek  b1ek 1    bm ek  m
uk  a1uk 1    anuk  n  b0 ek  b1ek 1    bm ek  m
18
Relation of the Transfer Function to the Unit Pulse
Response
• Recall that in continuous systems the transfer function of a system is equal
to the Laplace transform of the system’s unit impulse response.
• A similar relationship holds for discrete systems. Consider a system with
transfer function
U ( z)
H ( z) 
E( z)
• Let the input ek be a unit discrete pulse δk, i.e.
ek  1, k  0
 0, k  0
• The z-transform of the unit pulse is given by

E ( z )   ek z  k e0 z 0  1
k 0
• Hence U(z) = H(z), and the discrete transfer function H(z) is the z-transform
of the system’s unit pulse response.
19
Example
• Let’s see if this works on the trapezoidal integrator. The
difference equation is
uk  uk 1 
T
(ek  ek 1 )
2
• and the response to a unit pulse is shown in the table.
• Now, we find the z-transform of the unit pulse response:
T 
T 
Tz T
k
U ( z )    Tz     Tz  k 

2 k 1
2 
k 0
 z  1 2
T
T
1
1 z 1
2z  z 1 T z 1

2( z  1)
2 z 1
• which agrees with the transfer function obtained in slide 13.
20
Dynamic Response of Discrete Systems
• In this section we will examine the dynamic response of discrete
systems and begin to associate z-plane pole and zero location with
corresponding response. Presumably you have some knowledge of
this correlation for continuous systems in the s-plane.
• As a designer, it is important to have a good “feel” for the correlation
between z-plane pole and zero location and system response.
• We have already seen the most basic correlation, that of stability. If
any pole of the discrete transfer function is outside the unit circle,
the system is unstable.
• Our approach here will be to take three basic discrete functions, unit
step, exponential, and damped sinusoid, and examine both their ztransform (pole locations) and their discrete-domain character.
21
Unit step
• The unit step function is given by e(k) = 1, k ≥ 0. Its z-transform
is thus given as

E( z)   z
k 0
k
1
z


.
1
1 z
z 1
• The unit step has a pole at z = 1 and a zero at z = 0. A sketch of
the pole and zero locations for the unit step and the
corresponding discrete behavior are shown.
22
Exponential
• The discrete exponential function is given by e(k) = rk , k
≥ 0. The z-transform of this function is

E( z)   r z
k
k 0
k

  (rz 1 ) k 
k 0
1
z

.
1
1  rz
zr
• which has a single real pole at z = r, plus a zero at z = 0.
23
Three examples of pole and zero locations for the exponential
function and the corresponding discrete behavior are shown.
24
Notes on exponential function
• There are a couple of observations about the behavior of the
exponential function.
• Since the exponential function is e(k) = rk , if |r| > 1 the
response will grow. This corresponds to a pole outside the unit
circle. If this were the pulse response of a discrete system the
system would be unstable.
• If −1 < r < 0, the pole is on the negative real axis (but within
the unit circle) the response will alternate signs. This form is
unique to discrete systems and has no counterpart in the
continuous domain.
25
Damped sinusoid
• The discrete damped sinusoid is given by e(k) = rkcos(kθ), k≥0. Using an
Euler expansion of the cosine, we obtain
jk
 jk

e

e
e(k )  r k 
2


.

• Since the z-transform is linear, we can treat each term separately, then
add the z-transform of both terms at the end.
k
r e
jk
k  jk
r e
z  transform

z  transform



1
z
r e z   (re z ) 


j 1
j
1

re
z
z

re
k 0
k 0
z

z  re  j
k
jk
k
j
1 k
26
• Adding both expressions yields
E3 ( z ) 
1
z
z
z ( z  r cos  )





2  z  re j z  re  j  z 2  (2r cos  ) z  r 2
• The poles of E(z) are complex conjugates:
z  re  j  r cos   jr sin 
• The zeros are real, at 0 and rcos θ and are in line with the
poles.
27
Example
Consider a discrete damped sinusoid with r = 0.7 and θ = 45° =
π/4, thus
 
k
k
ek  e(k )  r cos k  0.7 cos k 
 4
the behavior of this discrete function is shown in the table
below and the plot in the middle. The pole/zero locations for
this function are shown to the right.
28
• Note that although the samples of the previous figure (in the
middle) are connected with straight lines for viewing clarity, in
a discrete system nothing truly exists between the samples.
• As in continuous systems, higher-order discrete system
response is always a combination of first order (exponential)
and second order (damped sinusoidal) terms.
• The notion of dominant poles carries over to discrete systems
also, with relative proximity to the z = 1 point defining
dominance. If a system has a single real pole or a complex
pole pair much closer to the z = 1 point than other poles or
zeros, the dynamic response of the system will be dominated
by that pole or poles.
29
Relationship between z-plane poles and
transient response
We can make the following observations:
Rate of decay of exponential response is determined by the
radius r of the pole location.
• If r > 1 the sequence increases, larger r ⇒ faster growth.
• If r = 1 the sequence neither grows nor decays.
• If r < 1 the sequence decays, the closer r is to zero the faster
the decay (This is also true for the exponential envelope of
damped sinusoids)
30
The oscillation speed (number of samples/cycle) of
complex poles is determined by their angle θ.
• Given ek = cos kθ
• let N be the number of samples per oscillation period,
hence
cos k  cos[(k  N ) ]  cos(k  N )
• Since N is defined to be the period, we must have Nθ =
2π, hence the period N is given by
N
2
 rad

360
 deg
31
In the previous example, we had a damped sinusoidal
response. The period of this response is given by
N
360 360

 8 samples/cycle
 deg 45
Examination of the response shown below verifies this
period.
32
Effect of Zeros on Dynamic Response
• In continuous transfer functions, zeros represent derivatives of
the input which are transferred to the output, thus speeding
up response and increasing overshoot (or undershoot).
• The same is true of discrete transfer functions, with the effect
of a zero is greater when it is near z = 1, and its effect
decreasing as it is far from z = 1. Note that a zero at z = 0
represents a unit advance, just as a pole at z = 0 is a unit delay.
33
Correspondence between Discrete and
Continuous Signals
• It is time to make a connection between discrete and continuous
systems, and a link between the z domain and the s domain.
• Consider discrete variable y(k), where we now say that this y(k) was
obtained by sampling continuous signal y(t) at sample period T. We
shall use a damped sinusoid for this development.
• Consider the continuous signal
y (t )  e  at cos bt
• Which has Laplace transform
Y (s) 
• And poles at
s  a  jb
sa
( s  a) 2  b 2
34
• Now, sampling y(t) with sample period T, we will get the discrete signal
y(kT )  e akT cos bkT  r k cos k , where r  e aT ,  bT
• This has two complex conjugate z-plane poles at
z  re  j  e  aT e  jbT  e (  a  jb )T
• Comparing the s-plane and the z-plane poles, we can find that they are
related by
z  e sT
is a general relationship between poles of continuous signals and
• This
their discrete counterparts. This mapping between the s and the z plane
is very useful in controller design.
that this mapping is not applicable to the zeros in the s- and z• Note
planes.
35
Example
Let’s examine the mapping between some contours in the s
plane and z plane, with reference to the following figure.
• s-plane origin. This maps into the point z = esT = 1, on the unit
circle.
• s-plane real axis from 0 → −∞. Using z = esT this maps into the
z-plane real axis from +1 → 0.
36
• s-plane jω axis. This maps into z = ejωT , which is the unit circle
itself. Thus the stability boundary in the s-plane (jω axis) maps
into the stability boundary in the z-plane (unit circle).
• As a point moves up the s-plane jω axis from zero, the
corresponding z-plane point travels counter-clockwise around
the unit circle, starting at +1. When s = jπ/T then z = −1. As s
continues up the jω axis, the value of z continues moving on
the unit circle.
• Line of constant damping ratio in s plane. This is a radial line
in the s-plane, which maps into a logarithmic spiral in the z
plane.
37
Download