Design of Analog Filters
Design of Analog Filters
Windowing Functions
Mohammed Alamgir
November 21, 2013
Problem
A finite impulse response (FIR) low-pass filter needs to be designed with specifications
The sampling rate is given as s = 20, 000Hz. When designing the filter, Hanning, Hamming,
Blackman and Kaiser window should be used to contain the ripple due to Gibbs effect.
An ideal low-pass filter (Fig.1) has a frequency response with zero transition band. Such a filter
has sinc impulse response which extends to infinite. For practical purpose the impulse response
must be truncated. This however, when done leaves a ripple on the frequency response (Fig.2).
Truncating the impulse response is the same as multiplying it with a rectangular window.
To reduce the ripple in the frequency spectrum a different window is used where the truncation
happens in a tapered manner. Some of the commonly available windows reported in the literature
are Hann, Hamming, Blackman and Kaiser. Among these only Kaiser window allows a design for
given passband/stopband attenuation while the others are trial-and-go types. Since we have to
compare the relative performance of the windows a common filter length is required. We will also
have to decide on the common cut-off frequency, which is usually taken as
c =
a + p
= (3000 + 5000)/2 = 4000Hz.
2
(2)
Amplitude
Gain
0
0
Time
0
Frequency
Gain
Amplitude
Gibbs ripple
0
Time
0
Frequency
Figure 2: Truncated impulse response and corresponding effect on the frequency response of a
low-pass filter.
Filter Length
To determine the filter length, we will first design the Kaiser window. Below are the steps of
designing Kaiser window:
1. p =
100.05 1
100.05 +1
2. = min{p , a } = 0.0316.
3. A = 20log() = 20log(0.0316) 30dB.
4. This value of A matches the second condition and gives
= 0.5842 (30 21)0.4 + 0.07866 (30 21) = 2.1166.
5. For A = 30dB we find
D=
(30 7.95)
= 1.5355.
14.36
6. Finally we have
N
s D
20000 2 1.5355
+ 1 = 16.355.
+1=
Bt
(5000 3000) 2
for |n| N 21
otherwise
where = 0.5 for Hann and = 0.54 for Hamming window. Because of the symmetry, only
(N 1)/2 values are required to calculate to get a whole window.
Blackman window considers a sidelobe in addition to the main lobe of the sinc function. Namely,
Blackmann window is given by
4n
for |n| N 21
0.42 + 0.5 cos N2n
1 + 0.08 cos N 1
wB (nT ) =
0
otherwise.
Similar to this, but consider one more sidelobe is Blackmann-Hariss window, which is given as
4n
6n
for |n| N 21
0.3587 0.4882 cos N2n
1 + 0.1412 cos N 1 0.0116 cos N 1
wBH (nT ) =
0
otherwise.
3
Window functions
1
Hann
Hamming
Blackman
BlackHarris
Kaiser
0.9
0.8
0.7
Amplitude
0.6
0.5
0.4
0.3
0.2
0.1
0
8
0
Sample Number
Kaiser Window
Window Shapes
Each of the window functions discussed above has been implemented in Matlab. Whenever, there
is a singularity condition of the form 0/0 lHopitals rule has been applied to avoid infinite value.
The windows are shown in Fig.3.
0.4
0.4
0.35
0.35
0.3
0.3
0.25
0.2
Amplitude
Amplitude
0.25
0.15
0.1
0.05
0.05
6
0
2
Sample Number
0.15
0.1
0.05
0.1
8
0.2
0.05
8
0
2
Sample Number
Impulse Response
The impulse response of the filter without any window can be found from the sinc function
h(nT ) =
sin(c nT )
, where n = 1, , 8
n
with the zeroth value h(0) set to 2c /s = 0.4. Actual impulse response is found by folding this
values and forming a full 17 samples array. This is plotted in in Fig.4. Note that these values are
also the coefficients of the desired FIR filter.
The impulse response of the desired filter, when no windowing is used is given in Fig.4. To apply
a window, we multiply each sample with the corresponding sample of the window to get the target
filters coefficient.
g(nT ) = h(nT ) wH (nT )
For example, Fig.5 shows the application of Hann window. One should note the tapering on both
sides due to the windowing.
The real impact of windowing is more clear when the frequency spectrum of the overall filter
is plotted. This is done in Fig.7. Since the impulse response is symmetric, the filter has a linear
phase response across the entire passband as see in Fig.8.
Gain, 20log|H(j)| in dB
20
40
60
Rec
Hann
Hamming
Blackman
BlackHarris
Kaiser
80
100
120
140
1000
2000
3000
4000
5000
6000
Frequency in Hz
7000
8000
9000
10000
Remarks
Looking at the frequency response in Fig.7, we note only the Kaiser window meets the specified
30dB stopband attenuation. The other windows can be made to meet this, but with greater value
of N .
Blackmann and Blackmann-Harris has the best stopband attenuation but roll off is very sloppy.
To see the behaviour in passband we plot the frequency response in linear scale in Fig.8.
The Kaiser window allows slight ripple the passband but it has real sharp roll-off. On the
other extreme, Blackmann-Harris has a very sloppy roll-off, it even attenuates the passband. The
best, one could get is little or no ripple in the passband, a faster roll off and a stopband attenuation
that meets the specification. Considering these factors, Kaiser window is the best amongst all.
Gain, 20log|H(j)| in dB
1000
2000
3000
4000
5000
6000
Frequency in Hz
7000
8000
9000
10000
2000
3000
4000
5000
6000
Frequency in Hz
7000
8000
9000
10000
0
5
10
Llinear phase
15
20
1000
Figure 7: Frequency and Phase responses of the filter with Hann window.
1.2
0.8
0.6
0.4
0.2
1000
2000
3000
4000
5000
6000
Frequency in Hz
7000
8000
9000
10000