Professional Documents
Culture Documents
IIR Digital Filter Structures Filter Design
IIR Digital Filter Structures Filter Design
1
Basic IIR Digital Filter Structure
An N-th order IIR digital transfer function is characterised by 2N+1 unique
coefficients, and in general, requires 2N+1 multipliers and 2N two input adders for
implementation
Direct form IIR filter: Filter structures in which the multiplier coefficients are
precisely the coefficients of the transfer function
where
2
Basic IIR Digital Filter Structure
The filter section H1(z) can be seen to be an FIR filter and can be realised:
3
Direct Form IIR Digital Filter Structure
Cascade of the two structures leads to H(z) and is known as direct form I
structure
4
Direct Form IIR Digital Filter Structure
Now, it is canonic
5
Cascade form IIR Digital Filter Structure
By expressing the numerator and the denominator polynomials of the
transfer function as a product of polynomials of lower degree, a digital
filter can be realised as a cascade of low-order filter sections
6
Cascade form IIR Digital Filter Structure
There are altogether a total of 36 different cascade realisations of H(z)
based on pole-zero pairings and orderings
Usually, the polynomials are factored into a product of 1 st order and 2nd
order polynomials:
7
Cascade form IIR Digital Filter Structure
Consider an example:
How?
Hint: try to remember a general form for direct form II and then reuse it!
8
Parallel Form IIR Digital Filter Structures
A partial-fraction expansion of the transfer function in z -1 leads to the
parallel form I structure
9
Parallel Form IIR Digital Filter Structures
A partial fraction expansion of
in z-1 yields
a b a (1 B ) b(1 A)
Use
1 A 1 B (1 A)(1 B )
Parallel form I
10
Parallel Form IIR Digital Filter Structures
A partial fraction expansion of
in z yields
a b a (1 B ) b(1 A)
Use
1 A 1 B (1 A)(1 B)
Parallel form II
11
FIR filter design
We have briefly explored the design of FIR filters in Lecture 5
We’ll look at it again here using MATLAB
We’ll use the window method to design FIR filters
12
Ideal filter and impulse response
An ideal LPF Its impulse
Gain
LPF
1
Inverse DFT
freq
wc
Similar to
13
Ideal filter and impulse response
Let us use a rectangular window
DFT
14
Filter length
15
Common window functions
Some common window functions
N=51 and wc
2
16
FIR filter design
Step 1 - Specify the ideal or required frequency response, H D(w)
Step 2 - Obtain impulse response, hD(n) of the desired filter by evaluating the
inverse Fourier transform
Important note: we’ll look at hD(n) for standard filter designs in the next slide
Step 3 - Select a window function and then the number of filter coefficients
Step 4 - Obtain values of w(n) for the chosen window function and the values of
the actual FIR coefficients, h(n), by multiplying hD(n) with w(n)
h(n)=hD(n) w(n)
17
FIR filter design (Steps 1 and 2)
We can make
use of available
hD(n)
18
FIR filter design (step 3) – window?
First problem in step 3 - which window function?
19
FIR filter design (step 3) – window?
To ensure a fast transition from passband to stopband, window should
have a very small main lobe width
To reduce the passband and stopband ripple , the area under the
sidelobes should be small so to increase the stopband attenuation, we
need to decrease the sidelobe amplitude
20
FIR filter design (step 3) – length?
Second problem in step 3 – number of filter coefficients?
To obtain good (i.e. sharper) transition band reduce main lobe width
increase the filter length
Eg: Frequency response of Hamming window with length 101 and 201
are shown below
50 50
Magnitude (dB)
Magnitude (dB)
0 0
-50 -50
-100 -100
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Normalized Frequency ( rad/sample) Normalized Frequency ( rad/sample)
200 200
Phase (degrees)
Phase (degrees)
0 0
-200 -200
-400 -400
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Normalized Frequency ( rad/sample) Normalized Frequency ( rad/sample)
21
21
FIR filter design (step 3) – length?
Using the same window as in the previous slide
Magnitude (dB)
0
-50 -50
-100 -100
-150 -150
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Normalized Frequency ( rad/sample) Normalized Frequency ( rad/sample)
0 0
Phase (degrees)
-1000
Phase (degrees) -2000
-2000
-3000 -4000
-4000
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 -6000
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Normalized Frequency ( rad/sample)
Normalized Frequency ( rad/sample)
22
FIR filter design (step 3) – order selection
To select the ‘suitable’ order i.e. the length
The lowest order that can meet the requirements
Kaiser’s formula:
N
20 log10 p s 13
N
20 log10 p s 13
14.6(s p ) / 2 14.6( f s f p )
Bellanger’s formula:
2 log10 10 p s
N 1
3( f s f p )
Hermann’s formula is more complex so we will not consider here (but generally it
gives slightly more accurate value for the order)
23
Example – Kaiser’s formula
N
20 log10 0.0115(0.0178) 13
14.6(2000 / 12000 1800 / 12000)
24
Another example
A requirement exists for an FIR digital filter to meet the following specifications:
Passband: 150-250 Hz
Transition width: 50 Hz
Passband ripple: 0.1 dB
Stopband attenuation: 60 dB
Sampling frequency: 1 kHz
Obtain the filter coefficients
Solution - The peak ripple values are p=0.0115, s=0.001
20 log10 0.0115(0.001) 13
N
20 log10 p s 13
Using Kaiser’s formula: N
14.6(50 / 1000) 14.6( f s f p )
which give N=49.85. So, we could take N=50 (type 1, odd length)
Note that the passband information is not used to obtain N, so it will be the same
even if we shift the passband or even if we use it for highpass, stopband etc
If the transition bands are not same then we use the smaller transition band
bigger transition band requires smaller N, so the smaller transition band
requires a higher order and is more important for the order selection
25
A common mistake
Example: Obtain the FIR coefficients for a highpass filter with
Fc=600 Hz with FT=2000 Hz 0.4
0.3
0.1
-0.1
-0.2
-0.3
-0.4
0 20 40 60 80 100 120
Magnitude (dB)
0
-5
-10
Problem -15
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
80
40
20
0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Normalized Frequency ( rad/sample)
26
A common mistake – solution 1
0.4
To obtain linear phase response 0.3
0.1
-0.1
-0.2
-0.3
-0.4
0 50 100 150 200 250
50
Magnitude (dB)
0
-50
-100
-150
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Normalized Frequency ( rad/sample)
Phase (degrees)
0
-5000
-10000
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Normalized Frequency ( rad/sample)
27
A common mistake – solution 2
0.9 0.3
0.8
0.2
0.7
0.1
0.6
0.5 0
0.4
-0.1
0.3
-0.2
0.2
0.1 -0.3
Magnitude (dB)
0
-50
-5000
-10000
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Normalized Frequency ( rad/sample)
28
Taking the example further
Let us actually use the filter after designing it!
20 20
0
0
Power Spectrum Magnitude (dB)
-40
-40
-60
-60
-80
-80
-100
-100
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 -120
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Frequency
Frequency
29
Using MATLAB fir1 function
Using MATLAB, filter coefficients can easily obtained using fir1 function!
Hamming window is used by default
For the same input x in the previous slide, let us design a bandpass filter
to extract only the component at 650 Hz 0.08
0.06
0.04
0.02
-0.02
-0.04
-0.06
-0.08
20 20 -0.1
0 50 100 150 200 250
0
0
Power Spectrum Magnitude (dB)
-20
-20
-40
-40
-60
-60
-80
-80
-100
-100 -120
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Frequency Frequency
30
Improved FIR filter design
The windows such as Hanning, Hamming etc are known as fixed window designs as
the ripple values are fixed)
FIR filter design can also be improved using adjustable window functions such as
Dolph-Chebyshev and Kaiser that provide control over by means of an additional
parameter characterising the window
The basis of FIR filter design is to obtain the set of minimal number of coefficients
for the required response
Note: Kaiser order and Kaiser window are two different matters, though we normally use them
together
31
IIR filter design
The most common approach to IIR filter design:
Convert the digital filter specifications into an analogue prototype
low-pass filter specifications
Determine the analogue low-pass filter transfer function, Ha(s)
Transform Ha(s) in the desired digital transfer function G(z)
32
IIR filter design using MATLAB
We have done IIR filter design using MATLAB in Lecture 5
First step is to estimate the order of the filter given the specifications – using
functions: buttord, cheb1ord, cheb2ord, ellipord etc
Next, obtain the coefficients, B and A using functions: buttord, besself, cheby1,
cheby2, ellip, etc
The frequency response of the filter can be obtained using function freqz(B,A)
33
IIR filter design using MATLAB -example
Design an elliptic IIR low-pass filter with the specifications: F p=0.8 kHz,
Fs=1 kHz, FT=4 kHz, p=0.5 dB, s=40 dB
MATLAB code:
[N,Wn]=ellipord(0.4,0.5,0.5,40)
[B,A]=ellip(N,0.5,40,Wn)
0
Magnitude (dB)
-50
-100
-150
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Normalized Frequency ( rad/sample)
0
Phase (degrees)
-100
-200
-300
-400
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Normalized Frequency ( rad/sample)
34
IIR filter design using MATLAB -example
To filter a signal, use filtfilt function
20 20
0 0
-20 -20
-40 -40
-60 -60
-80 -80
-100 -100
-120 -120
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Frequency Frequency
35