CE 40763Digital Signal Processing
Fall 1992
Design of digital FIR filtersusing the Windowing Technique
Hossein SametiDepartment of Computer Engineering
Sharif University of Technology
Design of Digital Filters
LTI Systemsh(n)
FIR IIR
With rational transfer function
)()()(
zQzPzH
No rational transfer function
)()()(
zQzPzH
Determine coefficients of h(n) [or P(z)
and Q(z)]
2Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology
Design Stages1. Specifications Application dependent 2. Design h(n) Determine coefficients of h(n)3. Realization Direct form I,II, cascade and parallel4. Implementation Programming in Matlab/C, DSP, ASIC,…
Design of FIR filters◦ Windowing
Design of digital filters
3Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology
IDTFT of ideal low-pass filter:
Motivation: impulse response of ideal-low-pass filter
c
cX01
)(
c
c
dedeXnx njnj
2
121 )()(
njeee
njnx
njnjnj
ccc
c
2][
21)(
n
nnx c
sin)(
4Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology
Motivation: impulse response of ideal low-pass filter
Multiply by a rectangular window
• It can be shown that if we have a linear-phase ideal filter and we multiply it by a symmetric window function, we end up with a linear-phase FIR filter.
5Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology
Incorporation of Generalized Linear Phase
Windows are designed with linear phase in mind◦ Symmetric around M/2
So their Fourier transform are of the form
Will keep symmetry properties of the desired impulse response
Assume symmetric desired response
With symmetric window
◦Periodic convolution of real functions
00
w M n n Mw n
else
/ 2 where is a real and evenj j j M je eW e W e e W e
/ 2j j j Md eH e H e e
12
jj je e eA e H e W e d
6Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology
The steps in the design of FIR filters using windows are as follows:1. Start with the desired frequency response results in the
sinc function in time domain 2. Compute3. Determine the appropriate window function w(n)4. Calculate
Design of FIR filters using windows
)(dH)()}({ nhHIDTFT dd
)()()( nwnhnh d
A finite-length window function
7Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology
Two properties should be considered: 1) The amplitude is unity in the pass band and
it is zero in the stop band: 2) The phase is linear:
Desired frequency response
)()()( jmd eHH
)(mH
)(H
8Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology
Example: Design of a high-pass FIR filter
• First, we have to decide on the type of the filter.
• Assume Type I filter (linear-phase) 2
1,,0
NoddN
jmd eHH )()(
c
9Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology
Example: Design of a high-pass FIR filter j
md eHH )()(
otherwise0
1)( cc
dH
otherwise0)( cc
j
deH
deeHIDTFTnh njjdd
c
c
21
)}({)(
))(sin()(
)1()(
nn
nh c
n
d IIR filter
c
otherwise0
1)( cc
mH
otherwise0
)( ccdH
10Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology
Example: Design of a high-pass FIR filter
n0 1 2 3 4
1.0
3.0
)()()( nwnhnh d
3.0
5.0
5 6
1.0
7N
• It is a high-pass FIR filter with 7 taps that approximates the high-pass IIR filter.
• How can we quickly check that the resulting FIR filter has the desired properties that we were looking for? (i.e., it is a high-pass linear-phase filter)?
11Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology
Reminder: DTFT Pairs
Hossein Sameti, ECE, UBC, Summer 2012 Originally Prepared by: Mehrdad Fatourechi, 12
Windowing in frequency domain)()()( nwnhnh d )(*)()( WHH d
• What condition should we impose on W(ω) so that H (ω) looks like Hd(ω) ?• Impulse function in the frequency domain, means an
infinitely-long constant in the time-domain
• Larger window means more computation
13Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology
Windowing in Frequency Domain Windowed frequency response
The windowed version is smeared version of desired response
If w[n]=1 for all n, then W(ej) is pulse train with 2 period
12
jj jdH e H e W e d
14Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology
15Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology
16Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology
17Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology
Rationale for the shape of the filter
(Oppenheim and Schaffer, 2009)
Ideal filter
RectangularWindow function
NM 1
18Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology
Filter Specifications
p 0Pass-band: sStop-band:
p 1Pass-band ripple:
Stop-band ripple: s 2
Transition width: ps
• What is the ideal situation?(Oppenheim and Schaffer, 2009)
19Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology
Filter Specifications
)(log20 H
20Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology
ObservationsWidth of transition is not sharp!
• Ripples in the passband / stopband are proportional to the peaks of side lobes of the window.
• The width of transition depends on the width of the main lobe of the window.
21Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology
Controlling the width of the main lobe
• Q: How can we control the transition width (size of the main lobe)?
• A1: using the size of the window Uncertainty principle
22Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology
Controlling the width of the main lobe
• Q: How can we control the size of transition width (size of the main lobe)?• A2: Shape of the window; in other words, windows
with a fixed size that have different shapes can have different main lobe width.• Rectangular window Smallest; and Blackman
largest main lobe width
23Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology
Controlling the peak of the side lobe
• Q: How can we control the peak of the side lobes so that we can get a good ripple behavior in the FIR filter?• A: using the shape of the window
24Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology
Controlling the peak of the side lobe
• Q: Can we control the peak of the side lobes by changing the size of the window?
• A: It can be shown that changes are not significant.
25Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology
Demonstration using Kaiser window
26Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology
Properties of Windows
Prefer windows that concentrate around DC in frequency◦ Less smearing, closer approximation
Prefer window that has minimal span in time ◦ Less coefficient in designed filter, computationally efficient
So we want concentration in time and in frequency◦ Contradictory requirements
Example: Rectangular window
1
0
/ 2
11
sin 1 / 2sin / 2
j MMj j n
jn
j M
eW e ee
Me
27Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology
Rectangular Window
Narrowest main lobe◦ 4/(M+1)◦ Sharpest transitions at
discontinuities in frequency
Large side lobes◦ -13 dB◦ Large oscillation around
discontinuities Simplest window possible
1 00
n Mw n
else
28Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology
Bartlett (Triangular) Window
Medium main lobe◦ 8/M
Side lobes◦ -25 dB
Hamming window performs better
Simple equation
2 / 0 / 2
2 2 / / 20
n M n Mw n n M M n M
else
29Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology
Hanning Window
Medium main lobe◦ 8/M
Side lobes◦ -31 dB
Hamming window performs better
Same complexity as Hamming
1 21 cos 02
0
n n Mw n M
else
30Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology
Hamming Window
Medium main lobe◦8/M
Good side lobes◦ -41 dB
Simpler than Blackman
20.54 0.46cos 0
0
n n Mw n M
else
31Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology
Blackman Window
Large main lobe◦ 12/M
Very good side lobes◦ -57 dB
Complex equation
20.42 0.5cos0
40.08cos
0
nM
n Mw n n
Melse
32Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology
Frequency response of some popular windows (M=50)
rectangular Bartlett
HanningHamming
Blackman
33Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology
Peak Approximation Error
34Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology
Approximation Error, defined in passband and stopband.
Peake Approximation Error is the maximum value of
Comparison of different windows
35Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology
Good design strategy
Shape of the window
Main lobe
Side lobe
width of the window
Main lobe
Good design strategy: 1) Use shape to control the behavior of the side lobe.
2) Use width to control the behavior of the main lobe.
36Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology
Kaiser window
Mn
otherwiseI
nInw
0
0)(
))]1(([)(
0
5.02
0
:0I Zeroth order modified Bessel function of the first kind
...)!3(2)!2(2)!1(2
1)( 26
6
24
4
22
2
0 xxxxI
:1M Number of taps M2
: Parameter to control the shape of the Kaiser window and thus the trade-off between the width of the main lobe and the peak of the side lobe.
37Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology
Demonstration of Kaiser window
M=20
38Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology
Demonstration of Kaiser window
6
39Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology
Comparison with popular windows
40Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology
1. Calculate the transition bandwidth2. Calculate
3. Choose
4. Choose
Design Guidelines using Kaiser window
ps 10log20A
285.2
82 AM
41Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology
Example: Design of LPF using Kaiser window 4.0pSpecs:
6.0s
01.0p
001.0s
42Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology
Example: Design of LPF using Kaiser window 4.0pSpecs:
6.0s
01.0p
001.0s001.0 60log20 10 A
563.5 2.0 37M Type II
filterUse Bessel equation to get w(n)
43Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology
Example: Design of LPF using Kaiser window
44Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology
Example: Design of LPF using Kaiser window
Q: Does it satisfy the specs?
45Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology
Windowing method is a fast and efficient solution to design FIR filters.
Using Kaiser windows, the window can be chosen automatically.
Summary
46Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology