Design of Finite Impulse Response (FIR) filters using Window Methods
B. N. JAGADALE Department of Electronics,
Kuvempu University, Shankaragatta-577451, INDIA.
(Received on: October 29, 2012) ABSTRACT
FIR filters are known for linear phase as compare to IIR filters.
The design procedure is simple and uses window techniques, which truncates the frequency response of the filter and hence the name finite impulse response. In this paper we have tried to study the frequency responses using various window methods.
Keywords: IIR filters, frequency response, window techniques.
INTRODUCTION
A linear time invariant system can be characterized by its impulse response. A system called finite impulse response means its output gradually decays to zero in a finite duration as long as its input duration is finite. The basic FIR filters are characterized by following two equations.
(1)
Equation (1) is the FIR difference equation. It is a time domain equation and describes the FIR filter in its non-recursive form: y ( ) n is the current output sample that is the function of present and past values of
input x ( ) n . N is the filter length that is the number of filter coefficients. An alternative expression for FIR in z-domain is given in equation (2).
( )
1( ) ( 2 )
0 k N
k
z k h z
H
−−
=
= ∑
where, h ( ) k , k = 0 , 1 ... ... N − 1 , are
impulse response coefficients of the filter and H ( ) Z is the transfer function of the filter. Since, only finite number of terms of finite magnitude is involved, there is no possibility of output becoming infinite or unstable and hence FIR filters are always stable. Due to the absence of denominator polynomial, its output depends only on the ( )
n h( ) (
k x n k)
y N
k∑ −
= −
=1 .
0
present and previous inputs. The FIR filters at any sample instant of time, computes the sum of weighted input samples in the neighborhood or the weighted average of the data which is changing from instant to instant, therefore this filter is also called as a moving average filter.
In IIR filter output depends not only on the present and previous input but also on previous outputs. This dependency on the previous outputs
y( )
n−k,k=1,2,3......pmay lead to the filter becoming unstable. IIR filters are characterized by the following two equations.
( ) ( ) ( )
( ) ( )
+ ∑
∑
=
=
=
−
−
−
= p k
k Q k
Q k
z k a
z k b z
X z z Y
H
1
1
(3)
( )
= ∑( ) (
−)
− ∑( ) (
−)
=
−
=
p k Q
Q k
k n y k a k n x k b n
y
1
(4)
DESIGN OF LINEAR PHASE FIR FILTER BY WINDOW METHOD:
Ideal frequency response h
d( ) n has infinite impulse response. By truncating the impulse response of the ideal filter on both the right and left sides yields a finite impulse response, whose associated frequency response approximates that of an ideal filter.
This is the basic idea of the impulse response window.
If h
d( ) n represents the impulse response of desired IIR filters, then an FIR filter with impulse response h ( ) n can be
obtained as follows.
(5)
The impulse response h
d( ) n is
truncated at n=0, since we are interested in a causal FIR filter. So it is possible to write
( ) n
h as
( ) ( ) ( ) n h n w n
h =
d. (6)
In equation (6), w ( ) n is called as rectangular window defined by
(7)
DTFT of equation (6) gives,
(8)
But, we would like to be equal to .This means that W ( ) ω must be equal to ∂ ( ) ω , which in turn means that,
( ) n
w =1 for all n. This gives us the infinite length ideal impulse response that cannot be realized in practice. The point here is that we desire a finite length window w ( ) n whose
DTFT W ( ) ω is close to an impulse.
The frequency response of the rectangular window is obtained by taking DTFT of w ( ) n .i.e.
(9)
( )
otherwise N n n
h n
h
d0
1 0
, )
(
=
−
≤
≤
=
otherwise N n n
w
, 0
1 0
, 1 ) (
=
−
≤
≤
=
( )
ω( )
ωω H W
H ( ) = d ∗
( ) ω H
d( ) ω H
2 / sin
) 2 / ( sin 1
) ( )
(
2 1 1
0
ω ω ω
ω ω ω
e N e e
n w W
j N N
n
n j n
n j
⋅
=
×
=
≈
−
−
−
=
∞ −
−∞
=
−
∑
∑
The magnitude is giving by
(10) And the phase is
( ) ( ) ( )
( ) ( )
<
+
−
−
>
−
= −
0 2 / sin 2
/ 1
0 2 / sin 2
/ 1
N when
N
N when
N
ω π
ω
ω ω ω
θ
(11)
The frequency response of the rectangular window has a linear phase. This is essential, because we want that the designed FIR filter to have linear phase. The magnitude frequency response of rectangular window is shown; it appears as in Figure 2.4.
Fig 2.4: Magnitude frequency response of rectangular window
We find that the magnitude response is impulse like that is, W ( ) ω is narrow pulse and it falls off sharply (sinc function).
It has a main lobe and few side lobes (ripples). When W ( ) ω is convolved with
( ) ω
h
dthe side lobes cause ripples in H ( ) ω .
Hence it is advantageous to use windows having low side lobe amplitudes. In addition, narrower the main lobe, more the W ( ) ω
will look like ∂ ( ) ω . Also, the width of main lobe of is approximates to the transition width of the desired FIR filter. The width of main lobe is found as 4π/N as shown in figure.
If one desires to have a narrow transition band for the FIR filter, the main lobe width of W ( ) ω should be narrow and this enforces the window length N should be as large as possible. Also, the effective length (defined as the area under the
window) of the window is given by L
e=1/∆f, where ∆f is the transition width of the filter.
The actual length of the filter is L ≤ L
e/β, where β is the characteristics of a window. A lot of work has been done on adjusting
( ) n
w to satisfy certain main lobe and side lode requirements.
TYPES OF WINDOWS
Rectangular window
Bartlett window
Hanning window
Hamming window
Blackman window
COMPARISON OF WINDOWS
• Triangular window has a transition width twice that of rectangular window, but attenuation in stop band is less.
2 , / sin
2 / ) ) sin(
( ω
ω ω N
W =
• The Hanning and Hamming windows have same transition width. But Hamming generates less ringing in the side lobes.
• The Blackman window reduces the side lobe level, at the cost of increase in transition width.
• The superior is Kaiser provides transition width is always small for given specification. By varying the parameter α desired side lobe level and main lobe peak can be achieved. The main lobe width can be varied by varying the length N.
Table 1. Summary of window parameters
Window
Peak amplitude of side lobe
(dB)
Main lobe width
Min. Stopband attenuation
(dB)
Rectangular -13 4π/N -21
Bartlett -25 8π/N -25
Hanning -31 8π/N -44
Hamming -41 8π/N -53
Blackman -57 12π/N -74
DESIGN PROCEDURE
Step 1: Let K1, ω1 and K2, ω2, represents the cut-off and stop band requirement for the digital filter.
Step 2: Select the window function such that stop band gain exceeds K2.
Step 3: Select the number of points in the window to satisfy the transition width for the type of the window
used. If ωt is the transition width we have ωt = ω
2- ω
1>K(2π/N) where K depends on the window used therefore N >=K(2π / = ω
2- ω
1).
Step 4: K=2 for rectangular and K=4 for hamming & Hanning window.
Step 5: Select ω
cand α such that ω
c= ω
1, where α=(N-1)/2.
Step 6: The impulse response of the FIR filter is given by
(12)
Step 7: Determine and plot frequency response H ( ) e
jωFIR HIGHPASS AND BANDPASS FILTERS
A lowpass filter with impulse response h
lp( ) n can be converted to a highpass filter or a bandpass filter by using the frequency translation property of the Fourier transform.
The highpass filter H
hp( ) ω is obtained by translating the lowpass filter
( ) ω H
lpby π.
That is H
hp( ) ω = H
lp( ω − π ) (13)
( ) ( )
( ) ( )
( ) ( ) ( ) n
N n
N n n
h
n n n
h but
n n h n h
c c d
d
ω ω
α
π ω α
ω
−
−
−
= −
∴
−
= −
=
2 / 1
2 / 1 sin
) ( sin )
(
Here the highpass filter is simply a frequency-shifted version of lowpass filter by π. The time domain equivalent of this is that h
lp( ) n is multiplied by e
−jnπ.
That is
( ) n h ( ) n e h ( )( n n j n )
h
hp=
lp.
−jnπ=
lp. cos π − sin π
( ) ( ) ( ) n h n
h
hp= − 1
n lp(14)
For a bandpass filter of bandwidth
ω
∆ and centre frequency ω
0, a lowpass filter cutoff frequency ∆ ω / 2 is designed and this is shifted in frequency by ω
0.
Therefore, the bandpass filter transfer function H
bp( ) ω is given by
( ) ω =
lp( ω − ω
0)
bp
H
H (15)
For filters with real coefficients there will be symmetry about the frequency
π , which corresponds to half the sampling frequency.
In time domain, this corresponds to
( ) n h ( ) n n
h
bp=
lp. cos ω
0(16)
This is called cosine modulation.
Advantages and Disadvantages of the window technique
Designing of FIR filter by window method is very simple to understand
conceptually and simple to apply.
Computationally very efficient even for more complicated Kaiser Window.
Most straight forward approach to design FIR filter is to truncate the impulse response of an ideal IIR by a suitable window.
Disadvantages
Draw back of window design method is the lack of precise, control of critical frequencies ω
pand ω
sin the design of a LPF. The values will depend on type of window and its window length.
Window method requires that the desired h
d(n) be known.
Windows provides limited flexibility in the design.
Somewhat difficult to determine, in advance, the type of window and the duration N required to meet a given prescribed frequency specifications.
SIMULATION RESULTS
The FIR Highpass filter is obtained,
just by changing the sign of every second
coefficient of the FIR lowpass filter. (Fig 1)
The frequency response of FIR highpass
filter for different windows is shown in
Figure 2.
Fig 1. Frequency response of the FIR lowpass filter using Rectangular, Hanning, Hamming, Blackman, Bartlett, and Kaiser Window.
Fig 2. Frequency response of the FIR highpass filter using Rectangular, Hanning, Hamming, Blackman, Bartlett, and Kaiser Window.