of 38
7/30/2019 DSP Lecture 24
1/38
Lectures 23-24 EE-802 ADSP SEECS-NUST
EE 802-Advanced Digital SignalProcessing
Dr. Amir A. Khan
Office : A-218, SEECS
9085-2162; [email protected]
1
7/30/2019 DSP Lecture 24
2/38
Lectures 23-24 EE-802 ADSP SEECS-NUST
Lecture Outline
Filter Design (From Oppenheim)
2
7/30/2019 DSP Lecture 24
3/38
Lectures 23-24 EE-802 ADSP SEECS-NUST
Introduction
The term Filters originate from frequency-selective
filtering
modify certain frequencies relative to others
Analysis vs. Design
Analysis Pole-zero distribution System properties (Causality/Stability)
Frequency response
System structural realizations
Study system behavior
Design
Practical realization poses causality and stability constraints
coefficients ak have strict constraints
Additionally, a linear phase requirement forH(z) may be desirable
Find system coefficients, i.e. M;N;a1; ;aN; b0; ;bM,
s.t.
3
7/30/2019 DSP Lecture 24
4/38
Lectures 23-24 EE-802 ADSP SEECS-NUST
Filter Design Overview
Design of Discrete-Time IIR Filters FromContinuous-Time (Analog) Filters Impulse Invariance
Bilinear Transformation
Common Discrete-time filters Butterworth Chebyshev
Elliptic
Design of FIR Filters Windowing Method Frequency Sampling Method
Optimum Filter Design (Park-McClellan)
4
7/30/2019 DSP Lecture 24
5/38
Lectures 23-24 EE-802 ADSP SEECS-NUST
Typical low-pass specifications
Parameters
[0;wp] = pass-band
[ws;p] = stop-band
[wp;ws] = transition-band
dp1; dp2 = pass-band ripple; Often expressed in dB via 20log10(1+dp)
ds = stop-band ripple; Often expressed in dB via 20log10(ds)
5
7/30/2019 DSP Lecture 24
6/38
Lectures 23-24 EE-802 ADSP SEECS-NUST
FIR or IIR ?
The choice between IIR and FIR usually based on phase considerations
GLP (generalized linear phase) constraint
FIR with GLP
IIR with GLP
IIR filters cannot be stable, causal and GLP at same time
If GLP desired : choose FIR
If GLP not desired : IIR can be chosen
6
7/30/2019 DSP Lecture 24
7/38Lectures 23-24 EE-802 ADSP SEECS-NUST
IIR Filter Design
Based on established methods for analog filter design
Approach usually restricted to low pass and band pass filters
Basic filter type is low pass
High pass or band pass filters generally created using
frequency transformations
Design Steps
Choose prototype analog filter
Butterworth, Chebyshev, Elliptic
Choose analog to digital transformation method
Impulse Invariance, Bilinear Transformation Transform digital filter specs to equivalent analog filter specs
Design analog filter
Transform analog filter to digital filter
Perform Frequency transformation if necessary7
7/30/2019 DSP Lecture 24
8/38Lectures 23-24 EE-802 ADSP SEECS-NUST
IIR Filter Design Steps
1. Start with filter specifications in digital frequency2. Choose a design methodology (impulse invariance, bilinear
transformation)
3. Convert digital frequency specs. into analog frequency specs (i.e.
to depending on design method chosen
4. Select a prototype analog filter (Butterworth, Chebyshev, Elliptic)
5. Design the analog filter according to the analog frequency specs
involves selecting the filter cut-off frequencies and order6. Obtain the corresponding filter transfer function (H(s) Laplace Tr.)
7. Convert this analog filter (H(s)) to the digital filter (H(z))
according to the design methodology initially chosen8
7/30/2019 DSP Lecture 24
9/38Lectures 23-24 EE-802 ADSP SEECS-NUST
Impulse Invariance Roundup !
Based on choosing a discrete time impulse responseh[n] that is similar to
continuous-time impulse responseh(t) (Step 7)
Motivated by desire to maintain the shape of frequency response
Frequency axis mapping is linear
Major problem is aliasing
TWw
Wj
0
Im(z)
Re(z)
unit-circle
T
p
T
p
9
7/30/2019 DSP Lecture 24
10/38Lectures 23-24 EE-802 ADSP SEECS-NUST
Impulse Invariance Roundup !
Based on choosing a discrete time impulse responseh[n] that is similar to
continuous-time impulse responseh(t)
Motivated by desire to maintain the shape of frequency response
Frequency axis mapping is linear
Major problem is aliasingWj
0
Im(z)
Re(z)
unit-circle
T
p
T
p
TWw
10
7/30/2019 DSP Lecture 24
11/38Lectures 23-24 EE-802 ADSP SEECS-NUST
Impulse Invariance Roundup !
Based on choosing a discrete time impulse responseh[n] that is similar to
continuous-time impulse responseh(t)
Motivated by desire to maintain the shape of frequency response
Frequency axis mapping is linear
Major problem is aliasing
TWw
Wj
0
Im(z)
Re(z)
unit-circle
T
p
T
p
Many-one mapping = source of aliasing
11
7/30/2019 DSP Lecture 24
12/38Lectures 23-24 EE-802 ADSP SEECS-NUST
Bilinear Transformation (B.T.)
Algebraic transformation b/w variables sand z
One-one mapping between the s and z-planes
Given a C.T. prototype filterHc(s), the corresponding D.T. filterH(z) is
The parameter Td has no influence whatsoever in the filter design, it is
cancelled out as we start with digital specs. and return to digital filter while
passing by analog filter
1
1
2 1( )1
d
zs
T z
1
1
2 1( ) ( ( ))
1c
d
zH z H
T z
12
7/30/2019 DSP Lecture 24
13/38Lectures 23-24 EE-802 ADSP SEECS-NUST
Properties of Bilinear Transformation
1 ( / 2)1 ( / 2)
d
d
T szT s
Substitute s j W
1 2 2
1 2 2
d d
d d
T j Tz
T j T
W
W
/ /
/ /
W(1) If0, then |z|1 for any
similarly, if0, then |z|1 for all W
(2) If0, then1 2
1 2
d
d
j Tz
j T
W W
/
/1z
1 2
1 2
j d
d
j Te
j T
w W W
/
/
2 1
1
j
j
d
es
T e
w
w
)
) )
/2
/2
2 sin / 22 2tan / 2
2 cos / 2
j
j
d d
e j js j
T e T
w
w
w w
w
W
2tan( )
2dT
wW 2arctan( / 2)dTw W
Since 0
13
7/30/2019 DSP Lecture 24
14/38Lectures 23-24 EE-802 ADSP SEECS-NUST
Properties of Bilinear Transformation
2tan( )
2dT
wW
2arctan( / 2)dTw W
Whole of left-half s-plane mapped to inside the unit circle in z-plane
The whole of imaginary axis on s-plane mapped to unit circle, no aliasing problem
14
7/30/2019 DSP Lecture 24
15/38Lectures 23-24 EE-802 ADSP SEECS-NUST
Properties of Bilinear Transformation
2tan( )
2dT
wW
2arctan( / 2)dTw W
Bilinear transformation avoids problem of aliasing through complete mapping but
everything comes at a cost ? Whats the cost here?
Non-linear frequency mapping as opposed to impulse invariance where we had a
linear mapping
Non-linear compression of frequency axis has to be compensated in B.T.
This non-linear phenomenon is called Frequency Warping
15
7/30/2019 DSP Lecture 24
16/38Lectures 23-24 EE-802 ADSP SEECS-NUST
Frequency Warping Effect of Bilinear
Transformation
Note that thecritical frequencies
are pre-warped
16
7/30/2019 DSP Lecture 24
17/38Lectures 23-24 EE-802 ADSP SEECS-NUST
Phase Warping and Non-linearity of Phase
by B.T.
Dashed line is linear phase and
solid line is phase resulting from bilinear transformation
Effect more pronounced at higher frequencies 17
7/30/2019 DSP Lecture 24
18/38Lectures 23-24 EE-802 ADSP SEECS-NUST
18
7/30/2019 DSP Lecture 24
19/38Lectures 23-24 EE-802 ADSP SEECS-NUST
FIR Filter Design
Windowing Method Truncate (window) the ideal response to
make it FIR
19
FIR Filt D i R t l
7/30/2019 DSP Lecture 24
20/38Lectures 23-24 EE-802 ADSP SEECS-NUST
FIR Filter Design-RectangularWindowing Problems
Magnitude spectra of Rectangular windows of increasing lengths (samples)
Reduction in width of main lobe as M increases
Area under sidelobes remain the same (note Normalized Amplitude plotted here)20
FIR Filter Design Rectang lar
7/30/2019 DSP Lecture 24
21/38Lectures 23-24 EE-802 ADSP SEECS-NUST
FIR Filter Design-RectangularWindowing Problems
Gibbs phenomenon occurs whenever there is truncation
Increasing M does not yield significant result as oscillations
increase without reducing in amplitude
Transition region becomes smaller with increasing M
Ripples continue to exist especially at discontinuities
Problem is due to sharp discontinuity (in time domain) of rectangular
windows
Solution : Use windows with tapered ends in time domain instead of
sharp discontinuities
21
G tti A d Sh Di ti it f
7/30/2019 DSP Lecture 24
22/38Lectures 23-24 EE-802 ADSP SEECS-NUST
Getting Around Sharp Discontinuity of
Rectangular Windows
No abrupt discontinuity in time-domain response of windows translates to
low amplitude side lobes in frequency domain
Advantage is the reduced number of ripples
On the hindsight, tapered window results in a wider transition band
(frequency domain)
Wider transition band can always be compensated by using larger length
windows (higher order filter, remember filter order = Window length - 1)
22
7/30/2019 DSP Lecture 24
23/38Lectures 23-24 EE-802 ADSP SEECS-NUST
Properties of Commonly Used Windows
Rectangular
1, 0
0, otherwise
n Mnw
Bartlett (triangular)
2 / , 0 / 2, even
2 2 / , / 2
0, otherwise
n M n M M
n n M M n M w
)0.5 0.5cos 2 / 0
0, otherwise
n M n M n
pw
)0.54 0.46cos 2 / 0
0, otherwise
n M n M n
pw
) )0.42 0.5cos 2 / 0.08cos 4 / 0
0, otherwise
n M n M n M n
p pw
Hanning
Hamming
Blackman
23
7/30/2019 DSP Lecture 24
24/38Lectures 23-24 EE-802 ADSP SEECS-NUST
Properties of Commonly Used Windows
24
7/30/2019 DSP Lecture 24
25/38Lectures 23-24 EE-802 ADSP SEECS-NUST
Rectangular
Bartlett (triangular)
Hanning
Hamming
Blackman
25
7/30/2019 DSP Lecture 24
26/38Lectures 23-24 EE-802 ADSP SEECS-NUST
Properties of Commonly Used Windows
Highest amplitude
high oscillations at discontinuity
Smallest width
the sharpest transition
Wider transition region (wider main-lobe) compensated by much lower side-
lobes and thus less ripples 26
7/30/2019 DSP Lecture 24
27/38
Lectures 23-24 EE-802 ADSP SEECS-NUST
Example : Window Comparison
Rectangular window
Hanning Window
Less ripples in Hanning Window at the cost of larger transition band
Hanning Window
M= 40
Transition band reduced by increasing window length
27
7/30/2019 DSP Lecture 24
28/38
Lectures 23-24 EE-802 ADSP SEECS-NUST
Specifications of Window Design Method
Filter responseH(ej ) should not the shaded regions
28
7/30/2019 DSP Lecture 24
29/38
Lectures 23-24 EE-802 ADSP SEECS-NUST
Properties of Window Design Method (1)
Equal transition bandwidth on both sides of desired (ideal) cut-off
frequency29
7/30/2019 DSP Lecture 24
30/38
Lectures 23-24 EE-802 ADSP SEECS-NUST
Properties of Window Design Method (2)
Equal peak approximation error in passband and stopband
30
7/30/2019 DSP Lecture 24
31/38
Lectures 23-24 EE-802 ADSP SEECS-NUST
Properties of Window Design Method (3)
Main lobe of window is wider than the width of transition band
31
7/30/2019 DSP Lecture 24
32/38
Lectures 23-24 EE-802 ADSP SEECS-NUST
Properties of Window Design Method (4)
Peak approximation error depends on window shape and
independent of window size (filter order) 32
7/30/2019 DSP Lecture 24
33/38
Lectures 23-24 EE-802 ADSP SEECS-NUST
Design Example
33
7/30/2019 DSP Lecture 24
34/38
Lectures 23-24 EE-802 ADSP SEECS-NUST
Step 1-Design Example : Choice of Window
dB40)01.0log(20;01.02
d
Hanning, Hamming and Blackman all satisfy the criterion, we can
chose between Hanning and Hamming to have a smaller transition
band as compared to Blackman for same order
Suppose we choose the Hanning Window 34
7/30/2019 DSP Lecture 24
35/38
Lectures 23-24 EE-802 ADSP SEECS-NUST
Step 2-Design Example : Filter Order
dB40)01.0log(20;01.02
dSuppose we choose the Hanning Window
Width of main lobe = s p = 0.3 0.2 0.1
pw sw
35
Step 3 Design Example : Specify Ideal
7/30/2019 DSP Lecture 24
36/38
Lectures 23-24 EE-802 ADSP SEECS-NUST
Step 3-Design Example : Specify Ideal
Response Hd(w)
pw sw
Ideal Filter cut-off frequency
Ideal low-pass filter
36
Step 4 Design Example : Specify Ideal
7/30/2019 DSP Lecture 24
37/38
Lectures 23-24 EE-802 ADSP SEECS-NUST
Step 4-Design Example : Specify Ideal
Impulse Response hd [n]
Non-causal
Make it causal: Delay by M/2
) )
)40
405.0sin][
n
nnh
dp
p
Ideal Filter Coefficients
37
7/30/2019 DSP Lecture 24
38/38
Step 5-FIR filter coefficients
) ) )40
405.0sin][
n
nnhd
p
p
Ideal Filter Coefficients
)0.5 0.5cos 2 / 0
0, otherwise
n M n M n
pw
Hanning
][].[][ nwnhnh d
FIR Filter Coefficients
Find frequency response H(ejw) and verify if it meets specifications
Otherwise, repeat the process by changing either filter order,
window type, or by slightly moving the ideal filter band edge freq.
38