Dsp-Unit 6.2 Window Based Fir Filters
Dsp-Unit 6.2 Window Based Fir Filters
Dsp-Unit 6.2 Window Based Fir Filters
Contents
1. Introduction
2. Characteristics of FIR Digital Filters
1. Frequency Response
3.2:Windowing Method
3.3:Frequency sampling Method
(1)
H d (e j )e jn d (2)
n
h
[
n
]
z
(3)
d
Then
H ( z)
hd [n]
h[n]
0
N21
h[n]z
n N21
for
N 1
2
otherwise
N 1
2
N21
(4)
N21
N 1
2
N21
1
2
the equ.7 with z
Where (N-1)/2 is delay in samples.
N21
H ( z) z
N21
N 1
h[0] h[n] z z
n 1
(8)
0
w[n] w[n]
0
for
for
N 1
n
2
N 1
n
for
for
h[n]
hd [n]w[n]
N 1
n
2
N 1
n
1
H (e )
2
j
(e )W (e
j ( )
)d H d (e ) *W (e )
W(ej)
HBS (e j )
HBP (e j )
c2 c1
c1 c2
c2 c1
c1 c2
j n c
1 e
hd [n]
2 jn
H d (e ) e
j n
1
d
2
e j n d
c
1 e jnc e jnc
1 e jnc e jnc
2
jn
n
2j
sin( nc )
hd [n]
n
H d (e ) e
1 e j n
hd [n]
2 jn
j n
1
d
2
j n
jn
d e jn d
1 e jnc e jn e jn e jnc
jn
2
jn
c
e
jnc
jnc
jn
jn
1 e e
e
e
hd [n]
n
2j
2j
1
sin(n ) sin(nc )
hd [n]
n
c2 c1
c1 c2
H d (e ) e
1 e jn
hd [n]
2 jn
1
hd [n]
n
c 1
c 2
jn
1
d
2
jn c 2
c1
c2
jn
c 2
c 1
e jn d
jn
2
jn
c1
e
2j
2j
1
sin(nc 2 ) sin(nc1 )
hd [n]
n
j
(e )
c2 c1
c1 c2
H d (e ) e
jn
1
hd [n]
2
1
d
2
e jn
jn
c 2
c 2
e jn
jn
jn
c 1
c1
c1
c 1
e j n
jn
jn
d e jn d
c1
c 2
1
hd [n]
n
2j
2j
2j
1
sin(n sin(nc 2 ) sin(nc1 )
hd [n]
n
Type
Low
Pass
c
hd [0]
High
Pass
sin( n ) sin( nc )
hd [n]
n 0
for
sin( n )c
hd [n]
for
(n )
c
hd [ n] 1
hd [0] 1 c
for
sin( nc )
hd [n]
for n 0
n
N 1
2
for
sin( n ) sin( n )c
(n )
hd [n]
for
Band
Pass
sin( nc 2 ) sin(nc1 )
hd [n]
for
Band
Stop
n
n 0
for
(
n
hd [n]
n 0
c1
hd [0] 1 c 2
hd [n]
c 2 c1
hd [n]
for
c 2 c1
hd [n] 1
hd [n]
for
Rectangular Window
N 1
1 for n
wR [n]
2
0 otherwise
Rectangular Window
Spectrum of the rectangular window is given by
N21
N
WR (e j )
e
e
j N21
j N21
j N2
n N21
... e
1 e
1 e
j
j
2
1
e
e
sin 2
WR (e )
sin 2
j n
e
1 e
... e
... e
j ( N 1)
j N
j N2
j 2
j N21
jN
j
e
j
1
e
e
N 1
2
j N2
j 2
Rectangular Window
The freq res is real and its zero occur when N/2=kor
=2k/N
The response for between 2/N and -2/N is called the
MAIN LOBE and other lobes are known as SIDE LOBES.
The main lobe of the response is the portion that lies between
the first two zero crossings. The side lobes are defined as the
portion of the response for <-2/N or >2/N.
As the window is made longer the main lobe becomes narrower
and higher and side lobes becomes more concentrated around
=0.
The main lobe width for the rectangular window is equal to
4/N and the highest side lobe level is equal to approximately
22% main lobe amplitude or -13dB relative to the maximum
value at =0.
Frequency
response of LPF
using
Rectangular
Window for N=25
Log magnitude
response of LPF
using
Rectangular
Window for N=25
Rectangular Window
As the desired response Hd(ej) is of infinte Fourier
coefficients. To get a finite impulse response filter we multiply
hd[n] with a rectangular window .i.e. h[ n] hd [ n]wR [ n]
The frequency response of the truncated filter can be obtained
by periodic convolution.
1
j
H (e )
2
j
j ( )
j
j
H
(
e
)
W
(
e
)
d
H
(
e
)
*
W
(
e
)
R
d
R
d
Rectangular Window
The width of the transition region depends on the width of the
main lobe. As the filter length N increases , the main lobe
becomes narrower decreasing the width of transition region.
The convolution of the desired response and the window
responses side lobes gives rise to the ripples in both pass band
and stop band.
The amplitude of the ripples is determined by the amplitudes of
the side lobes and is un effected by the length of the window.
So, increase in length N will not reduce the ripples, but increase
its frequency.
J.W.Gibbs showed that a finite length low pass filter will posses
an 8.9% maximum ripple no matter how long the filter is made..
Rectangular Window
j
WR (e )
N21
j n
N 1
2
4
N
sin 2N
sin
2
Rectangular Window
N=50
Rectangular Window
This effect where maximum ripple occurs just before and after
the transition band is known as Gibbs phenomenon.
The Gibbs phenomenon can be reduced by using a less
abrupt truncation of filter coefficients.
This can be achieved by using a window function that tapers
smoothly towards zero at both ends.
One such type of window is Triangular or Bartlett window.
wT [n]
2n
for
N 1
0 otherwise
N 1
n
sin N 1
4
WT (e j )
sin
[1 ] cos
w [n]
2n
N 1
0 otherwise
for
N 1
n
W (e j )
N21
j n
2n
[
1
]
cos
e
N 1
n N21
j n
N 1
2
A B C
1
2
N21
N 1
2
j N2 1 n
1
2
N21
N 1
2
j N2 1 n
A e
e
j N21
j N21
N 1
2
1 e
1 e
j 2
jN
e
1 e
j
j
2
e
1 e
j N2
j 2
... e
j N21
j N2
jN
j
1
1 e
... e j ( N 1)
j N2
... e
sin 2N
A
sin 2
1
2
1
2
j N2 1 N21
... e
1 e
1 e
j N2 1 N
j N2 1
j 2 N 1
j 2 N 1
e
1
2 j j
e 2 N 1 e 2 N 1
N
j N2 1
N
N
sin
2
N 1
1
B 2
sin 2 N 1
Similarly
1 e
j N2 1
j 2N NN1
... e
j N2 1 N21
j N2 1 N
1 e
1 e
2
2
2
N
1
N
1
e
1 e
N
N
sin
2
N 1
1
2
sin 2 N 1
N
N
sin
2
N 1
1
C 2
sin 2 N 1
[1 ] cos
w [n]
0 otherwise
2n
N 1
for
N 1
n
sin 2
sin 2 N 1
sin 2 N 1
j
In w[n] substitution of
=0.5 results in Hanning window
=0.54 results in Hamming window
Hanning Window
wHn [n]
2n
N 1
0 otherwise
for
N 1
n
N
N
N
N
N
sin
sin
sin
j
2
N 1
2
N 1
2
WHn (e ) 0.5
0.25
0.25
sin 2
sin 2 N 1
sin 2 N 1
Hanning Window
Hanning Window
Hanning Window
Hanning Window
The main lobe width is twice that of the rectangular
window, which results in doubling of the transition
region of the filter.
The magnitude of the sidelobe level is -31dB,
Which is 18dB lower over that of rectangular
spectral window.
The peak side lobe ripple is -44dB relative to the
main lobe. At high frequencies the stop band
attenuation is even greater.
Hamming Window
wH [n]
0 otherwise
2n
N 1
for
N 1
n
N
N
N
N
N
sin
sin
sin
j
2
N 1
2
N 1
2
WH (e ) 0.54
0.23
0.23
sin 2
sin 2 N 1
sin 2 N 1
Hamming Window
Hamming Window
Hamming Window
Hamming Window
The peak sidelobe level is down at about 41dB from the
main lobe peak, an improvement of 10dB relative to the
Hanning window.
The main lobe width is twice that of the rectangular window,
which results in doubling of the transition region of the filter.
The first sidelobe peak is -53dB, an improvement of 9dB
with respect to Hanning window filter. However at high
frequencies the stop band attenuation is lower when
compared to that of Hanning window.
Because the Hamming window generates less oscillation in
the sidelobes than the Hanning window, for the same
mainlobe width, the Hamming window is generally preferred.
Blackman Window
wB [n]
2n
N 1
0.08 cos
4n
N 1
for
N 1
n
Blackman Window
Blackman Window
Blackman Window
Blackman Window
The additional cosine term compared with Hanning
and Hamming window reduce the sidelobes, but
increases the mainlobe width to 12/N.
The peak sidelobe level is down about 57dB from
mainlobe peak, an improvement of 16dB relative the
Hamming window.
The sidelobe attenuation of a lowpass filter using
Blackman window is -74dB.
Bartlett
Hanning
Hamming
Hamming
Blackman
Hanning
1 , 2 , p
Given specifications:
and
1. Compute
min(1 , 2 )
p s
H ( z) z
n 1
N21
N 1
2
h[0] 2 h[n] z z
n
Disadvantages
Exceeds the specs everywhere except at
the edges of the passband and stopband
1 and 2 cannot be independently
controlled. Have to design more
conservatively for the smaller of the two
Window
Type
Summary of Windows
Peak
Approximate
Peak
Equivalent
Sidelobe
Amplitude
Width of
Mainlobe
(relative)
(dB)
Approxima
tion Error
20 log
(dB)
Kaiser
Windows
Transition
Width of
Equivalent
Kaiser
Window
Rectangular
-13
4
N
-21
Bartlett
-25
8
N
-25
1.33
2.37
N
Hanning
-31
8
N
-44
3.86
5.01
N
Hamming
-41
-53
4.86
6.27
N
Blackman
-57
8
N
12
N
-74
7.04
9.19
N
1.81
N
Example.1
Design an ideal high
pass filter with a
frequency response
j 5
e
j
H d (e )
0
for 4
for 4
wHn [n]
2n
0
.
5
0
.
5
cos
N 1
0 otherwise
for
N 1
Example.1 Cont..d
With N=11
wHn [n]
for
0 otherwise
n 5
Example.1 Cont..d
The filter coefficient equation is
1
hd [n]
2
1
j
j n
H d (e ) e d 2
1 e j n
hd [n]
2 jn
j n
jn
1 e
2
jn 4
jn
j n
d e jn d
e
jn
jn 4
jn 4
jn
jn
e e
1 e e
hd [n]
n
2j
2j
1
sin(n ) sin(n 4 )
hd [n]
n
jn
jn 4
hd [0] 1
Example.1 Cont..d
The desired filter coefficients are
hd [0] 1
1 14 0.75
1
hd [1] hd [1] sin( ) sin( 4 ) 0.225
1
sin(2 ) sin( 24 ) 0.159
hd [2] hd [2]
2
1
hd [3] hd [3] sin(3 ) sin( 34 ) 0.075
3
1
sin(4 ) sin( 44 ) 0
hd [4] hd [4]
4
1
sin(5 ) sin( 54 ) 0.045
hd [5] hd [5]
5
Example.1 Cont..d
The filter coefficients using Hanning window are
Example.1 Cont..d
The transfer function of the filter is given by
5
H ( z ) 0.75 h[n] z n z n
n 1
Example.1 Cont..d
The causal filter coefficients using Hanning window are
h[5] 0.75
Example.1 Cont..d
b) Hamming window
for
n N21
Example.1 Cont..d
The filter coefficients using Hamming window are
h[ n] hd [n] wH [n]
Example.1 Cont..d
The transfer function of the filter is given by
5
H ( z ) 0.75 h[n] z n z n
n 1
Example.1 Cont..d
The causal filter coefficients using Hamming window are
h[5] 0.75
Kaiser Window
From comparison of window parameters, we can
find that a trade-off exists between the mainlobe
width and the sidelobe amplitude.
The mainlobe width is inversely proportional to N. An
increase in window length decreases the transition
band of the filter.
However, the minimum stopband attenuation is
independent of N and is a function of the selected
window.
Kaiser Window
Thus in order to achieve prescribed minimum stop Band
attenuation and pass band ripple, the designer must find a
window with an appropriate sidelobe level and then choose
N to achieve prescribed transition width.
In this process the designer may often have to settle for a
window with undesirable design specifications
To overcome this problem Kaiser has chosen a class of
windows based on the prolate spheroidal functions.
These functions have the property that they are limited as
much as possible in both time and frequency domains.
Kaiser Window
I 1 n 2
N 1
wk [n]
2 ,
I
(
)
0
0
otherwise
N 1
2
1 x
I 0 ( x)
k 0 k! 2
controls sidelobe level (Stopband
Attenuation)
The filter order N controls the Mainlobe width.
2.
s 20 log10
and p 20 log10 11
1
B
LPF
s
p
c
2 s p
3. Determine
HPF
BPF
BSF
B p s
c 12 s p
B min p1 s1 , s 2 p 2
c1 p1 B2 , c 2 p 2 B2
B min s1 p1 , p 2 s 2
c1 p1 B2 , c 2 p 2 B2
0.1102 ( s 8.7)
for s 50
0.9222
D s 7.95
14.36
for s 21
for s 21
I 1 n 2
wk [n]
I
(
)
0
n N21 ,
otherwise
N 1
2
H ( z) z
n 1
N21
N 1
2
h[0] 2 h[n] z z
n
S No
IIR filter
The impulse response
of this filter extends
over an infinite duration
A variety of frequency
selective filters can be
designed using closed
form design formulas.
IIR filter
These can be
designed using only
a hand calculator
and tables of Analog
filter design
parameters.
5 Greater flexibility to
control the shape of
their magnitude
response.
Less flexibility
specially for
obtaining nonstandard frequency
response.
S No
IIR filter
The poles are placed
anywhere inside the
unit circle, high
selectivity can be
achieved with loworder transfer function
7 Always stable.
S No