IIR Filter
IIR Filter
IIR Filter
where
h(k)= Impulse response of the filter which is theoretically infinite in duration,
ak and bk = The coefficients of the filter
x(n) = Input to the filter and
y(n) = Output to the filter
• IIR filter is a feedback system
• The transfer function
Basic features of IIR filters
Dept of BME, KUET Sub: BME 3111 3
• Zeros: Z1 Z2, ... are the zeros of H(z), that is those values of Z for which H(z) becomes zero.
• Poles: P1 P2, ... are the poles of H(z), that is values of z for which H(z) is infinite.
• A plot of the poles and zeros of the transfer function is known as the pole-zero
diagram and provides a very useful way of representing and analysing the filter
in the complex z-plane
Basic features of IIR filters
Dept of BME, KUET Sub: BME 3111 4
• IIR filter normally requires fewer coefficients than an FIR filter for the same set
of specifications, that is why IIR filters are used when sharp cutoff and high
throughput are the important requirements.
Design stages for digital IIR filters
Dept of BME, KUET Sub: BME 3111 5
• The design of IIR filters can be conveniently broken down into five main stages
1. Filter specification: Function of the filter (for example, lowpass) and the desired
performance.
2. Approximation or coefficient calculation: calculate the values of the coefficients, ak
and bk, in the transfer function, H(z), such that the specifications given in stage 1 are
satisfied.
3. Realization: Typical structures for IIR filters are parallel and cascade of second and/or
first-order filter sections
4. Analysis of finite word length effect
5. Implementation: It involves building the hardware and/or writing the software codes,
and carrying out the actual filtering operation
Design stages for digital IIR filters
Dept of BME, KUET Sub: BME 3111 6
Stage 1: performance specification
Dept of BME, KUET Sub: BME 3111 7
the design of digital IIR filters starts with an explicit specification of the
performance requirements.
• (i) signal characteristics (types of signal sources and sinks, I/O interface, data rates and
wordlengths, and frequencies of interest),
• (ii) the frequency response characteristics of the filter (the desired amplitude and/or
phase responses and their tolerances (if any), the speed of operation),
• (iii) the manner of implementation (for example, as a high level language routine in a
computer or as a DSP processor-based system, choice of signal processor, modes of
filtering (real-time or batch)), and
• (iv) other design constraints (such as costs and permissible signal degradation through
the filter).
In general, most of the above requirements are application dependent.
Stage 1: performance specification
Dept of BME, KUET Sub: BME 3111 8
• Tolerance scheme:
8.2
Stage 2: Calculation of IIR filter coefficients
Dept of BME, KUET Sub: BME 3111 9
• When a zero is placed at a given point on the z-plane, the frequency response
will be zero at the corresponding point.
• Thus, by strategically placing poles and zeros on the z-plane, we can obtain
simple lowpass, or other frequency selective, filters
• An important point to bear in mind is that for the coefficients of the filter to be
real, the poles and zeros must either be real (that is lie on the positive or
negative real axes) or occur in complex conjugate pairs
Example 8.1
Dept of BME, KUET Sub: BME 3111 12
Solution
• First, we must determine where to place the poles and zeros on the z-plane.
• Placing zeros
• Since complete signal rejection at dc i.e. 0 and 250 Hz; we need to place zeros at
corresponding points on the z-plane
• These are at angles of 0° and 360°x 250/500 = 180° on the unit circle
Example 8.1
Dept of BME, KUET Sub: BME 3111 13
• Placing poles
Angle
• To have the passband centred at 125 Hz requires us to place poles at ±360° x 125/500 =
±90°.
• To ensure that the coefficients are real, it is necessary to have a complex conjugate pole
pair
Location of pole in the unit circle
• The radius, r, of the poles is determined by the desired bandwidth
• An approximate relationship between r, for r > 0.9, and bandwidth, bw, is given by
8.4
• From the pole-zero diagram, the transfer function can be written down by
inspection
Example 8.1
Dept of BME, KUET Sub: BME 3111 15
• Comparing the transfer function, H(z) with the general IIR equation, we find
that the filter is a second-order section with the following coefficients.
Assignment
Dept of BME, KUET Sub: BME 3111 16
• In this method, starting with a suitable analogue transfer function, H(s), the
impulse response, h(t), is obtained using the Laplace transform.
• The h(t) so obtained is suitably sampled to produce h(nT), and
• The desired transfer function, H(z), is then obtained by z-transforming h(nT),
where T is the sampling interval.
Summery of impulse invariant method
Dept of BME, KUET Sub: BME 3111 18
Example 8.3: Digitize, using the impulse variant method, the simple analogue
filter with the transfer function given by
Solution: The impulse response, h(t), is given by the inverse Laplace transform:
Example 8.3
• The transfer function of H(z) is obtained by z-transforming h(nT):
• If the poles, P1 and P2, are complex conjugates, then C1 and C2 will also be
complex conjugates
Example 8.4
Dept of BME, KUET Sub: BME 3111 23
Solution:
• Before applying the impulse invariant method, we need to frequency scale the
normalized transfer function.
• This is achieved by replacing s by s/α, where α = 2π X 150 = 942.4778, to
ensure that the resulting filter has the desired response.
• Thus
• Since the poles are complex conjugates, we can use the transfer function in
Equation
H(z) Assignment: Step by step full
calculation o f the problem
• Here,
• The impulse invariant method may be used for very sharp cutoff lowpass filters
with little aliasing, provided that the sampling frequency is reasonably high,
but it is unsuitable for highpass or bandstop filters unless an anti-aliasing filter
is used.
Matched z-transform (MZT) method of coefficient
calculation Dept of BME, KUET Sub: BME 3111 30
• This method directly maps the poles and zeros of an analog filter directly into
poles and zeros of the z-plane. We start with the transfer function of the
analog filter in factored form:
σ𝑀
𝑚=1 𝑠 − 𝑧𝑚
𝐻 𝑠 = 𝑁
σ𝑛=1 𝑠 − 𝑝𝑛
• The transfer function of the equivalent digital filter is obtained by replacing
terms of the form (𝑠 − 𝑎) with (1 − 𝑧 −1 𝑒 𝑎𝑇 ). This is called a ’matched z’
transform and gives the same pole location as impulse invariance but different
zero location.
Matched z-transform (MZT) method of coefficient
calculation Dept of BME, KUET Sub: BME 3111 31
• In higher order IIR filters, the second order filter sction is the basic building
block, where M=N=2
𝑠 − 𝑧1 𝑠 − 𝑧2
𝐻 𝑠 =
𝑠 − 𝑝1 𝑠 − 𝑝2
• Applying MZT we obtain
𝑠 − 𝑧1 𝑠 − 𝑧2 1 − 𝑒 𝑧1 𝑇 + 𝑒 𝑧2 𝑇 𝑧 −1 + 𝑒 (𝑧1 +𝑧2)𝑇 𝑧 −2
→
𝑠 − 𝑝1 𝑠 − 𝑝2 1 − 𝑒 𝑝1 𝑇 + 𝑒 𝑝2𝑇 𝑧 −1 + 𝑒 (𝑝1 +𝑝2)𝑇 𝑧 −2
• If the poles are complex conjugate
1 − 2𝑒 𝑧𝑟 𝑇 cos(𝑧𝑖 𝑇) 𝑧 −1 + 𝑒 𝑧𝑟 𝑇 𝑧 −2 Where,
𝑧𝑟 , 𝑧𝑖 real and imaginary part of zeros
𝑝𝑟 , 𝑝𝑖 real and imaginary part of poles
1 − 2𝑒 𝑝𝑟 𝑇 cos(𝑝𝑖 𝑇) 𝑧 −1 + 𝑒 𝑝𝑟 𝑇 𝑧 −2
Matched z-transform (MZT) method of coefficient
calculation Dept of BME, KUET Sub: BME 3111 32
• For the problem, the real and imaginary parts of the poles are
Summary of Matched z-transform
Dept of BME, KUET Sub: BME 3111 36
(1) Determine a suitable analog transfer function, H(s), that meets the
specifications of the desired digital filter.
(2) Find the locations of the poles and zeros of H(s). This may require factorizing
the analog transfer function, H(s).
(3) Map the poles and zeros from the s-plane to the z-plane.
(4) Combine the z-plane equations as appropriate to obtain the transfer
function, H(z).
Bilinerar z-transfor (BZT) method of coefficient
calculation Dept of BME, KUET Sub: BME 3111 37
𝑧−1 2
𝑠= 𝑘 , 𝑘 = 1 𝑜𝑟 …….(1)
𝑧+1 𝑇
• In the figure the entire jω axis in the s-plane is mapped onto the unit circle, the
left-half s-plane is mapped inside the unit circle, and the right-half s-plane is
mapped outside the z-plane unit circle
• Unfortunately, direct replacement of s in H(s) as indicated in Equation (1) may
lead to a digital filter with an undesirable response
• by making the substitution 𝑧 = 𝑒 𝑗𝜔𝑇 and 𝑠 = 𝑗𝜔′, the analog frequency 𝜔′ and digital
frequency are related as
𝜔𝑇 2
𝜔′ = 𝑘 𝑡𝑎𝑛 , 𝑘 = 1 𝑜𝑟
2 𝑇
Bilinerar z-transfor (BZT) method of coefficient
calculation Dept of BME, KUET Sub: BME 3111 39
• The analogue frequency 𝜔' and the digital frequency, 𝜔, is almost linear for
small values of 𝜔, but becomes nonlinear for large values of 𝜔, leading to a
distortion (or warping) of the digital frequency response. This effect is normally
compensated for by prewarping the analogue filter before applying the bilinear
transformation.
• For a lowpass filter, the cutoff or bandedge frequency are prewar by using the
following equation
′
𝜔𝑝 𝑇 𝑤ℎ𝑒𝑟𝑒 𝑘 = 1 𝑜𝑟
2
𝜔𝑝 = 𝑘 𝑡𝑎𝑛 𝑇
2 𝜔𝑝 =specified cutoff frequency
𝜔𝑝′ =prewarped cutoff frequency
T= Sampling period
Summary of Bilinear z-transform (BZT) of coefficient
calculation Dept of BME, KUET Sub: BME 3111 40
• For standard, frequency selective IIR filters, the steps for using the BZT
1. Use the digital filter specifications to determine a suitable normalized transfer
function,𝐻(𝑠).
2. Determine the cutoff frequency, 𝜔𝑝 (or passband edge frequency 𝜔𝑝1 and 𝜔𝑝2 for
band pass ) of the digital filter
3. Obtain an equivalent analogue filter cutoff frequency ( 𝜔𝑝′ ) using the relation
(prewarped)
′
𝜔𝑝 𝑇
𝜔𝑝 = 𝑘 𝑡𝑎𝑛
2
′ 𝜔𝑝1 𝑇
′
𝜔𝑝2 𝑇
𝜔𝑝1 = 𝑘 𝑡𝑎𝑛 and 𝜔𝑝2 = 𝑘 𝑡𝑎𝑛
2 2
Summary of Bilinear z-transform (BZT) of coefficient
calculation Dept of BME, KUET Sub: BME 3111 41
4. Denormalize the analogue filter by frequency scaling H(s). This is achieved by replacing
s, depending upon filter type as
𝑠
𝑠= lowpas to lowpass 𝑠 2 +𝜔02
𝜔𝑝′ 𝑠= lowpas to band pass
𝑊𝑠
′
𝜔𝑝 𝑊𝑠
𝑠= lowpas to high pass 𝑠= lowpas to band stop
𝑠 𝑠 2 +𝜔02
5. Apply the bilinear transformation to obtain the desired digital filter transfe rfunction
𝐻(𝑧) by replacing s in the frequency scaled transfer function 𝐻 ′ (𝑧) as.
s = (𝑧 − 𝑙)/(𝑧 + 1)
An illustration of the BZT method
Dept of BME, KUET Sub: BME 3111 42
using BZT method obtain the transfer function, H(z), of the digital filter, assuming
a 3 dB cutoff frequency of 150 Hz and a sampling frequency of 1.28 kHz.
Dept of BME, KUET Sub: BME 3111 43
Assignment- Due date next class
Dept of BME, KUET Sub: BME 3111 44
• In real life, the analogue transfer function H(s) from which H(z) is obtained may
not be available and will have to be determined from the filter specifications.
• For standard frequency selective filtering tasks, H(s) can be derived from the
classic Butterworth, Chebyshev or elliptic filter’s transfer functions.
Use of BZT and Classical analog filters to design IIR filters
Dept of BME, KUET Sub: BME 3111 46
• Butterworth filter
• Characterized by the following magnitude squared frequency response
The transfer function of the analogue Butterworth filter, H(s), contains zero at infinity and poles which are uniformly
spaced on a circle of radius 1 in the s-plane at the following locations
Use of BZT and Classical analog filters to design IIR filters
Dept of BME, KUET Sub: BME 3111 47
• In cases where the prototype lowpass filter does not exist, the stages of BZT
method are
1. Prewarp the band edge or critical frequencies of digital filter
2. Find a suitable lowpass prototype analog filter based on the digital filter specification
and one of the classical filter charecteristics
3. Denormalize the prototype analog LP filter, 𝐻(𝑠) by frequency transformation and
scalling to obtain a new transfer function, 𝐻′(𝑠)
4. Apply the BZT to obtain the desired digital filter transfer function, 𝐻(𝑧)
Nyquist Effect
Dept of BME, KUET Sub: BME 3111 49
• The available frequency band for analog filter extends from zero to infinity,
where as for digital filter it is from zero to Nyquist frequency (i.e. half of
sampling frequency)
• The magnitude-frequency response of digital filter designed either of the three
methods may be significantly different from those of analog filter because the
entire analog frequency band (zero to infinity) is now compressed into a
narrow band (zero to Nyquist frequency) This differences represents a
distortion which is sometimes referred to as the Nyquist effect
Realization structures for IIR digital filters
Dept of BME, KUET Sub: BME 3111 50
• The basic elements of realization structures are multipliers, adders, and delay
elements
8.23
Realization structures for IIR digital filters
Dept of BME, KUET Sub: BME 3111 52
𝑤ℎ𝑒𝑟𝑒, 𝑀 ≥ 𝑁
• practical second-order building blocks used in realizing higher order IIR filters
are depicted in Figure.
Canonic section: This biquadratic section is characterized
by the following equations:
• Scaling is not mandatory for the direct form, because it has only one adder,
and may be preferred where scaling is not desired, for example high fidelity
digital audio. Under certain conditions the direct form is superior to the
canonic section, in terms of noise performance.
Cascade and parallel realization structures for higher IIR
filters Dept of BME, KUET Sub: BME 3111 55
• In the IIR filter, the output, 𝑦(𝑛), is computed for each input sample, 𝑥(𝑛)
Assuming cascade realization using the second-order direct form, the key
filtering equation is
• This equation clearly shows that to implement the filter we need the following
components
• Memory (for example ROM) for storing filter coefficients;
• Memory (for example RAM) for storing the present and past inputs and outputs
{𝑥(𝑛), 𝑥(𝑛 − 1), … } and {𝑦(𝑛), 𝑦(𝑛 − 1), … };
• Hardware or software multiplier( s);
• Adder or arithmetic logic unit.
Implementation of IIR Filter
Dept of BME, KUET Sub: BME 3111 57
• In modern real-time DSP, the filtering operations are efficiently performed with
a DSP processor such as the TMS320C25
• These processors have all the basic blocks on-board, including in-built hardware
multiplier(s).
• In some applications, standard 8-bit or 16-bit microprocessors such as the
Motorola 6800 or 68000 families offer attractive alternative implementations
• In batch or off-line processing a suitable high level language is used to
implement the filter. In this case, the filter is often implemented in a high level
language (for example C or FORTRAN) and runs in a general purpose computer
Computational requirements
Dept of BME, KUET Sub: BME 3111 58
• The choice between FIR and IIR filters depends largely on the relative
advantages of the two filter types.
1. FIR filters can have an exactly linear phase response. The implication of this is that no
phase distortion is introduced into the signal by the filter. This is an important
requirement in many applications, for example data transmission. biomedicine, digital
audio and image processing. The phase responses of IIR filters are nonlinear, especially
at the band edges.
2. FIR filters realized nonrecursively are always stable. The stability of IIR filters cannot
always be guaranteed
3. The effects of using a limited number of bits to implement filters such as roundoff
noise and coefficient quantization errors are much less severe in FIR than in IlR.
4. FIR requires more coefficients for sharp cutoff filters than IIR. Thus for a given
amplitude response specification, more processing time and storage will be required
for FIR implementation. However, one can readily take advantage of the computational
speed of the FFT and multirate techniques
Choosing Between FIR and IIR filters
Dept of BME, KUET Sub: BME 3111 60
5. Analog filters can be readily transformed into equivalent IIR digital filters meeting
similar specifications. This is not possible with FIR filters as they have no analog
counterpart. However, with FIR it is easier to synthesize filters of arbitrary frequency
responses
6. In general, FIR is algebraically more difficult to synthesize, if CAD support is not
available.
Summery- Choosing Between FIR and IIR filters
Dept of BME, KUET Sub: BME 3111 61
• From the above, a broad guideline on when to use FIR or IIR would be as
follows.
• Use IlR when the only important requirements are sharp cutoff filters and high
throughput, as IIR filters, especially those using elliptic characteristics, will give fewer
coefficients than FIR.
• Use FIR if the number of filter coefficients is not too large and, in particular, if little or no
phase distortion is desired. One might also add that newer DSP processors have
architectures that are tailored to FIR filtering, and indeed some are designed specifically
for FIRs