Professional Documents
Culture Documents
https://www.allaboutcircuits.com/technical-articles/design-examples-of-fir-filters-using-window-method/ 1/21
11/19/2017 Design Examples of FIR Filters Using the Window Method
Based on the previous articles in this series, especially the last one
(https://www.allaboutcircuits.com/technical-articles/filter-specs-window-
parameters-in-finite-impulse-response-filter-design/), we will discuss a step-by-
step design procedure.
Please note that, in this article, we will use "stop-band attenuation" and "the
minimum stop-band attenuation" interchangeably.
Example 1:
Design a low-pass filter with ωp = 0.4π and ωs = 0.6π which exhibits a
minimum attenuation greater than 50dB in the stop-band.
https://www.allaboutcircuits.com/technical-articles/design-examples-of-fir-filters-using-window-method/ 2/21
11/19/2017 Design Examples of FIR Filters Using the Window Method
Considering the fact that the stop-band attenuation of an ideal filter is infinite,
we find that the peak approximation error of the utilized window determines
the stop-band attenuation of the designed filter.
Since we need attenuation greater than 50dB in the stop-band, we may use
either the Hamming or the Blackman from Table I.
The Blackman window will lead to an overdesigned filter. This is due to the fact
that, for a given window length, M , the Blackman gives a wider main lobe
which is not desired. Hence, in this example, use of the Blackman will force us
to use a larger M compared to utilizing the Hamming window.
Among the five windows in Table I, Hamming is the appropriate window for this
example.
https://www.allaboutcircuits.com/technical-articles/design-examples-of-fir-filters-using-window-method/ 3/21
11/19/2017 Design Examples of FIR Filters Using the Window Method
In this example, the transition band is ωs − ωp = 0.2π . Since the main lobe
8π
width of the Hamming window is approximately , we find M = 40 . This
M
means that the designed filter will be of length 41.
So far we have determined the window type and its length. Using the equation
describing a Hamming window, we find the window as
2nπ
0.54 − 0.46cos( ) 0 ≤ n ≤ M
M
w[n] = { }
0 otherwise
Equation (1)
where M = 40 .
ωc ωc n
hd,lowpass [n] = sinc( )
π π
Equation (2)
https://www.allaboutcircuits.com/technical-articles/design-examples-of-fir-filters-using-window-method/ 4/21
11/19/2017 Design Examples of FIR Filters Using the Window Method
n
hd,lowpass [n] = 0.5sinc( )
2
M
4) Apply a time shift of and multiply hd,lowpass [n] by w[n]
2
2nπ n−20
h[n] = [0.54 − 0.46cos( )][0.5sinc( )] 0 ≤ n ≤ M
M 2
where h[n] denotes the impulse response of the designed FIR filter.
The frequency response of the designed low-pass filter is shown in Figure (1):
https://www.allaboutcircuits.com/technical-articles/design-examples-of-fir-filters-using-window-method/ 5/21
11/19/2017 Design Examples of FIR Filters Using the Window Method
As discussed in the previous article in this series, the window method leads to
the same ripple in the pass-band and stop-band. However, since Figure (1)
uses a logarithmic scale for |H (ω)|, the ripples in the stop-band seem to be
larger. This is due to the fact that variation of a logarithmic function is much
larger when its argument is close to zero.
https://www.allaboutcircuits.com/technical-articles/design-examples-of-fir-filters-using-window-method/ 6/21
11/19/2017 Design Examples of FIR Filters Using the Window Method
Figure (2) Zoomed-in version of the pass-band of the designed low-pass filter
Note that we always need software verification of any design, however, hand
calculations give us a better understanding of the problem and enable us to
have a rough approximation of the system. In this example, simple hand
calculations enable us to roughly approximate the value of M .
Example 2:
Design a high-pass filter with fs = 200H z and fp = 300H z which exhibits
attenuation greater than 40dB in the stop-band. We need the pass-band ripple
to be less than 0.2dB. Assume that the sampling frequency, fsamp , is 1200H z
.
https://www.allaboutcircuits.com/technical-articles/design-examples-of-fir-filters-using-window-method/ 7/21
11/19/2017 Design Examples of FIR Filters Using the Window Method
1) Window Type
Figure (3) shows the ripples in the pass-band and stop-band of a practical filter.
Figure (3) Pass-band and stop-band ripples of a practical filter. Image courtesy of the University of
Michigan (PDF) (https://web.eecs.umich.edu/~fessler/course/451/l/pdf/c8.pdf).
Although this figure shows a low-pass filter, the relations for the ripples are valid
for other filter types. Considering Figure (3), we can find the pass-band ripple
as 20log(1 + δ 1 ) − 20log(1) = 20log(1 + δ 1 ) . In this example,
20log(1 + δ 1 ) = 0.2dB , hence δ 1 = 0.023 .
https://www.allaboutcircuits.com/technical-articles/design-examples-of-fir-filters-using-window-method/ 8/21
11/19/2017 Design Examples of FIR Filters Using the Window Method
the pass-band and the stop-band. As a result, we need to choose the peak
approximation error as the minimum of δ 1 and δ 2 . Therefore, δ = 0.01 and the
peak approximation error is −40dB.
2) Window Length
We can find the approximate window length by equating the main lobe width
with the transition band of the desired filter. Note that since this example
discusses a high-pass filter, ωp is greater than ωs . Moreover, this example
gives the pass-band and stop-band frequencies in Hz.
To find the angular frequencies, we need to normalize fs and fp with half the
sampling frequency and multiply the result by π. Therefore,
fp
ωp = 2π = 0.5π and ωs = 0.33π .
fsamp
Equating the transition band, 0.17π, with the main lobe width of the Hann
window, we obtain M = 47 . An odd M will lead to a type II filter which is not
suitable for high-pass and band-stop filters. As a result, we need to increase the
filter length by one, i.e. M = 48 .
2nπ
0.5 − 0.5cos( ) 0 ≤ n ≤ M
M
w[n] = { }
0 otherwise
Equation (3)
where M = 48 .
https://www.allaboutcircuits.com/technical-articles/design-examples-of-fir-filters-using-window-method/ 9/21
11/19/2017 Design Examples of FIR Filters Using the Window Method
Using the impulse response of a low-pass filter given by Equation (2), we can
find the impulse response of a high-pass filter with cut-off of ωc as
ωc ωc n
hd,highpass [n] = sinc(n) − sinc( )
π π
Equation (4)
2nπ
h[n] = [0.5 − 0.5cos( )][sinc(n) − 0.415sinc(0.415n)] 0 ≤ n ≤ M
48
The frequency response of the designed high-pass filter is shown in Figure (4).
https://www.allaboutcircuits.com/technical-articles/design-examples-of-fir-filters-using-window-method/ 10/21
11/19/2017 Design Examples of FIR Filters Using the Window Method
As shown in Figure (4) and (5), fp and fs are slightly different from the design
specifications, however the differences are negligible. By tweaking M , fp or
fs , we can find filters that are closer to the design specifications.
https://www.allaboutcircuits.com/technical-articles/design-examples-of-fir-filters-using-window-method/ 11/21
11/19/2017 Design Examples of FIR Filters Using the Window Method
Figure (5) Zoomed-in version of the pass-band of the designed high-pass filter.
Example 3:
Design a band-pass filter with center frequency and two-sided pass-band of
fcenter = 500H z and 300H z, respectively. Both the low and high transition
bands of this filter are 100H z. The stop-band rejection needs to be greater
than 60dB and the pass-band ripple is expected to be less than 0.1dB.
Assume that the sampling frequency, fsamp , is 2000H z .
1) Window Type
Assume that, similar to the low-pass example in Figure (3), δ 1 and δ 2 denote
the deviation from ideal response in the pass-band and stop-band, respectively.
Therefore, 20log(1 + δ 1 ) = 0.1 and 20log(δ 2 ) = −60 . We need to choose
https://www.allaboutcircuits.com/technical-articles/design-examples-of-fir-filters-using-window-method/ 12/21
11/19/2017 Design Examples of FIR Filters Using the Window Method
the peak approximation error of the design based on the minimum of δ 1 and δ 2 .
Hence we obtain δ = min{δ 1 , δ 2 } = 0.001 . The Blackman is the only
window in Table I which can provide a peak approximation error smaller than
−60dB .
2) Window Length
Δf 100
The angular transition band is found as Δω = 2π = 2π = 0.1π .
fsamp 2000
Equating the transition band, 0.1π, with the main lobe width of the Blackman
window, we obtain M = 120 .
Using the equation describing the Blackman window, we find the window as
2nπ 4nπ
0.42 − 0.5cos( ) + 0.08cos( ) 0 ≤ n ≤ M
M M
w[n] = { }
0 otherwise
Equation (5)
where M = 120 .
Consider a band-pass filter with the low cut-off and high cut-off of ωc,l and ωc,u ,
respectively. The impulse response of this band-pass filter can be found by
subtracting the response of two low-pass filters with cut-off frequencies of ωc,u
and ωc,l . Utilizing Equation (2), we can arrive at the impulse response of the
assumed band-pass filter as
Equation (6)
https://www.allaboutcircuits.com/technical-articles/design-examples-of-fir-filters-using-window-method/ 13/21
11/19/2017 Design Examples of FIR Filters Using the Window Method
nπ nπ
h[n] = [0.42 − 0.5cos( ) + 0.08cos( )][0.7sinc(0.7(n − 60)) − 0.3sin
60 30
The frequency response of the designed band-pass filter is shown in Figure (6).
https://www.allaboutcircuits.com/technical-articles/design-examples-of-fir-filters-using-window-method/ 14/21
11/19/2017 Design Examples of FIR Filters Using the Window Method
Figure (7) Zoomed-in version of the pass-band of the designed band-pass filter
I hope you now have more practical knowledge of how to use the window
method to design FIR Filters.
https://www.allaboutcircuits.com/technical-articles/design-examples-of-fir-filters-using-window-method/ 15/21
11/19/2017 Design Examples of FIR Filters Using the Window Method
https://www.allaboutcircuits.com/technical-articles/design-examples-of-fir-filters-using-window-method/ 16/21
11/19/2017 Design Examples of FIR Filters Using the Window Method
https://www.allaboutcircuits.com/technical-articles/design-examples-of-fir-filters-using-window-method/ 17/21
11/19/2017 Design Examples of FIR Filters Using the Window Method
https://www.allaboutcircuits.com/technical-articles/design-examples-of-fir-filters-using-window-method/ 18/21
11/19/2017 Design Examples of FIR Filters Using the Window Method
https://www.allaboutcircuits.com/technical-articles/design-examples-of-fir-filters-using-window-method/ 19/21
11/19/2017 Design Examples of FIR Filters Using the Window Method
https://www.allaboutcircuits.com/technical-articles/design-examples-of-fir-filters-using-window-method/ 20/21
11/19/2017 Design Examples of FIR Filters Using the Window Method
https://www.allaboutcircuits.com/technical-articles/design-examples-of-fir-filters-using-window-method/ 21/21