Date post: | 10-Feb-2018 |
Category: |
Documents |
Upload: | divy-pratap |
View: | 245 times |
Download: | 1 times |
of 35
7/22/2019 IIR Digital Filter Structures Filter Design
1/35
1
Digital Signal Processing
IIR digital filter structuresFilter design
7/22/2019 IIR Digital Filter Structures Filter Design
2/35
2
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 forimplementation
Direct form IIR filter: Filter structures in which the multiplier coefficients areprecisely the coefficients of the transfer function
Consider, a 3rdorder IIR filter with transfer function
We can implement H(z) as a cascade
where
7/22/2019 IIR Digital Filter Structures Filter Design
3/35
3
Basic IIR Digital Filter Structure
The filter section H1(z) can be seen to be an FIR filter and can be realised:
Time domain representation of H2(z) is given by
7/22/2019 IIR Digital Filter Structures Filter Design
4/35
4
Direct Form IIR Digital Filter Structure
Cascade of the two structures leads to H(z) and is known asdirect form I
structure
It is noncanonic as it uses 6 delays to realise 3rdorder transfer function
Its transpose (direct form It)
7/22/2019 IIR Digital Filter Structures Filter Design
5/35
5
Direct Form IIR Digital Filter Structure
Various other noncanonic directform structures can be derived bysimple block diagrammanipulations
Observe in the direct formstructure (on the right), signalvariables in nodes 1 and 1 are thesame, so the two top delays canbe shared
Likewise, the middle and bottomtwo delays can be shared
We get direct form II and itstranspose (direct form IIt) isalso shown
Now, it is canonic
7/22/2019 IIR Digital Filter Structures Filter Design
6/35
6
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 digitalfilter can be realised as a cascade of low-order filter sections
)(
)(
)(
)(
)(
)(
)(
)()(
3
3
2
2
1
1
zD
zP
zD
zP
zD
zP
zD
zPzH
Consider, for example,H(z)=P(z)/D(z) expressed as
Examples of cascade realisationsobtained by different pole-zeropairings
Examples of cascade realisationsobtained by different ordering ofsections
7/22/2019 IIR Digital Filter Structures Filter Design
7/35
7
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
Due to finite wordlength effects, each such realisation behavesdifferently
Usually, the polynomials are factored into a product of 1storder and 2ndorder polynomials:
For a first order,
7/22/2019 IIR Digital Filter Structures Filter Design
8/35
8
Consider an example:
The direct form II and cascaderealisations are
Cascade form IIR Digital Filter Structure
How?
21
21
1
1
5.08.01
0455.08227.01
4.01
44.0)(
zz
zz
z
zzH
Hint: try to remember a general form for direct form II and then reuse it!
7/22/2019 IIR Digital Filter Structures Filter Design
9/35
9
Parallel Form IIR Digital Filter Structures
A partial-fraction expansion of the transfer function in z-1leads to the
parallel form Istructure
Assuming simple poles, the transfer function H(z) can be expressed as
In the above for a real pole,
A direct partial fraction expansion of the transfer function in z leads tothe parallel form IIstructure
In the above for a real pole,
Well see some examples.
7/22/2019 IIR Digital Filter Structures Filter Design
10/35
10
A partial fraction expansion of
in z-1yields
Parallel Form IIR Digital Filter Structures
1.04.01
6.0
)5831.04.0(1
25.0
)5831.04.0(1
25.0)( 111
zzjzjzH
)1)(1(
)1()1(
11 BA
AbBa
B
b
A
aUse
Parallel form I
7/22/2019 IIR Digital Filter Structures Filter Design
11/35
11
A partial fraction expansion of
in z yields
Parallel Form IIR Digital Filter Structures
1
1
1
1
1
1
)5831.04.0(1
)1458.01.0(
)5831.04.0(1
)1458.01.0(
4.01
24.0)(
zj
zj
zj
zj
z
zzH
)1)(1(
)1()1(
11 BA
AbBa
B
b
A
aUse
Parallel form II
7/22/2019 IIR Digital Filter Structures Filter Design
12/35
FIR filter design
We have briefly explored the design of FIR filters in Lecture 5
Well look at it again here using MATLAB
Well use the window method to design FIR filters
12
7/22/2019 IIR Digital Filter Structures Filter Design
13/35
13
Ideal filter and impulse response
An ideal LPF Its impulse
What is the problem we cant have infinite coefficient length
So, we need to truncate
13
Gain
freqwc
1LPF
Inverse DFT
Similar to
7/22/2019 IIR Digital Filter Structures Filter Design
14/35
1414
Let us use a rectangular window
We can see that the shape of the LPF has changed
This is know as Gibbs phenomenon oscillatory behaviour in the magnituderesponses caused by truncating the ideal impulse response function (i.e. the
rectangular window has an abrupt transition to zero)
Gibbs phenomenon can be reduced by
Using a window that tapers smoothly at each end
Providing a smooth transition from passband to stopband in the magnitudespecifications
14
Ideal filter and impulse response
DFT
7/22/2019 IIR Digital Filter Structures Filter Design
15/35
151515
Filter length
The filter length (i.e. order) affects the
magnitude response
Length increase, number of ripples in bothpassband and stopband increases but witha corresponding decrease in the ripplewidths
That is as N increase, it gets closer to theideal LPF
But height of largest ripples remain thesame independent of length
Similar oscillatory behaviour could beobserved in the magnitude responses ofthe truncated versions of other types ofideal filters
15
Infinite N
N=25
N=13
7/22/2019 IIR Digital Filter Structures Filter Design
16/35
1616
Common window functions
Some common window functions
Low pass filter frequency response
N=51 and2
cw
Magnitude response of windowfunctions with M=25
7/22/2019 IIR Digital Filter Structures Filter Design
17/35
171717
FIR filter design
Step 1 - Specify the ideal or required frequency response, HD(w)
Step 2 - Obtain impulse response, hD(n) of the desired filter by evaluating theinverse Fourier transform
Important note: well 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 ofthe actual FIR coefficients, h(n), by multiplying hD(n) with w(n)
h(n)=hD(n) w(n)
7/22/2019 IIR Digital Filter Structures Filter Design
18/35
FIR filter design (Steps 1 and 2)
18
We can makeuse of availablehD(n)
7/22/2019 IIR Digital Filter Structures Filter Design
19/35
19
FIR filter design (step 3) window?
First problem in step 3 - which window function?
The ratio of the main lobe/side lobe can be used
Example, the frequency response of Hamming and Blackman windows
Main lobe centred at =0
Other ripples are called side lobes
7/22/2019 IIR Digital Filter Structures Filter Design
20/35
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 thesidelobes should be small so to increase the stopband attenuation, weneed to decrease the sidelobe amplitude
Most of the time, these two requirements are contradictory
Example: LPF with length=51 and cut-off at /2
20
7/22/2019 IIR Digital Filter Structures Filter Design
21/35
21
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 widthincrease the filter length
But increased filter length means increased computational complexity
Eg: Frequency response of Hamming window with length 101 and 201are shown below
21
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-400
-200
0
200
Normalized Frequency (rad/sample)
Phase(degrees)
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-100
-50
0
50
Normalized Frequency (rad/sample)
Magnitude(dB)
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-400
-200
0
200
Normalized Frequency (rad/sample)
Phase(degrees)
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-100
-50
0
50
Normalized Frequency (rad/sample)
Magnitude(dB)
7/22/2019 IIR Digital Filter Structures Filter Design
22/35
FIR filter design (step 3) length?
Using the same window as in the previous slide
LPF with Hamming window, with normalised cut-off=0.3
22
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-4000
-3000
-2000
-1000
0
Normalized Frequency (rad/sample)
P
hase(degrees)
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-150
-100
-50
0
50
Normalized Frequency (rad/sample)
M
agnitude(dB)
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-6000
-4000
-2000
0
Normalized Frequency (rad/sample)
Ph
ase(degrees)
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-150
-100
-50
0
50
Normalized Frequency (rad/sample)
Magnitude(dB)
7/22/2019 IIR Digital Filter Structures Filter Design
23/35
23
To select the suitable order i.e. the length
The lowest order that can meet the requirements
There are several methods:
Kaiser, Bellanger, Hermann
Kaisers formula:
Actual location of transition band is immaterial
Bellangersformula:
Hermanns formula is more complex so we will not consider here (but generally itgives slightly more accurate value for the order)
23
FIR filter design (step 3) order selection
)(6.14
13log20 10
ps
sp
ffN
1)(3
10log2 10
ps
sp
ffN
2/)(6.14
13log20 10
ps
spN
7/22/2019 IIR Digital Filter Structures Filter Design
24/35
2424
Example Kaisers formula
Estimate the order of a linear-phase lowpass FIR filter with the following
specifications: passband edge Fp=1.8 kHz, stopband edge Fs=2 kHz,peak passband ripple p=0.1 dB, minimum stopband attenuation s=35dB and sampling rate FT=12 kHz.
Get the peak ripple values: p=0.0115, s=0.0178
Using the Kaisers formula:
which gives 98.27
Since N must be an integer, we round up the value to give N=99
As the order is odd, a Type 2 FIR filter can be designed. To design aType 1 FIR filter, N should be increased to 100
In Matlab, you can use kaiserord function but it only gives anapproximation
Normally, you should check to see if the filter specifications are met, ifnot change N
24
)12000/180012000/2000(6.14
13)0178.0(0115.0log20 10
N
7/22/2019 IIR Digital Filter Structures Filter Design
25/35
25
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
Using Kaisers formula:
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 sameeven 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 bandrequires a higher order and is more important for the order selection
)1000/50(6.14
13)001.0(0115.0log20 10 N)(6.14
13log20 10
ps
sp
ffN
7/22/2019 IIR Digital Filter Structures Filter Design
26/35
A common mistake
Example: Obtain the FIR coefficients for a highpass filter with
Fc=600 Hz with FT=2000 Hz
Assume we start with N=100
Use the known impulse response for HPF
Problem
The phase is completely non-linear
The magnitude response is not good
26
0 20 40 60 80 100 120-0.4
-0.3
-0.2
-0.1
0
0.1
0.2
0.3
0.4
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10
20
40
60
80
Normalized Frequency ( rad/sample)
Phase(degrees)
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-15
-10
-5
0
5
Normalized Frequency ( rad/sample)
Magnitude(dB)
7/22/2019 IIR Digital Filter Structures Filter Design
27/35
27
To obtain linear phase response
Coefficients must be symmetry/antisymmetry
So say, change N=201
Linear phase response achieved
But there are still ripples (Gibbs phenomenon)
A common mistake solution 1
0 50 100 150 200 250-0.4
-0.3
-0.2
-0.1
0
0.1
0.2
0.3
0.4
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-10000
-5000
0
5000
Normalized Frequency (rad/sample)
Phase(degrees)
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-150
-100
-50
0
50
Normalized Frequency (rad/sample)
Magnitude(dB)
7/22/2019 IIR Digital Filter Structures Filter Design
28/35
28
Let us use a window, say Hamming
Less ripple in the magnituderesponse (in the passband)
Why is the cut-off frequency in theplot at 0.6 rad/sample?
We used 0.3 to obtain the impulseresponse function, right?
A common mistake solution 2
0 50 100 150 200 2500
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
0 50 100 150 200 250-0.4
-0.3
-0.2
-0.1
0
0.1
0.2
0.3
0.4
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-10000
-5000
0
5000
Normalized Frequency (rad/sample)
Phase(degrees)
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-150
-100
-50
0
50
Normalized Frequency (rad/sample)
Magnitude(dB)
7/22/2019 IIR Digital Filter Structures Filter Design
29/35
Taking the example further
29
Let us actually use the filterafter designing it!
It could be improved using higher N and improved window such asKaiser window
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-100
-80
-60
-40
-20
0
20
Frequency
PowerSpectrumM
agnitude(d
B)
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-120
-100
-80
-60
-40
-20
0
20
Frequency
PowerSpectrumM
agnitude(dB)
7/22/2019 IIR Digital Filter Structures Filter Design
30/35
Using MATLAB fir1 function
30
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 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-100
-80
-60
-40
-20
0
20
Frequency
PowerSpectrumM
ag
nitude(dB)
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-120
-100
-80
-60
-40
-20
0
20
Frequency
PowerSpectrumM
ag
nitude(dB)
0 50 100 150 200 250-0.1
-0.08
-0.06
-0.04
-0.02
0
0.02
0.04
0.06
0.08
7/22/2019 IIR Digital Filter Structures Filter Design
31/35
Improved FIR filter design
31
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 asDolph-Chebyshev and Kaiser that provide control over by means of an additionalparameter characterising the window
The basis of FIR filter design is to obtain the set of minimal number of coefficients
for the required response
So, computer based optimisation methods have been invented
Parks-McClellan algorithm can be used to obtain the FIR coefficients (in MATLAB,we can design this filter using remez function)
Normally, improved design over the standard window based method
Known as computer based FIR filter design
The only other FIR design method is frequency sampling method
But knowledge of the window based method is sufficient for this course
Note: Kaiser order and Kaiser window are two different matters, though we normally use themtogether
7/22/2019 IIR Digital Filter Structures Filter Design
32/35
32
IIR filter design
32
The most common approach to IIR filter design:
Convert the digital filter specifications into an analogue prototypelow-pass filter specifications
Determine the analogue low-pass filter transfer function, Ha(s)
Transform Ha(s) in the desired digital transfer function G(z)
The most widely used transformation is the bilinear transformation that
maps the imaginary axis in the s-plane (j) onto the unit circle of the z-plane
So, relation between G(z) and Ha(s)
However, this design requires some knowledge of analogue low-passfilters and also s-plane and therefore, we will skip this method andstraightaway utilise IIR filter design using MATLAB
7/22/2019 IIR Digital Filter Structures Filter Design
33/35
3333
IIR filter design using MATLAB
33
We have done IIR filter design using MATLAB in Lecture 5
There are several classical IIR filters
Butterworth, Chebyshev Types I and II, Elliptic
MATLAB functions
butter Butterworth filter with flat passband (no ripples)
ellip Elliptic filter with ripples (but normally requiring lower order thanButterworth for same transition band)
cheby1 - Chebyshev filter controlling peak-to-peak ripple in the passband
cheby2 - Chebyshev filter controlling the amount of stopband ripple
First step is to estimate the order of the filter given the specifications usingfunctions: buttord, cheb1ord, cheb2ord, ellipord etc
Next, obtain the coefficients, BandAusing functions: buttord, besself, cheby1,cheby2, ellip, etc
Finally, do the filtering using filtfilt function
The frequency response of the filter can be obtained using function freqz(B,A)
7/22/2019 IIR Digital Filter Structures Filter Design
34/35
34
IIR filter design using MATLAB -example
Design an elliptic IIR low-pass filter with the specifications: Fp=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 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-400
-300
-200
-100
0
Normalized Frequency (rad/sample)
Phase(degrees
)
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-150
-100
-50
0
Normalized Frequency (rad/sample)
Magnitude(dB)
7/22/2019 IIR Digital Filter Structures Filter Design
35/35
3535
IIR filter design using MATLAB -example
To filter a signal, use filtfilt function
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-120
-100
-80
-60
-40
-20
0
20
Frequency
PowerSpectrumM
agnitude(dB)
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-120
-100
-80
-60
-40
-20
0
20
Frequency
PowerSpectrumM
agnitude(dB)