Finite Impulse Response (FIR) Digital Filters (II) Ideal Impulse Response Design Examples Yogananda Isukapalli
1 • FIR Filter Design Problem Given H(z) or H(ejw), find filter coefficients {b0, b1, b2, ….. bN-1} which are equal to {h0, h1, h2, ….hN-1} in the case of FIR filters.
1 z-1 z-1 z-1 z-1 x[n] h0 h1 h2 h3 hN-2 hN-1
1 1 1 1 1 y[n] Consider a general (infinite impulse response) definition: ¥ H (z) = å h[n] z-n n=-¥
2 From complex variable theory, the inverse transform is: 1 n -1 h[n] = ò H (z)z dz 2pj C
Where C is a counterclockwise closed contour in the region of convergence of H(z) and encircling the origin of the z-plane • Evaluating H(z) on the unit circle ( z = ejw ) :
¥ H (e jw ) = åh[n]e- jnw n=-¥
1 p h[n] = ò H (e jw )e jnwdw where dz = jejw dw 2p -p
3 • Design of an ideal low pass FIR digital filter
H(ejw) K
-2p -p -wc 0 wc p 2p w Find ideal low pass impulse response {h[n]}
1 p h [n] = H (e jw )e jnwdw LP ò 2p -p
1 wc = Ke jnwdw 2p ò -wc Hence K h [n] = sin(nw ) n = 0, ±1, ±2, …. ±¥ LP np c 4 Let K = 1, wc = p/4, n = 0, ±1, …, ±10 The impulse response coefficients are n = 0, h[n] = 0.25 n = ±4, h[n] = 0 = ±1, = 0.225 = ±5, = -0.043 = ±2, = 0.159 = ±6, = -0.053 = ±3, = 0.075 = ±7, = -0.032
n = ±8, h[n] = 0 = ±9, = 0.025 = ±10, = 0.032
5 Non Causal FIR Impulse Response
We can make it causal if we shift hLP[n] by 10 units to the right: K h [n] = sin((n -10)w ) LP (n -10)p c n = 0, 1, 2, …. 20
6 Causal FIR (N = 21) Impulse Response
Notice the symmetry: h[n] = h[N-1-n] which satisfies the linear phase condition.
• Filter Transfer Function
20 jw - jnw jw H LP (e ) = åhLP[n]e since z = e n=0 7 20 Implies -n H LP (z) = åhLP[n]z n=0
Filter Implementation for 21 coefficients Magnitude of filter Frequency Response for 11, 21 and 31 coefficient lengths
8 Low Pass filter Frequency Response in dB for 11 and 21 coefficients
Low pass filter phase response for 21-coefficient design
9 The above figure implies jw j(w-p ) H HP (e ) = H LP (e ) n hHP[n] = hLP[n](-1)
10 Now: ¥ ¥ jw - jn(w-p ) - jnw n H HP (e ) = åhLP[n]e = åhLP[n]e (-1) n=-¥ n=-¥
¥ n - jnw = åhLP[n](-1) e n=-¥
hHP[n]
Example: Analog high pass filter specification
Ideal high pass
0 10 kHz f
Given: fs = 50kHz, it follows:w = WT = 2pf/fs = 0.4p rad Digital specification: 0.4p = p - wa 11 \ wc (LPF) = p - wa = p - 0.4p = 0.6p
First design ideal LPF with wc= 0.6p 1 Answer : h [n] = sin(0.6pn) LP np n = 0, ±1, ±2, …. ±¥ Follows now:
n hHP[n] = hLP[n](-1) (-1)n-I h [n] = sin(0.6p (n - I)) HP p (n - I)
The I indicates the length of the filter
Hence the above filter is a causal FIR high pass digital filter 12 13 14 15 Bandpass FIR filter design:
H(ejw) K
-p -wu -wo-wl 0 wl wo wu p w
Shift to right: H(ejw) ejwo Shift to left: H(ejw) e-jwo Follows:
hBP[n] = [2cosnwo ]hLP[n] n = 0, ±1, ±2, …. ±I where
wu - wl = 2wc (lowpass) w + w w = u l o 2 16 Example: H(ejW) 1 fs = 50kHz
-15 -10 0 10 15 f in kHz Digital specifications: 2p (104 ) w = = 0.4p l (5)(104 )
2p (104 )(1.5) w = = 0.6p u (5)(104 )
wo = 0.5p w - w w = u l = 0.1p c 2 17 First design LPF: 1 hLP[n] = sin(0.1pn) n = 0, ±1, ±2, …. np
Follows: hBP[n] = [2cos(0.5pn)hLP[n] n = 0, ±1, ±2, ….
18 19 20 Bandpass filter frequency response
21 Homework # 6
1. Design a length-5 FIR bandpass filter with an antisymmetric impulse response h[n], i.e. h[n]= -h[4-n], 0£n £4, satisfying the following magnitude response jp jp values : | H ( e 4 ) | = 0 . 5 and | H ( e 2 ) | = 1 . Determine the exact expression for the frequency response of the filter designed. 2. An FIR filter of length 5 is defined by a symmetric impulse response i.e. h[n]= h[4-n], 0£n £4,. Let the input to this filter be a sum of 3 cosine sequences of angular frequencies: 0.2 rad/samples, 0.5 rad/samples, and 0.8 rad/samples, respectively. Determine the impulse response coefficients so that the filter passes only the midfrequency component of the input. 3. The frequency response H(ejω) of a length-4 FIR filter with a real and antisymmetric impulse response has the following specific values: H(ejπ)=8, and H(ejπ/2)= -2+j2. Determine H(z).
22 Frequency transformations of ideal filters. High pass Filter
The ideal low filter frequency response is shown below. hLP[n] jw represents the non-causal impulse response of HLP(e )
jw HLP(e )
-2p 0 2p -2p-wc -p -wc wc p 2p-wc w
Shifting the low pass filter frequency by p, we get
j(w-p) HLP(e )
-2p 0 2p -p-wc -p -p+wc p-wc p p+wc w 23 The above figure is the frequency response of an ideal high pass jw filter with a cutoff frequency of p-wc (HHP(e ) ).Hence,
jw j(w-p ) H HP (e ) = H LP (e )
From the shifting property of the Fourier transform, we get
jpn hHP [n] = hLP [n]e
n hHP [n] = (-1) hLP [n]
1 where h [n] = sin(nw ) LP pn c Hence, to design an ideal high pass filter with cutoff frequency of wa, first design a ideal low pass filter with a cutoff frequency of (p-wa). Then use the above transformation to obtain the impulse response of the ideal high pass filter. 24 Band pass Filter
The frequency response for an ideal band pass filter is shown
below. The center frequency is wo. jw HBP(e ) K
-p -wu -wo wl wl wo wu p jw Low pass frequency response HLP(e )
-p -wc wc p w
Looking at the frequency responses of a band pass filter and a low pass filter, we can observe that a band pass filter is obtained by
shifting the low pass filter to the left and to the right by wo and
adding the two shifted responses. 25 Shifting the low pass filter by wo to the left and to the right and adding , we get
j(w-wo) j(w+wo) HLP(e )+HLP(e )
-p -wc-wo -wo wc-wo -wc+wo wo wc+wo p
Comparing the ideal band pass filter and the above figure, we can observe that
wl = -wc + wo
wu = wc + wo w - w w = u l c 2 w + w w = u l o 2 26 jw The frequency response of the band pass filter HBP(e ) is
jw j(w-wo ) j(w+wo ) H BP (e ) = H LP (e ) + H LP (e )
From the shifting property of the Fourier transform , we have
jwon - jwon hBP [n] = hLP [n]e + hLP [n]e
jwon - jwon hBP [n] = hLP [n]{e + e }
hBP [n] = hLP [n]{2cos(nwo )}
To design a band pass filter, first design a low pass filter with
cutoff frequency wc given by w - w w = u l c 2 And use the above transformation to get the impulse response of the band pass filter . 27 Band stop Filter
jw The frequency response of an ideal band stop filter (HBS(e )) is
jw HBS(e )
-p 0 p -wu -wo -wl wl wo wu w
Looking at the frequency responses of band stop and band pass filters, we observe that the band stop filter is obtained by subtracting the band pass from 1.
jw jw H BS (e ) = 1- H BP (e )
28 ¥ ¥ - jnw - jnw å hBS [n]e = 1- å hBP [n]e n=-¥ n=-¥
If we work out the first few terms, we get
j2w jw - jw - j2w ...... + hBS [-2]e + hBS [-1]e + hBS [0] + hBS [1]e + hBS [2]e j2w jw - jw - j2w = ...... + hBP [-2]e + hBP [-1]e +1- hBP [0] + hBP [1]e + hBP [2]e
Hence, the impulse response coefficients for a band stop filter are obtained as
hBS [0] = 1- hBP [0] = 1- 2hLP [0]
hBS [n] = -hBP [n] = -hLP [n]{2cos(nwo } n ¹ 0
29 Low pass
K h [n] = sin(nw ) n = 0,±1,±2,...,±I LP np c
H(ejw) K
-p -wc wc p High pass
n hHP[n] = (-1) hLP[n], n = 0,±1,±2,...,±I
H(ejw) K
30 -p -(p -wc) (p- wc) p Band pass
hBP[n] = [2cos(nwo )]hLP[n], n = 0,±1,±2,...,±I w + w w - w = 2w , w = u l u l c 0 2 H(ejw) K
-p -wu -wo wl wl wo wu p Band stop
hBS [0] = K - hBP[0],
hBS [n] = -hBP[n], n = ±1,±2,...,±I
wu + wl wu - wl = 2wc , w0 = 2 H(ejw) K
-p -wu -wo wl wl wo wu p 31 Examples
1. An FIR filter is defined by a symmetric impulse response, i.e. h[0] = h[2]. Input to the filter is a sum of two cosine sequences of angular frequencies 0.2 rad/s and 0.5 rad/s
Determine the impulse response coefficients so that it passes only the high frequency component of the input Solution:
Since h[0] = h[2] H (e jw ) = h[0](1+ e- j2w ) + h[1]e- jw = h[0] e- jw (e jw + e- jw ) + h[1] e- jw - jw = e ( 2h[0] cos(w0 ) + h[1] ) Since only high frequency component can pass through the filter, when,
jw0 w0 = 0.2 Þ H(e ) = 0 and
jw0 w0 = 0.5 Þ H(e ) =1 i.e. H(e j0.2 ) = 2h[0]cos(0.2) + h[1] = 0 H(e j0.5 ) = 2h[0]cos(0.5) + h[1] = 1
Solving these two equations,
h[0] = h[2] = - 4.8788 and h[1] = 9.5631 32 2. Design a length – 4 FIR bandpass filter with an anti symmetric impulse response i.e. h[n] = h[-n-4], for 0 n 4 satisfying the following magnitude response Values: | H (e jp / 4 ) | = 1 and | H (e jp / 2 ) |= 0.5
jw - jw - j2w - j3w H (e ) = ho + h1e + h2e + h3e - jw - j2w - j3w = ho + h1e - h1e - h0e - j3w - jw - jw = h0 (1- e ) + h1e (1- e ) - j3w/ 2 j3w/ 2 - j3w/ 2 - jw - jw/ 2 jw/ 2 - jw/ 2 = h0e (e - e ) + h1e (e (e - e )) - j3w/ 2 = je (2h0 sin(3w/ 2) + 2h1 sin(w/ 2))
Since we have | H(e jp/4 ) |=1 and | H(e jp/2 ) |= 0.5
jp/4 H(e ) = 2h0 sin(3p/8) + 2h1 sin(p/8) =1 and jp/2 H(e ) = 2h0 sin(3p/4) + 2h1 sin(p/4) = 0.5
Solving equations, we get
33 h0 = - 0.0381 and h1 = 0.7452 3. The frequency response of a length-4 FIR filter has values: | H (e j0 ) |= 2 | H (e jp / 2 ) |= 7 - j3 and | H (e jp ) |= 0 Determine H(z) Solution Using the symmetry property of DTFT of a real sequence, we observe that | H (e j3p / 2 ) |=| H *(e jp / 2 ) |= 7 + j3 Thus the 4 point DFT of the sequence is given by: H (k) = [2 ,7 - j3, 0 ,7 + j3] The inverse DFT of the H(k) gives h(n) as:
h(n) = (4 , 2 , -3 , -1) (using ifft in MATLAB)
Therefore H(z) is:
H (z) = 4 + 2z-1 - 3z -2 - z -3
34