6
Design and Implementation
of IIR Filters
We have discussed the design and implementation of digital FIR filters in the previous
chapter. In this chapter, our attention will be focused on the design, realization, and
implementation of digital IIR filters. The design of IIR filters is to determine the
transfer function H(z) that satisfies the given specifications. We will discuss the basic
characteristics of digital IIR filters, and familiarize ourselves with the fundamental
techniques used for the design and implementation of these filters. IIR filters have the
best roll-off and lower sidelobes in the stopband for the smallest number of coefficients.
Digital IIR filters can be easily obtained by beginning with the design of an analog
filter, and then using mapping technique to transform it from the s-plane into the z-
plane. The Laplace transform will be introduced in Section 6.1 and the analog filter will
be discussed in Section 6.2. The impulse-invariant and bilinear-transform methods for
designing digital IIR filters will be introduced in Section 6.3, and realization of IIR
filters using direct, cascade, and parallel forms will be introduced in Section 6.4. The
filter design using MATLAB will be described in Section 6.5, and the implementation
considerations are given in Section 6.6. The software development and experiments
using the TMS320C55x will be given in Section 6.7.
6.1 Laplace Transform
As discussed in Chapter 4, the Laplace transform is the most powerful technique used to
describe, represent, and analyze analog signals and systems. In order to introduce
analog filters in the next section, a brief review of the Laplace transform is given in
this section.
6.1.1 Introduction to the Laplace Transform
Many practical aperiodic functions such as a unit step function u(t), a unit ramp tu(t),
or an impulse train
I
kÀI
dt À kT do not satisfy the integrable condition given in
Àst
e
ÀjVt
dt
I
0
xte
ÀsjVt
dt
I
0
xte
Àst
dt,
6:1:2
where
s s jV 6:1:3
is a complex variable. This is called the one-sided Laplace transform of x(t) and is
denoted by XsLTxt. Table 6.1 lists the Laplace transforms of some simple time
functions.
Example 6.1: Find the Laplace transform of signal
xta be
Àct
, t ! 0:
From Table 6.1, we have the transform pairs
a 6
a
Table 6.1 Basic Laplace transform pairs
xt, t ! 0 X(s)
dt 1
u(t)
1
s
c
c
s
ct
c
s
2
ct
nÀ1
cn À 1!
s
n
e
Àat
1
s a
sin V
0
t
V
0
s
2
V
e
Æ at
xt Xs
À
a
xat
1
a
X
s
a
Equation (6.1.2) clearly shows that the Laplace transform is actually the Fourier
transform of the function xte
Àst
, t > 0. From (6.1.3), we can think of a complex s-
plane with a real axis s and an imaginary axis jV. For values of s along the jV axis, i.e.,
s 0, we have
Xsj
sjV
I
0
xte
ÀjVt
dt, 6:1:5
which is the Fourier transform of the causal signal x(t). Given a function X(s), we can
is expressed as
Hs
b
0
b
1
s ÁÁÁb
LÀ1
s
LÀ1
a
0
a
1
s ÁÁÁa
M
s
M
Ns
Ds
: 6:1:9
The roots of N(s) are the zeros of the transfer function H(s), while the roots of D(s) are
the poles.
Example 6.2: The input signal xte
À2t
ut is applied to an LTI system, and the
output of the system is given as
yte
Àt
:
This transfer function can be written as
Hs
s
2
6s 7
s 1s 3
1
1
s 1
1
s 3
:
From Table 6.1, we have
htdte
Àt
e
À3t
ut:
244
DESIGN AND IMPLEMENTATION OF IIR FILTERS
The stability condition for a system can be represented in terms of its impulse
response h(t) or its transfer function H(s). A system is stable if
lim
t3I
ht0: 6:1:10
This condition is equivalent to requiring that all the poles of H(s) must be in the left-half
of the s-plane, i.e., s < 0.
Example 6.3: Consider the impulse response
T
t
I
nÀI
dt À nT6:1:12
represents a unit impulse train and is called a sampling function. Clearly, d
T
t is not
a signal that we could generate physically, but it is a useful mathematical abstrac-
tion when dealing with discrete-time signals. Assuming that xt0 for t < 0, we
have
LAPLACE TRANSFORM
245
xnTxt
I
nÀI
dt À nT
I
n0
xnTdt À nT: 6:1:13
To obtain the frequency characteristics of the sampled signal, take the Laplace
transform of x(nT ) given in (6.1.13). Integrating term-by-term and using the property
of the impulse function
I
ÀI
xtdt À tdt xt, we obtain
xnTz
Àn
, 6:1:16
where X(z) is the z-transform of the discrete-time signal x(nT). Thus the z-transform can
be viewed as the Laplace transform of the sampled function x(t) with the change of
variable z e
sT
.
As discussed in Chapter 4, the Fourier transform of a sequence x(nT) can be obtained
from the z-transform by replacing z with e
j!
. That is, by evaluating the z-transform on
the unit circle of jzj1. The whole procedure can be summarized in Figure 6.1.
6.1.3 Mapping Properties
The relationship z e
sT
defined in (6.1.15) represents the mapping of a region in the s-
plane to the z-plane since both s and z are complex variables. Since s s jV,wehave
z e
sT
e
sT
e
jVT
jzje
j!
, 6:1:17
Sampling
Laplace
transform
jzje
sT
6:1:18a
and the angle
! VT: 6:1:18b
When s 0, the amplitude given in (6.1.18a) is jzj1, and Equation (6.1.17) is
simplified to z e
jVT
. It is apparent that the portion of the jV-axis between
V Àp=T and V p=T in the s-plane is mapped onto the unit circle in the z-plane
from Àp to p as illustrated in Figure 6.2. As V increases from p=T to 3p=T in the
s-plane, another counterclockwise encirclement of the unit circle results in the z-plane.
Thus as V varies from 0 to I, there are an infinite number of encirclements of the unit
circle in the counterclockwise direction. Similarly, there are an infinite numbers of
encirclements of the unit circle in the clockwise direction as V varies from 0 to ÀI.
From (6.1.18a), jzj < 1 when s < 0. Thus each strip of width 2p=T in the left-half of
the s-plane is mapped onto the unit circle. This mapping occurs in the form of con-
centric circles in the z-plane as s varies from 0 to ÀI. Equation (6.1.18a) also implies
that jzj > 1ifs > 0. Thus each strip of width 2p=T in the right-half of the s-plane is
mapped outside of the unit circle. This mapping also occurs in concentric circles in the z-
plane as s varies from 0 to I.
In conclusion, the mapping from the s-plane to the z-plane is not one-to-one, since
there is more than one point in the s-plane that corresponds to a single point in the z-
plane. This issue will be discussed later when we design a digital filter from a given
analog filter.
6.2 Analog Filters
Analog filter design is a well-developed technique. Many of the techniques employed in
studying digital filters are analogous to those used in studying analog filters. The most
systematic approach to designing IIR filters is based on obtaining a suitable analog
filter function and then transforming it into the discrete-time domain. This is not
C
and V
out
IR:
From (6.2.1), the transfer function of the circuit is
HV
V
out
V
in
R
R
1
jVC
jVRC
1 jVRC
: 6:2:3
The magnitude response of circuit can be expressed as
jHVj
R
R
2
1
V
2
C
R
R 1=Cs
RCs
1 RCs
: 6:2:4
To design an analog filter, we can use computer programs to calculate the correct values
of the resistor and the capacitor for desired magnitude and phase responses. Unfortu-
nately, the characteristics of the components drift with temperature and time. It is
sometimes necessary to re-tune the circuit while it is being used.
6.2.2 Characteristics of Analog Filters
In this section, we briefly describe some important characteristics of commonly used
analog filters based on lowpass filters. We will discuss frequency transformations for
converting a lowpass filter to highpass, bandpass, and bandstop filters in the next
section. Approximations to the ideal lowpass prototype are obtained by first finding a
polynomial approximation to the desired squared magnitude jHVj
2
, and then con-
verting this polynomial into a rational function. An error criterion is selected to measure
how close the function obtained is to the desired function. These approximations to the
ideal prototype will be discussed briefly based on Butterworth filters, Chebyshev filters
type I and II, elliptic filters, and Bessel filters.
The lowpass Butterworth filter is an all-pole approximation to the ideal filter, which is
characterized by the squared magnitude response
jHVj
2
1
1
À
p
Ω
s
Ω
Figure 6.5 Magnitude response of Butterworth lowpass filter
cut-off frequency. The magnitude response of a typical Butterworth lowpass filter is
illustrated in Figure 6.5. This figure shows that the magnitude is monotonically decreas-
ing in both the passband and the stopband. The Butterworth filter has a completely flat
magnitude response over the passband and the stopband. It is often referred to as the
`maximally flat' filter. This flat passband is achieved at the expense of the transition
region from V
p
to V
s
, which has a very slow roll-off. The phase response is nonlinear
around the cut-off frequency.
From the monotonic nature of the magnitude response, it is clear that the specifica-
tions are satisfied if we choose
1 !jHV
p
j ! 1 À d
p
, jVj V
p
6:2:6a
in the passband, and
jHV
s
j d
s
cut-off frequency before it drops away and we have the opportunity to improve the roll-
off. Although the Butterworth filter is very easy to design, the rate at which its
magnitude decreases in the frequency range V ! V
p
is rather slow for a small L.
Therefore for a given transition band, the order of the Butterworth filter required is
often higher than that of other types of filters. In addition, for a large L, the overshoot
of the step response of a Butterworth filter is rather large.
To obtain the filter transfer function H(s), we use HsHÀsj
sjV
jHVj
2
.From
(6.2.5), the poles of the Butterworth filter are defined by
250
DESIGN AND IMPLEMENTATION OF IIR FILTERS
1 Às
2
L
0: 6:2:8
By solving this equation, we obtain the poles
s
k
e
j2kLÀ1p=2L
, k 0, 1, ...,2L À 1: 6:2:9
These poles are located uniformly on a unit circle in the s-plane at intervals of p=L
radians. The pole locations are symmetrical with respect to both the real and imaginary
axes. Since 2L À 1 cannot be an even number, it is clear that as there are no poles on the
The coefficients a
k
are real numbers because the poles s
k
are symmetrical with respect to
the imaginary axis. Table 6.2 lists the denominator of the Butterworth filter transfer
function H(s) in factored form for values of L ranging from L 1toL 4.
Example 6.5: Obtain the transfer function of a lowpass Butterworth filter for
L 3. From (6.2.9), the poles are located at
s
0
e
jp=3
, s
1
e
j2p=3
, s
2
e
jp
, s
3
e
j4p=3
, s
4
e
j5p=3
, and s
ANALOG FILTERS
251
Hs
1
s À s
1
s À s
2
s À s
3
1
s À e
j2p=3
s À e
jp
s À e
j4p=3
1
s 1s
2
s 1
:
Chebyshev filters permit a certain amount of ripples in the passband, but have a much
steeper roll-off near the cut-off frequency than what the Butterworth design can achieve.
The Chebyshev filter is called the equiripple filter because the ripples are always of equal
size throughout the passband. Even if we place very tight limits on the passband ripple,
jΩ
s
Figure 6.6 Poles of the Butterworth polynomial for L 3
(b)(a)
1 − d
p
|H(Ω)|
1
d
s
Ω
p
Ω
s
ΩΩ
1 − d
p
|H(Ω)|
1
d
s
Ω
p
Ω
s
Figure 6.7 Magnitude responses of Chebyshev lowpass filters: (a) type I, and (b) type II
252
DESIGN AND IMPLEMENTATION OF IIR FILTERS
1 − d
p
p
. Although the same procedure can be applied to designing highpass, band-
pass, or bandstop filters, it is much easier to obtain these filters from the desired lowpass
filter using frequency transformations. In addition, most classical filter design tables
only generate lowpass filters and must be converted using spectral transformation into
highpass, bandpass, or bandstop filters. Filter design packages such as MATLAB often
incorporate and perform the frequency transformations directly.
Butterworth highpass filter's transfer function H
hp
s can be obtained from the
corresponding lowpass filter's transfer function H(s) by using the relationship
H
hp
sHsj
s
1
s
H
1
s
: 6:2:12
For example, consider L 1. From Table 6.2, we have Hs1=s 1. From (6.2.12),
we obtain
ANALOG FILTERS
253
H
hp
s
1
2
m
=BW. That is,
H
bp
sHs
s
s
2
V
2
m
BW
,
6:2:14
where V
m
is the center frequency of the bandpass filter and BW is its bandwidth. As
illustrated in Figure 5.3 and defined in (5.1.10) and (5.1.11), the center frequency is
defined as
V
m
V
a
V
2
m
BW
BWs
s
2
BWs V
2
m
: 6:2:17
In general, H
bp
s has L zeros at the origin and L pole-pairs.
Bandstop filter transfer functions can be obtained from the corresponding highpass
filters by replacing s in the highpass filter transfer function with s
2
V
2
m
=BWs. That
is,
H
bs
sH
hp
s
filter by digitizing the impulse response of analog filter, but not its frequency (magni-
tude) response. Because of inherent aliasing, this method is inappropriate for highpass
or bandstop filters. The bilinear-transform method yields very efficient filters, and is
well suited for the design of frequency selective filters. Digital filters resulting from the
bilinear transform will preserve the magnitude response characteristics of the analog
filters, but not the time domain properties. In general, the impulse-invariant method is
good for simulating analog filters, but the bilinear-transform method is better for
designing frequency selective IIR filters.
6.3.1 Review of IIR Filters
As discussed in Chapters 3 and 4, an IIR filter can be specified by its impulse response
fhn, n 0, 1, ...,Ig, I/O difference equation, or transfer function. The general
form of the IIR filter transfer function is defined in (4.3.10) as
Hz
LÀ1
l0
b
l
z
Àl
1
M
m1
a
m
z
Àm
: 6:3:1
The design problem is to find the coefficients b
described by the linear difference equation given in (6.3.2).
By factoring the numerator and denominator polynomials of H(z) given in (6.3.1) and
assuming M L À 1, the transfer function can be expressed in (4.3.12) as
Hzb
0
M
m1
z À z
m
M
m1
z À p
m
, 6:3:4
where z
m
and p
m
are the mth zero and pole, respectively. For a system to be stable, it is
necessary that all its poles lie strictly inside the unit circle on the z-plane.
6.3.2 Impulse-Invariant Method
The design technique for an impulse-invariant digital filter is illustrated in Figure 6.9.
Assuming the impulse function dt is used as a signal source, the output of the analog
filter will be the impulse response h(t). Sampling this continuous-time impulse response
yields the sample values h(nT). In the second signal path, the impulse function dt is
sampled first to yield the discrete-time impulse sequence dn. Filtering this signal by
, 6:3:6
where s Às
i
is the pole of H(s), and c
i
is the residue of the pole at Às
i
. Note that we
have assumed there are no multiple poles. Taking the inverse Laplace transform of
(6.3.6) yields
ht
P
i1
c
i
e
Às
i
t
, t ! 0, 6:3:7
which is the impulse response of the analog filter H(s).
The impulse response samples are obtained by setting t equal to nT. From (6.3.5) and
(6.3.7), we have
hn
P
i1
c
i
P
i1
c
i
1 À e
Às
i
T
z
À1
: 6:3:9
The impulse response of H(z) is obtained by taking the inverse z-transform of (6.3.9).
Therefore the filter described in (6.3.9) has an impulse response equivalent to the
sampled impulse response of the analog filter H(s) defined in (6.3.6). Comparing
(6.3.6) with (6.3.9), the parameters of H(z) may be obtained directly from H(s) without
bothering to evaluate h(t)orh(n).
The magnitude response of the digital filter will be scaled by f
s
1=T due to the
sampling operation. Scaling the magnitude response of the digital filter to approximate
magnitude response of the analog filter requires the multiplication of H(z)byT.
The transfer function of the impulse-invariant digital filter given in (6.3.9) is modified
as
HzT
P
i1
c
i
À2t
:
Taking the z-transform and scaling by T yields
Hz
1:5T
1 À e
ÀT
z
À1
À
T
1 À e
À2T
z
À1
:
It is interesting to compare the frequency response of the two filters given in Example
6.6. For the analog filter, the frequency response is
HV
0:54 jV
1 jV2 jV
:
For the digital filter, we have
H!
1:5T
1 À e
ÀT
e
Àj!T
À
1 À1 À 2T
1: 6:3:13
Therefore by using a high sampling rate, the aliasing effect becomes negligible and the
DC gain is one as shown in (6.3.13).
258
DESIGN AND IMPLEMENTATION OF IIR FILTERS
While the impulse-invariant method is straightforward to use, it suffers from obtaining
a discrete-time system from a continuous-time system by the process of sampling. Recall
that sampling introduces aliasing, and that the frequency response corresponding to the
sequence h(nT) is obtained from (4.4.18) as
H!
1
T
I
kÀI
H V À
2pk
T
: 6:3:14
This is not a one-to-one transformation from the s-plane to the z-plane. Therefore
H!
1
T
HV is true only if HV0 for jVj!p=T. As shown in (6.3.14), H! is
the aliased version of HV. Hence the stopband characteristics are maintained ad-
equately if the aliased tails of HV are sufficiently small. The passband is also affected,
but this effect is usually less serious. Thus the resulting digital filter does not exactly
meet the original design specifications.
Digital filter
specifications
Digital filter
H(z)
Bilinear
transform
Bilinear
transform
w → Ω
w ← Ω
Analog filter
specifications
Analog filter
H(s)
Aanlog filter
design
Figure 6.10 Digital IIR filter design using the bilinear transform
The bilinear transform is a mapping or transformation that relates points on the s-
and z-planes. It is defined as
s
2
T
z À 1
z 1
2
T
1 À z
À1
V
2
T
tan
!
2
, 6:3:19
or equivalently,
! 2 tan
À1
VT
2
: 6:3:20
Thus the entire jV-axis is compressed into the interval Àp=T, p=T for ! in a one-to-
one manner. The range 0 3Iportion in the s-plane is mapped onto the 0 3 p portion
of the unit circle in the z-plane, while the 0 3ÀIportion in the s-plane is mapped onto
260
DESIGN AND IMPLEMENTATION OF IIR FILTERS
01
ΩT
2
p
p
w
−p
Figure 6.11 Plot of transformation given in (6.3.20)
the 0 3Àp portion of the unit circle in the z-plane. Each point in the s-plane is uniquely
mapped onto the z-plane. This fundamental relation enables us to locate a point V on
the same critical frequencies for the analog design and then apply the bilinear transform,
the digital filter frequencies would be in error because of the frequency wrapping given
in (6.3.20). Therefore we have to pre-wrap the critical frequencies of the analog filter.
DESIGN OF IIR FILTERS
261
There are three steps involved in the bilinear design procedure. These steps are
summarized as follows:
1. Pre-wrap the critical frequency !
c
of the digital filter using (6.3.19) to obtain the
corresponding analog filter's frequency V
c
.
2. Frequency scale of the designed analog filter H(s) with V
c
to obtain
^
Hs
^
Hsj
ss=V
c
H
s
V
c
, 6:3:22
2. where
^
!
c
2
2
T
tan
2000p
16 000
2
T
tan
p
8
0:8284
T
:
Step 2: We use frequency scaling to obtain
^
HsHsj
ss=0:8284=T
0:8284
sT 0:8284
:
or configurations. In this section, we will discuss direct-form I, direct-form II, cascade,
and parallel realizations. Many additional structures such as wave digital filters, ladder
structures, and lattice structures can be found in the reference book [7].
6.4.1 Direct Forms
Given an IIR filter described by (6.3.1), the direct-form I realization is defined by the
I/O Equation (6.3.2). It has L M coefficients and needs L M 1 memory locations
to store fxn À l, l 0, 1, ..., L À 1g and fyn À m, m 0, 1, ..., Mg. It also
requires L M multiplications and L M À 1 additions for implementation on
a DSP system. The detailed signal-flow diagram for L M 1 is illustrated in
Figure 4.6.
Example 6.8: Given a second-order IIR filter transfer function
Hz
b
0
b
1
z
À1
b
2
z
À2
1 a
1
z
À1
a
2
z
À2
0
b
1
z
À1
b
2
z
À2
and H
2
z1=1 a
1
z
À1
a
2
z
À2
. Since multiplica-
tion is commutative, we have
HzH
2
zH
1
z: 6:4:4
Therefore Figure 6.12 can be redrawn as Figure 6.13.
Note that in Figure 6.13, the intermediate signal w(n) is common to both signal
buffers of H
1
2
y(n)
x(n−1)
x(n−2)
y(n−1)
y(n−2)
Figure 6.12 Direct-form I realization of second-order IIR filter
x(n) y(n)
H
1
(z)H
2
(z)
z
−1
z
−1
z
−1
z
−1
b
0
b
1
b
2
− a
1
− a
numbers of delays, adders, and multipliers.
It is worthwhile verifying that the direct-form II realization does indeed implement
the second-order IIR filter. From Figure 6.14, we have
ynb
0
wnb
1
wn À 1b
2
wn À 2, 6:4:5
where
wnxnÀa
1
wn À 1Àa
2
wn À 2: 6:4:6
Taking the z-transform of both sides of these two equations and re-arranging terms, we
obtain
YzWz b
0
b
1
z
À1
b
2
z
À2
ÀÁ
6:4:7
a
2
z
À2
which is identical to (6.4.1). Thus the direct-form II realization described by (6.4.5) and
(6.4.6) is identical to the direct-form I realization described in (6.4.2).
Figure 6.14 can be expanded as Figure 6.15 to realize the general IIR filter defined in
(6.3.1) using the direct-form II structure. The block diagram realization of this system
assumes M L À 1. If M T L À 1, one must draw the maximum number of common
delays. Although direct-form II still satisfies the difference Equation (6.3.2), it does not
implement this difference equation directly. Similar to (6.4.5) and (6.4.6), it is a direct
implementation of a pair of I/O equations:
wnxnÀ
M
m1
a
m
wn À m6:4:9
REALIZATION OF IIR FILTERS
265