Title: FIR%20Filter%20Design%20Using%20Windows
1FIR Filter Design Using Windows
2The FIR Filter Challenge
- We are given a filter specification
- Examples
p
p
0
0
low pass
high pass
3The FIR Filter Challenge
- We are given a filter specification
- Examples
p
p
0
0
band pass
band stop
Goal Find a filter which is a good
approximation of the specification
4Outline
- Goals
- Impulse Response truncation
- Using Windows
- Practical Filter Design
5Impulse Response Truncation -Reminder
Write the amplitude response
Choose filter type and order
Compute impulse response of ideal filter
Truncate the impulse response
6Example Band Pass Filter
- The desired impulse response
- An FIR filter of order N has the form
p
0
An approximation of Ad(q)
group delay -.5N
initial phase
7Choosing Filter Type and Order
IV III II I Type
Anti-symmetric Anti-symmetric symmetric symmetric Symmetry
Odd even odd even Order
.5p .5p 0 0 f
- Suppose we choose a type I filter
- The Ideal filter with phase is
8Computing the Impulse Response
- Recall that if
- The impulse response is
- Using linearity we get
9Truncating
- The impulse response of the filter is
- And we end up with an approximated filter
10Optimality
- The integral of the square error is
- Theorem
- For a given ideal frequency response and for a
- given order, the filter obtained by impulse
- response truncation has a minimum error
- among all causal FIR filters of the given order.
11The Gibbs Phenomenon
- Peaks near the transition band
- Both within and outside the pass band
- Peaks height 0.09, regardless of the filters
order - Become narrower as the order gets larger
N10
N40
N100
12Other Optimality Criteria -Reminder
1dp
Transition band
pass band ripple
ds
qs
qp
Pass band
Stop band
Given the filters order, our aim is to minimize
dp, ds and qs -qp
13A Deeper Look At Gibbs Phenomenon
- Rewriting the truncated impulse response
- where
- Therefore, by the modulation theorem
- If Wr was the delta function -gt an ideal filter
The DTFT of wr
14The DTFT of a Rectangular Window
- Suppose wr is a window with length N .
- The fourier transform of wr is
- The function
- Is called the Dirichlet kernel
15Properties of Dirichlet Kernel
D(0,N)N
Main lobe region between two zeros near the
origin
zeros at q2mp/N m is integer
Nearset zeros to the origin at q2p/N
Side lobes regions between adjacent zeros
16Understanding Gibbs
- Main lobe width determineDistance of peaks from
transition point - Side lobe level
- The ratio between main lobe and next lobes
height - Roughly Determines peak height
- 2/(3p), or about -13.5db in Dirichlet kernel
Can we do better?
17Outline
- Goals
- Impulse Response truncation
- Using Windows
- Practical Filter Design
18FIR filter Design Using Windows
- Define the ideal frequency response Hd (q)
- For each pair qp,qs take the midpoint
0.5(qpqs) - Obtain the ideal impulse response hd n as in
the IRT method - Compute coefficients
qs
qp
19Criteria for Choosing a Window
- Given the desired order of the FIR filter,
- we would like the kernel function to have
- A main lobe that is as narrow at possible
- Side lobes that are as low as possible
20Reducing Side Lobes by Squaring
- The side lobe level of Dirichlet kernel may be
reduced by squaring it - The corresponding window
- Window size is nearly doubled
- To maintain Filters order we need a smaller
window
21Bartlett Window
- Defined as a convolution of rectangular windows
- Size of rectangular window 0.5(N-1)
- Normalized
22Kernel of Bartlett Window
- For an odd N
- The kernel function becomes
Bartlett
Dirichlet
Side lobe level -27db
Side lobe level -13.5db
Main lobe width 4p/N
Main lobe width 8p/(N1)
23The Window Design Challenge
- Choosing a window always involves a trade-off
between - the width of the main lobe and the level of the
side lobes - The rectangular window
- Narrowest possible main lobe of all windows of
the same length - But its side lobes are the highest
- We are ready to increase the main-lobe width in
order to reduce the side lobe level - As a consequence we increase transition band
width in order to reduce the pass band ripple - Our aim choose a window with a good trade-off
24Window Representation - Rectangular
Time Domain Plot
Frequency Magnitude
FIR Filter Magnitude
1.09
-13.5db
Ripple 1
4p/L
Side lobe level
Transition band width (L is the length of the
window)
Amplitude response of an FIR filter based on the
window near a discontinuity point
25Window Representation - Bartlett
Time Domain Plot
Frequency Magnitude
FIR Filter Magnitude
.95
-27db
1 - Ripple
8p/L
Side lobe level
Transition band width (L is the length of the
window)
Amplitude response of an FIR filter based on the
window near a discontinuity point
26Hann Window (aka Hanning)
Time Domain Plot
Frequency Magnitude
FIR Filter Magnitude
1.0063
.95
-32db
8p/L
- Constructed by combining three Dirichlet
Kernels W(q)0.5D(q,N)0.25D(q-2p/(N-1),N)0
.25D(q2p/(N-1),N) - The resulting window sequence
27Hamming Window
Time Domain Plot
Frequency Magnitude
FIR Filter Magnitude
1.0022
.95
-43db
8p/L
- Constructed by combining three Dirichlet
Kernels W(q)0.54D(q,N)0.23D(q-2p/(N-1),N)
0.23D(q2p/(N-1),N) - The resulting window sequence
28Blackman Window
Time Domain Plot
Frequency Magnitude
FIR Filter Magnitude
1.0002
.95
-57db
12p/L
- Constructed by combining five Dirichlet
Kernels - lower lobes at the cost of larger main lobe
width
29Optimal Windows
- Previous windows were derived by intuition and
educated guess - Modern windows are based on optimality criteria
- Kaisers criterion
- Minimize the width of the main lobe kernel
- Constraints
- Window length should be fixed
- Energy in the side lobes level do not exceed a
percentage of total energy - Dolph criterion
- Similar to Kaisers, except
- Energy in side lobes do not exceed a given
maximum value
30Windows Comparison
Band pass ripple, dp Side lobe level, db Main lobe width Window
0.09 -13.5 4p/L Rectangular
0.05 -27 8p/L Bartlett
0.0065 -32 8p/L Hann
0.0022 -43 8p/L Hamming
0.0002 -57 12p/L Blackman
Depends on specific parameters Depends on specific parameters Depends on specific parameters Kaiser
Depends on specific parameters Depends on specific parameters Depends on specific parameters Dolph
31Summary of Design by Windows
- FIR design by impulse response truncation is
optimal on the average - However, it is not optimal given constrained
criteria - Windowing allows to tradeoff transition band
width and pass band ripple - Specific window should be chosen according to
desired constraints - Recall that this is not the optimal method
32Outline
- Goals
- Impulse Response truncation
- Using Windows
- Practical Filter Design
33Designing a Filter
- We can use the function fir1
- theta-pi2pi/1023pi
- tf fir1(40,0.5,'low',rectwin(41))
- plot(theta,fftshift(abs(fft(tf,1024))))
34Demonstrating Gibbs Phenomenon
- tf1 fir1(40,0.5,'low',rectwin(41))
- tf2 fir1(100,0.5,'low',rectwin(101))
- plot(x,fftshift(abs(fft(tf1,1024))),'b','LineWidth
',2) - hold on
- plot(x,fftshift(abs(fft(tf2,1024))),'g','LineWidth
',2)
35Using Windowing
- tf1 fir1(40,0.5,'low',hamming(41))
- plot(x,fftshift(abs(fft(tf1,1024))),'b','LineWidth
',2) - tf2 fir1(40,0.5,'low',blackman(41))
- hold on
- plot(x,fftshift(abs(fft(tf2,1024))),'k','LineWidth
',2)
36Using Least Square Design
- lsffirls(40,0 0.5 0.5001 1,1 1 0 0)
- plot(x,fftshift(abs(fft(lsf,1024))),'b','LineWidth
',2) - hold on
- lsf2firls(40,0 0.5 0.6 1,1 1 0 0)
- plot(x,fftshift(abs(fft(lsf2,1024))),'k','LineWidt
h',2)
37Usign Remez Exchange
- ReFremez(40,0 0.5 0.6 1,1 1 0 0)
- plot(x,fftshift(abs(fft(ReF,1024))),'k','LineWidth
',2)
38Applying a Filter
- tfh fir1(80,0.1,'low',hamming(81))
- outx filter (tfh,y)
- soundsc(y,fs)
- soundsc(outx,fs)
- freqz(y)
- freqz(outx)
39Beyond Low-pass
- lsffirls(500,0 0.4 0.4001 0.6 0.6001 0.7 0.7001
1, - 0 0 5 5 10 10 0 0)
- outx filter(lsf,1,y)
- plot(x,fftshift(abs(fft(lsf,1024))),'b','LineWidth
',2) - soundsc(outx,fs)
- plot(outx,fftshift(abs(fft(lsf,1024))),'b','LineWi
dth',2)
40fdatool
41fdatool
42(No Transcript)
43(No Transcript)
44(No Transcript)