Transcript IIR Filters

IIR Filters
The general form for z-transform transfer functions
for a digital filter is
H (z) 
b0  b1 z
1
a 0  a1 z
1
   bm z
m
   an z
n
.
The inverse of this z-transform transfer function h[n]
is the impulse response for this digital filter.
As an example if
H (z) 
1
1 z
1
.
we have
b0  1, a 0  1, a1  1, b1  b2    0 , a 2  a 3    0 .
The inverse z-transform of this transfer function (the
impulse response) is
h[ n ]  (  1) u [ n ].
n
h[n]
n
1
2 3 4 5
This impulse response function goes on forever.
That is, the impulse response is infinite in duration.
Such filters are referred to as infinite impulse
response or IIR filters.
Another example would be
1
H (z)  1  z .
The corresponding impulse response is
h [ n ]   [ n ]   [ n  1].
h[n]
n
1
2 3 4 5
This impulse response is finite in duration. Such
filters are referred to as finite impulse response or
FIR filters.
Given a transfer function, how do we know whether
this transfer function corresponds to an impulse
response that is infinite or finite in duration?
In our previous two examples we had
H (z) 
1
1 z
1
1
.
H (z)  1  z .
(IIR)
(FIR)
In general, any filter whose transfer function has a
denominator (that does not factor-out) will have an
impulse response that is infinite in duration
corresponding to an IIR filter.
Any filter whose transfer function does not have a
denominator will have an impulse response that is
finite in duration corresponding to an FIR filter.
The distinction between IIR filter transfer functions
and FIR filter transfer functions becomes more clear
if we look at the corresponding difference
equations. In our examples the corresponding
difference equations are
y [ n ]   y [ n  1]  x [ n ].
(IIR)
y [ n ]  x[ n ]  x[ n  1].
(FIR)
The IIR filter difference equation is recursive in
nature: the current output depends upon the
previous output
y [ n ]   y [ n  1]  x [ n ].
Since the current output depends upon the previous
output and the previous output depends upon its
previous output, the output depends upon the
infinite past.
The FIR filter difference equation is depends only
upon the input
y [ n ]  x[ n ]  x[ n  1].
If the input is finite in duration (such as an impulse)
then the output is finite in duration. The output
depends upon the finite past.
The difference between IIR and FIR filters can also
be seen by looking at the transfer functions and
noting that the IIR transfer function can be expanded
using a geometric series that is infinite:
H (z) 
1
1 z
1
 1 z
1
z
2
z
3
.
The FIR filter is already in a finite series form.
1
H (z)  1  z .
Most analog filters have an impulse response which
is infinite in duration. IIR filters are generally
designed by emulating an analog prototype filter.
There are two methods for doing this analog filter
emulation:
(1) the matched z-transform or impulse invariant
transform
(2) the bilinear transformation.
In both cases, we are given an analog transfer
function H(s), and we transform this function into a
digital transfer function H(z).
The Matched z-Transform
In the matched z-transform digital filter design
method we try to “match” the impulse response of
the analog filter with that of the digital filter being
designed.
To match the impulse responses, we take the
inverse Laplace transform of the analog filter
H(s)h(t), then sample the impulse response
h(t)h[n], then take the z-transform of the sampled
impulse response to get the z-transform transfer
function h[n]H(z).
Analog Prototype
Digital Filter
H (s)
H (z)
L-1
Z
h (t )
sample
h[n ]
Once we have our z-transform transfer function H(z),
we apply the definition of the transfer function to
write our digital filter equations:
H (z) 
Y (z)
X (z)
.
Example: Use the matched filter design method to
design the digital equivalent of an integrator.
Solution: The analog transfer function is
H (s) 
1
.
s
The inverse Laplace transform is
h ( t )  u ( t ).
We then sample the impulse response to get h[n]:
h [ n ]  u [ n ].
Finally, we take the z-transform of the impulse
response to get the digital filter transfer function.
H (z) 
1
1 z
1
.
Finally, we apply the definition of the z-transform
transfer function to get the relationship between the
input of the digital filter x[n] and the output of the
digital filter y[n].
H (z) 
Y (z)
X (z)

1
1 z
1
.
1
Y ( z )[1  z ]  X ( z ).
y [ n ]  y [ n  1]  x [ n ].
y [ n ]  y [ n  1]  x[ n ].
Applying this formula to an arbitrary input x[n], we
have
n
x[n]
y[n]
0
x[0]
x[0]
1
x[1]
x[0]+x[1]
2
x[2]
x[0]+x[1]+x[2]
3
x[3]
x[0]+x[1]+x[2]+x[3]
We see that the output is the summation of the input.
Thus the digital filter accurately represents the
analog filter.
The digital filter does not always accurately
represent the analog filter as will be seen in the next
example.
Example: Use the matched filter design method to
design the following transfer function:
H (s) 
1
s
c
1
,
where c = s/4, and s is the sampling frequency.
Solution: First, we find the impulse response
h (t )   c e
  ct
.
Then we sample the impulse response:
h[ n ]   c e
  c nT
  ce
n / 2
.
Then we take the z-transform of the (discrete-time)
impulse response:
H (z) 
c
1 e
 / 2
z
1
.
We then find the frequency response of the filter
w
ejw
H(ejw)
|H(ejw)|
0
1
1
1.26
/2
j

-1
1 e
 / 2
1
1  je
 / 2
1
1 e
 / 2
0.98
0.83
Frequency Response
2
1.8
1.6
jw
|H(e )|
1.4
1.2
1
0.8
0.6
0.4
0.2
0
0
0.25
0.5
w, x 
0.75
1
As we can see, it is not much of a low-pass filter:
the frequency rolloff is not very great. The reason
for this small rolloff is aliasing error: the frequency
response of H(z) is composed of copies of the
frequency response of H(s) at 0, s, 2s, etc. The
copy at 2s overlaps the copy at 0.
Aliasing error is an inherent problem in matched filter
design. Unless the cutoff frequency is very low
compared to the sampling frequency, we will get
substantial error due to aliasing. This aliasing
problem is solved using the bilinear transformation.
The Bilinear Transformation
The bilinear transformation is a fairly direct method
of converting H(s) to H(z). Rather than map the
analog frequencies =0 to s/2 to the digital
frequencies w=0 to w= (as we had done with the
matched z-transform), we will map the analog
frequencies =0 to  to the digital frequencies w=0
to w=
Matched z-transform: =(0,s/2)  w=(0,)
Bilinear Transformation: =(0,)  w=(0,)
What kind of function maps =(0,)  w=(0,)?
How about this:
  tan
w
.
2
As we can see from the graph on the following slide,
this function does perform the necessary mapping.
Frequency Warping
20
15
 = tan (w /2)
10
5
0
-5
-10
-15
-20
-1
-0.5
0
w, x 
0.5
1
We know the relationship between  and w; what is
the relationship between s and z?
w
  tan
2

w
sin
2
cos

1
2 j
1
2
w
2
(e
(e
jw / 2
jw / 2
e
e
 jw / 2
 jw / 2
)
)

j 
1 1 e
 jw
j 1 e
 jw
1 e
 jw
1 e
 jw
.
Since s=j and z=ejw, we have
s
1 z
1
1 z
1
.
.
Because of the “warped” nature of our
transformation, it is necessary to “pre-warp” our
analog prototype critical frequencies so as to
coincide with the critical frequencies of the
corresponding digital filter.
  tan
'
c
w
2
 tan
 cT
2
.
Example: Use the bilinear transformation method to
find the digital equivalent to the following transfer
function:
H (s) 
1
1
s
c
,
where c = s/4, and s is the sampling frequency.
Solution: First, we must “pre-warp” the analog
frequency:
  tan
'
c
 cT
2
s
 tan
4
T
2
 tan

4
 1.
We then substitute our “pre-warped” frequency,
H (s) 
1
s 1
,
and apply the bilinear (sz) transformation:
H ( z)  H (s)
s
1 z
1
1 z
1

1
1 z
1
1 z
1
1

1 z
2
1
.
The frequency response of the filter is
w
ejw
0
1
H(ejw)
11
|H(ejw)|
1.000
2
/2
j
1 j
0.707
2

-1
11
2
0.000
Frequency Response
2
1.8
1.6
jw
|H(e )|
1.4
1.2
1
0.8
0.6
0.4
0.2
0
0
0.25
0.5
w, x 
0.75
1
As can be seen, the frequency response is much
improved. At w=0, the response is the same as the
analog filter at =0, and at w=, the frequency
response is the same as the analog filter at =.
Example: Repeat the previous example
H (s) 
1
1
s
c
,
where c = s/6.
Solution: Our “prewarping” is slightly different:
  tan
'
c
 cT
2
s
 tan
6
T
2
 tan

6

1
3
.
Substituting our “pre-warped” frequency, we have
H (s) 
1
3s  1
.
Applying the bilinear transformation, we have
H ( z)  H (s)

1 z
s
1 z
1
1 z
1
1

3
1 z
1
1 z
1
1
1
3  1  ( 3  1) z
1
.
The frequency plot is given on the following slide.
Frequency Response
2
1.8
1.6
jw
|H(e )|
1.4
1.2
1
0.8
0.6
0.4
0.2
0
0
0.25
0.5
w, x 
0.75
1
Example: find the digital equivalent of a secondorder Butterworth filter using the bilinear
transformation. Let c = s/4.
Solution: The second-order Butterworth filter has
the following form:
1
H (s) 
(
s
c
) 
2
2 ( s )  1
,
c
(Enter [b a] = butter(2,1,'s') in MATLAB.)
The prewarping is the same as in the first example:
  tan
'
c
 cT
s
 tan
T
4
2
2
H (s) 
1
 tan
4
So,
s 
2
2s  1

.
 1.
Applying the bilinear transformation we have
H ( z)  H (s)

s
1 z
1
1 z
1
1

1 z
1
1 z
1
)
2

2
1 z
1
1 z
1
1
1

(1  z )
1
(1  z ) 
2
1
2
1
1
2 (1  z )( 1  z )  (1  z )
2

1 2z
(2 
1
z
2 )  (2 
2
2)z
2
.
The frequency response is on the following slide.
Frequency Response
2
1.8
1.6
jw
|H(e )|
1.4
1.2
1
0.8
0.6
0.4
0.2
0
0
0.25
0.5
w, x 
0.75
1