You are on page 1of 19
(3) FIR Filter Design and Applications tmp Example 1: Determine the cutoff frequency of the digital filter whose difference equation is, yin) ~ Sun 1) = x(n. Solution : Taking z-transform of given difference equation, Hel) = 1-3 [eos @-jsin ol ” Teme) jin 2 1 _ 1-5coso sine = z z (1-Jcose} +sin2 (1-Lcos@) +sin? o (1-geos0] +sin 1-zc0s0) +sin? @ Hence magnitude will be, sin? @ [em ¥ (ese) +sint o] ; 5 [(-}ose) esineo] @-1) Digital Signal Processing 3-2 FIR Filter Design & Applications (,_1 we 370080} +sin? @ For o= 0, |H(ei)| = tes = 14142 This is the maximum amplitude of the filter response. Now at @ = ox, the above 1.4142 amplitude will be reduced to = 1. We have to determine the ‘ai for which |H(e!®)|=1 . This value can be evaluated by testing H(e/*) for few sample values of «ie., 0.8, | H(ef*)| = 1.031 0.85, | H(el®)| = 0.993 0.82, | H(ei*) © = 0.83, |H(e!)|= 1.0083 o= 016 Thus the cutoff frequency lies near @c = 0.83 radians/sample. vm Example 2: Let h,(t) denote the impulse response of a linear time invariant analog filter and h(n) the unit sample response of a linear shift invariant digital filter i) If hg(t)=e-*ut), determine the analog filter frequency response and sketch its magnitude, ii) If ha(n)=Na(nT) with hg(0) as given above, determine the digital filter frequency response and sketch its magnitude. Solution : i) Frequency response of analog filter Consider, hy(f) = e-#'u(t) From standard fourier transform relations, the fourier transform of this function becomes, 1 Hip = as jonf fi And, HOI = taraaaE Fig, 1 shows the plot of above magnitude. HOO) Fig. 1 Plot of frequency response of analog filter Digital Signal Processing 3-3 FIR Filter Design & Applications | filter ii) Frequency response of After sampling of hy(t) at t = nT we get, hal) = ha(nT) = eT 4) Taking fourier transform, Ho) = Sohal) efor = Derm T freien Toe mt This equation gives the frequency response of the digital filter. wm Example 3: Determine the filter coefficients h(n) for the desired frequency response of a low pass filter given by, ei? for~ Haleis) = 0 for If we define the new filter coefficients by h(n) = h(t) -tw(n), where _ [1 for Osns4 mn) = { 0 elsewhere Determine h(n) and also the frequency response H(e) and compare with Ha(el)| Solution : i) To obtain ha(n) The given Ha(el#) is for a lowpass type of filter. Taking inverse fourier transform of Ha(ei9) we get, glo) Hy | Hale)eiendeo is =p fete-cind 3 A f : ‘i-2) deo an a Digital Signal Processing 3-4 FIR Filter Design & Appli 2n| j—2) Above equation can be simplified to, {_. an-2) TT forne2 halo) = }Wa=2} 1 i for n=2 This equation gives filter coefficients for the desired filter. )) To obtain h(n) The given window function is, _ fl for Osns4 BS { otherwise This is rectangular window of length M = 5. For this window, h(n)=hy(n) for O 0 id LH = ant (o) {ie for |H(o)| <0 Above two equations can be plotted against ‘oi to give frequency response. Here note that | H(«) | will not be exactly same as H,(«) due to windowing operation nm Example 4: Design an FIR filter (lowpass) using rectangular window with passband gain of 0.4B, cut-off frequency of 200 Hz, sampling frequency of 1 kHz. Assume the length of the impulse response as 7. Solution : Given data : F. = 200 Hz, F = 1000 Hz fe z 200 = 0.2 cycles/sample ee = 2q M=7 The impulse response of the desired filter is as given by eq. 3.4.20. Putting M = 7 and = 04 min this equation we get, (sin [0.4 x(n-3)] {xa 0.4 for n=3 hal) ne3 Since window function is rectangular, h(n) = h(n). The coefficients are as follows : Mnj=ha(n) for 05 n<6 WO) = = 0.062341 W4) = 0.302609 WI) = 0.093511 (5) = 0.093511 2) = 0.302609 (6) = - 0.062341 W3) = 04 These are the required filter coefficients. Digital Signal Processing 3-6 FIR Filter Design & Applications mm Example 5: Using a rectangular window technique, design a low pass filter with passband gain of unity, cutoff frequency of 1000 Hz and working at a sampling frequency of SkHz, The length of impulse response should be 7. Solution : Here F. = 1000 Hz, F, = 5000 Hz Fe _ 1000 _ fe = FE ~ 5qg9 = 02 eyeles/sample @. = Infe = 2nx0.2 = 04K M=7 Note that these specifications are exactly similar to those of last example. Hence filter coefficients will be same as calculated in last example ie, (0) = ~ 0.062341 (4) = 0.302609 hn) = 0.093511 (5) = 0.093511 (2) = 0.302609 (6) = ~ 0.062341 WW3) = 04 nm Example 6 : Design an ideal bandpass filter with frequency response. Hil 3n for Fsjo<32 Als iw Use rectangular window with N = 11 in your design Solution : i) To obtain ha(n) The given bandpass filter has a passband from = to 2 = z rad/sample. The desired unit sample response of the ideal bandpass filter is given by eq. 3.4.25 as, sing(na)-Sin =) ey gy hal) = x 2 ~0. for n=t Here = M = 5, Putting values in above equation, Sresecs (se 2) sin | so 2 4 hao) = 4 any Bn ln | 1 for 125 Digital Signal Processing 3-7 FIR Filter Design & Applications {i) To obtain h(n) by windowing Here since rectangular window is given, : hin) = han) for OSm1 = 3 = M-=7, For odd length of M, the frequency response is given as, M3 z (,_ Mz1) yh (n-=— (n) coso( n= “= } azo ot {h(342 Yin) cose(n-3)} L no = €3 h(3)+2.h(0) cos 30+2(1) cos 2@+2 h(2) cos o} Comparing with given H(e!®) we get, 2h(0) = 18 = h(0)=09 2n(1) 12 = h(1)=06 2h(2) = 05 = h(2)= 0.25 Digital Signal Processing 3-10 FIR Filter Design & Applications (3) = 2 Since filter has linear phase, h(n)=h(M-1-n) h(n) = h(6-n) (4) = h(6-4)=h(2) = 0.25 (5) = h(6-5)=h(1) = 06 h(6) = h(6-6)=h(0) = 0.9 Thus h(n) = (0.9, 06, 0.25, 2, 0.25, 0.6, 0.9} Example 11: Deduce the equation for the frequency spectrum for the rectangular window sequence defined by, fr BD oy we(n)= 4" 0 otherwise What is the width of main lobe of the spectrum ? Solution: DTFT of window function is given as, Here let us use, Digital Signal Processing 3-11 FIR Filter Design & Applications Frequency spectrum will be, The width of the main lobe of the spectrum is <7, Example 12: The frequency response of a filter is given by H(ci*)=jo; -xsosn Design the filter, using a rectangular window function. Take N = 7. Solution : The desired impulse response is given as, j Hg(o) el" do ha(n) 1 on & J ioe” do ne0 0 for n=0 To have linear phase, we will shift h(n) to right. This shift is equal to samples. ie., {cosr(n-3) n-3 Values of h(n) can be calculated as follows : ho) = SCS and h(3) z " Digital Signal Proce: ing 3-12 FIR Filter Design & Applications nO) ho) Thus, h(n) = Here observe that h(n)=-h(N-1-n) with N = 7 since it is antisymmetric linear phase filter. Example 13: By choosing an appropriate window, design a linear phase, odd-length, low-pass FIR filter that satisfies the following specifications 0.985 < |H(el*)|< 1015, 0 X(0-2) a) and B2(R) = Ke x(n)+Ky (1+ Kz) x(n 1) + x(n -2) = 6) For third stage we can write, y(n) = f(n)+Ks g2(n-1) = x(n)+ {Ky +K, Kz +Kz Ks} x(n=-1) + {Kz +Ki Ks + Ky Ka K3}x(n-2)+Ks3 x(n—-3) ~ 0.34 and K3 = 0.8 and after simplification, y(n) = x(n)+0.157 x(n 1) + 0.0032 x(n -2)+ 0.8 x(n -3) K " X(z)+ 0.157 2-1 X(z)+0.0032 2°? X(z)+0.8 2 X(z) H(z) = 140.157 271 + 0.00322 +0829 z 3 " 1+0.1578(n-1) + 0.0032 6(n -2)+0.88(n -3) = mt xn) y(n) Fig. 7 Direct form structure nm Example 17: Design an ideal high pass filter with a frequency response Ha(el® Find the value of h(n) for N = 11 using (i) Hamming window (ii) Hanning window [Nov /Dec-2004, 16 Marks] Solution : Here the magnitude of H,(ei*) is given. The complete function can be represented as, Digital Signal Processing 3-18 FIR Filter Design & Applications reer) = [0 for -nsos-™ & Bcasn 0 elsewhere To obtain hg(n) for M = 11 Taking inverse Fourier transform of H.,(e!), 7 hal) = all Hale) eio"da = Lf ermennio 14 joo = alll elhmn) den (1) 5 sin x(n d-sin Fora} for net 2) And for n=, equation (1) above becomes, 4, han) = 3 = forn=« @ For linear phase filter r= 5, Therefore from eq. (2) and (3) ha(n) can be collectively written as, Digital Signal Processing 3-19 FIR Filter Design & Applications 1 { 7 al — eI sina(n-5)-sin2(n-5)}forn#5 hng(r) = xe =) ao 3 forn=5 To obtain coefficients of a filter Following table shows values of hg(n), o(r) for hamming and hanning window. Then h(n) is given as, Rin) = hg(n)-w{n) n halo) Hamming [Hanning window] Filter Filter window Wamm(M) coefficients coefficients Hamm (9) (Hamming) h(n) | (Hanning) h(n) = = ha(M)W pean(M) | Mal nana) 1 054-046, Wa cos 25") x(n) aan a 1) [sinxer-5) M4 ie. for M = 11, ‘i ie.torm=11, | 47 } sin (n- §) Aft cosZn [singr-9) 0.54 ~ 0.46 a\t-85"} torn es , cost 0 | (0) 0045 0.08 ° 0.0036 ° + | na(d=0 03167 0095 0 ° 2 | naay~-075 0.397 08s = 0.297 ~ 0.2567 3 | na(@)=-0189 0662 0.654 ~ 0.1084 = 0.1099 4 | natty = 0205 oar 0.908 = 02052 = 0.2034 5 | naey=3- 078 1 1 075 078 6, | ha(@)=-0.225 ost 0.908 = 02052 — 0.2034 7 | ne(ty= 0159 0.682 0.654 = 0.1084 ~ 0.1098 8 | na(8)=~0075 0.397 0.345 = 02977 = 0.2587 9 | na(@=0 0.167 0095 ° ° 10 | ha(10)= 0045 0.08 ° 0.0038 ° Qo00

You might also like