J. Comp. & Math. Sci. Vol.3 (6), 571-578 (2012)
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. y (n
)=
∑ h (k ). x (n − k
N −1 k = 0
)
(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). N−1
H(z) =∑ h(k)z−k
(2)
k=0
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
Journal of Computer and Mathematical Sciences Vol. 3, Issue 6, 31 December, 2012 Pages (557-663)
572
B. N. Jagadale, J. Comp. & Math. Sci. Vol.3 (6), 571-578 (2012)
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................... p may lead to the filter becoming unstable. IIR filters are characterized by the following two equations.
h ( n ) = h d (n ) =0
h(n) = hd (n).w(n)
Y (z ) k =−Q = p X (z ) 1 + ∑ a (k )z − k
w (n) = 1
= 0 (3)
k =1
y (n ) = ∑ b (k )x (n − k ) − ∑ a (k )y (n − k ) Q
p
k =−Q
k =1
(4)
DESIGN OF LINEAR PHASE FIR FILTER BY WINDOW METHOD: Ideal frequency response hd (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 hd (n ) represents the impulse response of desired IIR filters, then an FIR filter with impulse response h(n ) can be obtained as follows.
(5)
(6)
In equation (6), w(n ) is rectangular window defined by
−k ∑ b (k )z
(z ) =
otherwise
The impulse response hd (n ) is truncated at n=0, since we are interested in a causal FIR filter. So it is possible to write h(n ) as
Q
H
,0 ≤ n ≤ N − 1
called
,0 ≤ n ≤ N −1 , otherwise
as
(7)
DTFT of equation (6) gives, H (ω ) = H
d
(ω ) ∗
W
(ω )
(8)
But, we would like H d (ω ) to be equal to H (ω ).This means that W (ω ) must be
equal to ∂ (ω ) , which in turn means that,
w(n ) =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. W (ω) ≈
∞
∑ w(n)e
n = −∞
− jωn
N −1
= ∑1 × e− jωn n =0
=e
N −1 − jω 2
sin (ωN / 2) ⋅ sinω / 2
Journal of Computer and Mathematical Sciences Vol. 3, Issue 6, 31 December, 2012 Pages (557-663)
(9)
B. N. Jagadale, J. Comp. & Math. Sci. Vol.3 (6), 571-578 (2012)
The magnitude is giving by W (ω ) =
sin( ω N ) / 2 , sin ω / 2
And the phase is θ (ω
)=
when − ω (N − 1 ) / 2 − ω ( N − 1 ) / 2 + π when
(10)
sin (ω N / 2 ) > 0
sin (ω N / 2 ) < 0
(11)
573
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
hd (ω ) the 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 Le=1/∆f, where ∆f is the transition width of the filter. The actual length of the filter is L ≤ Le/β, where β is the characteristics of a window. A lot of work has been done on adjusting w(n ) 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.
Journal of Computer and Mathematical Sciences Vol. 3, Issue 6, 31 December, 2012 Pages (557-663)
574
B. N. Jagadale, J. Comp. & Math. Sci. Vol.3 (6), 571-578 (2012)
• 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 Peak amplitude Main Window
Min. Stopband
of side lobe
lobe
attenuation
(dB)
width
(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
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 ωc and α such that ωc = ω1, where α=(N-1)/2. Step 6: The impulse response of the FIR filter is given by
h ( n ) = hd (n )ω (n ) but hd (n ) =
sin ω c (n − α ) π (n − α )
(12)
sin ω c (n − N − 1 / 2 ) ∴ h (n ) = ω (n ) n − N −1/ 2 Step 7: Determine and response H e jω
( )
plot
frequency
FIR HIGHPASS AND BANDPASS FILTERS A lowpass filter with impulse
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
response hlp
(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 lp (ω ) by π. That is H hp (ω ) = H lp (ω − π )
Journal of Computer and Mathematical Sciences Vol. 3, Issue 6, 31 December, 2012 Pages (557-663)
(13)
B. N. Jagadale, J. Comp. & Math. Sci. Vol.3 (6), 571-578 (2012)
Here the highpass filter is simply a frequency-shifted version of lowpass filter by π. The time domain equivalent of this is
that hlp (n ) is multiplied by e − jnπ . That is
hhp (n ) = hlp (n ).e − jnπ = hlp (n )( . cos πn − j sin πn )
hhp (n ) = (− 1) hlp (n ) n
(14)
For a bandpass filter of bandwidth
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
∆ω 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
H bp (ω ) = H lp (ω − ω 0 )
(15)
For filters with real coefficients there will be symmetry about the frequency π , which corresponds to half the sampling frequency.
575
Draw back of window design method is the lack of precise, control of critical frequencies ωp and ωs in the design of a LPF. The values will depend on type of window and its window length. Window method requires that the desired hd(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.
In time domain, this corresponds to
hbp (n ) = hlp (n ). cos ω 0 n
(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
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.
Journal of Computer and Mathematical Sciences Vol. 3, Issue 6, 31 December, 2012 Pages (557-663)
B. N. Jagadale, J. Comp. & Math. Sci. Vol.3 (6), 571-578 (2012)
Fig 1. Frequency response of the FIR lowpass filter using Rectangular, Hanning, Hamming, Blackman, Bartlett, and Kaiser Window.
576
Journal of Computer and Mathematical Sciences Vol. 3, Issue 6, 31 December, 2012 Pages (557-663)
Fig 2. Frequency response of the FIR highpass filter using Rectangular, Hanning, Journal of Computer and Mathematical Sciences Vol. 3, Issue 6, 31 December, 2012 Pages (557-663)
Hamming, Blackman, Bartlett, and Kaiser Window.
577
B. N. Jagadale, J. Comp. & Math. Sci. Vol.3 (6), 571-578 (2012)
578
B. N. Jagadale, J. Comp. & Math. Sci. Vol.3 (6), 571-578 (2012)
CONCLUSIONS
REFERENCES
We have designed FIR lowpass filter by window method having specification: cutoff frequency 20Hz and sampling frequency 100Hz.The frequency response of the FIR lowpass filter designed using Rectangular, Hanning, Hamming, Blackman, Bartlett, and Kaiser Window. By comparing the response of different windows, it is clear that the Bartlett window has the poor response and the Kaiser window has the optimal.
1. Ashok Ambardar, “Digital Signal Processing: A Modern Introduction. 2. John G. Prokis, D. G. Manolakis “Digital Signal Processing-Principles, Algorithms and Applications. 3. Sanjith K Mitra, Digital Signal Processing–A Computer based approach. Tata Mc Graw Hill (1998). 4. D. Ganesh Rao, Vineeta P Gejji, “Digital Signal Processing: a simplified approach”. 5. S. V. Narasimhan, S. Veena, “ Signal Processing-Principle and Implimentaion”. Narosa, (2005).
Journal of Computer and Mathematical Sciences Vol. 3, Issue 6, 31 December, 2012 Pages (557-663)