Chapter 7 Finite Impulse Response(FIR) Filter Design Properties of FIR filter FIR filter has characteristics: N y ( n) h( k ) x ( n k ) k 0 (7-1) N H ( z ) h( k ) z k (7-2) k 0 – Always stable – Exactly linear phase response – Simple to implement • The effect of finite wordlength in FIR is less than in IIR filters 2/77 Linear phase response Phase response of FIR filter H (e jT N ) h(k )e j kT k 0 = H (e jT ) e j ( ) (7-3) where ( ) arg H (e jT ) (7-4) – Phase delay p and group delay g p ( ) g d ( ) d (7-5) (7-6) 3/77 – Conditions to be linear phase response ( ) (7-7) ( ) (7-8) where and are constants Constant group and constant phase delay responses 4/77 • Impulse response of the filter should have positive symmetry to satisfy Eq. (7-7), thus ( ) N = tan 1 h(n) sin nT n 0 N h(n) cos nT (7-9) n 0 N tan = h(n) sin nT n 0 N h(n) cos nT (7-10) n 0 5/77 N h(n) cos nT sin sin nT cos 0 (7-11) n 0 N h(n) sin( nT ) 0 (7-12) n 0 – For symmetry condition h(n) h( N n), 0 n N NT / 2 (7-13) (7-14) 6/77 – For the condition given in Eq. (7-8) » Constant group delay only » Negative symmetric impulse response h(n) h( N n), 0 n N NT / 2 (7-15) (7-16) /2 7/77 Fig. 7-1. 8/77 Example 7-1 1) Symmetric impulse response for linear phase response • No phase distortion h(n) h( N n) or h(n) h( N n) 2) Using the symmetry condition • For N 10 h(0) h(10) h(1) h(9) h(2) h(8) h(3) h(7) h(4) h(6) 9/77 • Frequency response H ( ) H ( ) H (e jT ) 10 = h(k )e jkT k 0 =h(0) h(1)e jT h(2)e j 2T h(3)e j 3T h(4)e j 4T h(5)e j 5T +h(6)e j 6T h(7)e j 7T h(8)e j 8T h(9)e j 9T h(10)e j10T =e j 5T [h(0)e j 5T h(1)e j 4T h(2)e j 3T h(3)e j 2T h(4)e jT h(5) +h(6)e jT h(7)e j 2T h(8)e j 3T h(9)e j 4T h(10)e j 5T ] – Using the symmetry condition H ( )=e j 5T [h(0)(e j 5T e j 5T ) h(1)(e j 4T e j 4T ) h(2)(e j 3T e j 3T ) h(3)(e j 2T e j 2T ) h(4)(e jT e jT ) h(5)] e j 5T [2h(0) cos(5T ) 2h(1) cos(4T ) 2h(2) cos(3T ) 2h(3) cos(2T ) 2h(4) cos(T ) h(5)] – Compact form 5 H ( )= a(k ) cos(kT )e j 5T H ( ) e j ( ) k 0 where 5 H ( ) = a(k ) cos(kT ) k 0 ( ) 5T 10/77 3) N 9 h(0) h(9) h(1) h(8) h(2) h(7) h(3) h(6) h(4) h(5) • Using the symmetry condition H ( )=e j 9T /2 [h(0)(e j 9T e j 9T ) h(1)(e j 7T e j 7T ) h(2)(e j 5T e j 3T ) h(3)(e j 3T e j 3T ) h(4)(e jT e jT )] e j 9T /2 [2h(0) cos(9T / 2) 2h(1) cos(7T / 2) 2h(2) cos(5T / 2) 2h(3) cos(3T / 2) 2h(4) cos(T / 2)] = H ( ) e j ( ) 5 where H ( )= b(k ) cos[ ( k 1/ 2)T ] k 1 ( ) (9 / 2)T b ( k ) 2h( N 1 k ), k 1, 2, 2 , N 1 2 11/77 Table 7.1 A summary of the key point about the four types of linear phase FIR filters 12/77 Zeros of FIR filters Transfer function for FIR filter N H ( z ) h( k ) z k k 0 – Positive symmetry (types 1 and 2) N H ( z ) h( N k ) z k k 0 0 = h( k ) z k z N k N =z N H ( z 1 ) (7-17) 13/77 1) H ( z ) has zero at z z0 (i.e., z0 re j ) , then should have zero at z0 1 r 1e j If h(n) is real and z0 is complex number, should have conjugate zero at z0* re j This means that ( z0* ) 1 r 1e j should be zero. If each complex zero does not exist on the unit circle, then have 4 conjugate reciprocal zeros : (1 re j z 1 )(1 re j z 1 )(1 r 1e j z 1 )(1 r 1e j z 1 ) 14/77 2) If zero exists on unit circle, then r 1, 1/ r 1 , i.e., z0 e j becomes z0 1 e j z0* (1 e j z 1 )(1 e j z 1 ) 3) If zeros are real and do not exist on the unit circle, then (1 rz 1 )(1 r 1 z 1 ) 4) If zeros exist on z 1 , then (1 z 1 ) 15/77 • If zeros exist on z 1 , then H (1) (1) N H (1) – For symmetry and odd N, Should have mandatory zero at z 1 – Impulse response of type 3 (even N) and type 4 (odd N) H ( z ) ( z ) N H ( z 1 ) (7-18) • For z = 1 Mandatory zero at z 1 • For z 1 and even N Mandatory zero at z 1 16/77 Mandatory zero Mandatory zero Mandatory zero Mandatory zero Fig. 7-2. 17/77 FIR filter design Design of FIR Filter – Need to decide : • Type of filter • Amplitude and/or phase responses • Tolerances • Sampling frequency • Wordlength of the input data – To calculate filter coefficients, select the method from: • Window method, Optimal method, Frequency sampling method 18/77 Filter specifications – Important parameters p peak passband deviation (or ripples) r stopband deviation p passband edge frequency ( 2 f ) p p r stopband edge frequency (r 2 f r ) s sampling frequency (s 2 f s ) – Another important parameter Filter order N 19/77 ILPF Fig. 7-3. 20/77 FIR coefficient calculation N y ( n) h( k ) x ( n k ) k 0 N H ( z ) h( k ) z k k 0 – Most commonly used methods for obtaining h(k ) • Window, optimal, and frequency sampling methods 21/77 Window method Design of FIR filter using window methods – Frequency response of filter, H I ( ) – Impulse response, hI (n) hI (n) 1 2 1 2 H I ( )e j n d (7-19) – Ideal lowpass response hI (n) 1 e j n d 2 f c sin(nc ) , n = c 2 fc , 1 2 c e j n d c n 0, - n n0 (7-20) 22/77 Fig. 7-4. 23/77 Truncation for FIR h(n) hI (n)w(n) H(e j ) 1 2 1 2 "windowing" H I (e j ) W(e j ) H I (e j )W(e j ( ) )d – Rectangular Window 1 , n 0,1,..., N w(n) 0 , elsewhere 24/77 Fig. 7-5. 25/77 Fig. 7-6. 26/77 Fig. 7-7. 27/77 Table 7.2 Summary of ideal impulse responses for standard frequency selective filters hI (n) hI (n) hI (n) f c , f1 and f 2 are the normalized passband or stopband cutoff frequencies 28/77 Some common window functions – Hamming window 0.54 0.46cos 2 n / N , 0 n N w n 0 , elsewhere (7-21) • Appropriate relationship between transition width and filter length F 3.32 / N (7-22) where N is filter order and F is normalized transition width 29/77 – Properties of common window functions Fig. 7-8. 30/77 Table 7.3 summary of important features of common window functions 31/77 – Kaiser window • Trade-off transition width against ripple – Using a ripple control parameter 2 2 n N I0 1 N wn , 0n N I0 0 , elsewhere (7-23) where I 0 ( x) is zero-order modified Bessel function of the first kind ( x / 2) k I 0 ( x) 1 k ! k 1 L 2 where typically L 25 32/77 • Determination of parameter – Using the stopband attenuation requirements – Using empirical relationships 0, 0.5842( A 21)0.4 0.07886( A 21), 0.1102( A 8.7) if A 21dB if 21dB A 50dB if A 50dB where A 20log10 ( ) is the stopband attenuation min( p , s ) , since the passband and stopband ripples are nearly equal • The number of filter coefficients N N A 7.95 14.36f (7-25) where f is the normalized transition width 33/77 The window method of calculating FIR filter coefficients – Step 1 : specify the desired frequency response of filter, H I ( ) – Step 2 : obtain the impulse response, hI (n) , of desired filter by evaluating the inverse Fourier transform – Step 3 : select a window function and then determine the number of coefficients using the appropriate relationship between the filter length and the transition width, f – Step 4 : obtain values of w( n ) for chosen window function and the values of the actual FIR coefficient, h(n) , by multiplying hI (n) by w( n ) h(n) hI (n) w(n) (7-26) 34/77 Example 7-2 – Obtain coefficients of FIR lowpass filter using hamming window Passband cutoff frequency f p : 1.5kHz Transition width f : 0.5kHz Stopband attenuation 50dB Sampling frequency f s : 8kHz • Lowpass filter sin nc 2 f , n0 c hI n nc 2 fc , n0 F f / f s 0.5 / 8 0.0625 N 3.32 / F 3.32 / 0.0625 53.12 N 54 35/77 • Using Hamming window 0 n 54 h(n) hI (n) w(n) w(n) 0.54 0.46 cos(2 n / 54) 0 n 54 – Considering the smearing effect of the window function fc' f p f / 2 (1.5 0.25) 1.75[kHz ] fc fc' / f s 1.75 / 8 0.21875 N 2 f sin ( n ) c c 2 , N hI (n) (n )c 2 2 fc , n N , 0 n N 2 n N 2 36/77 – Symmetrical function h(n) » Calculation of h(0), h(1), , h(27) » Using the symmetry property to obtain the other coefficients 2 0.21875 sin(27 2 0.21875) 27 2 0.21875 0.00655 n 0 : hI (0) w(0) 0.54 0.46 cos(0) 0.08 h(0) hI (0) w(0) 0.00052398 2 0.21875 sin( 26 2 0.21875) 26 2 0.21875 0.011311 n 1 : hI (1) w(1) 0.54 0.46 cos(2 / 54) 0.08311 h(1) hI (1) w(1) 0.000940057 37/77 2 0.21875 sin( 25 2 0.21875) 0.00248397 25 2 0.21875 w(2) 0.54 0.46 cos(2 2 / 54) n 2 : hI (2) 0.092399 h(2) hI (2) w(2) 0.000229516 2 0.21875 sin(1 2 0.21875) 1 2 0.21875 0.312936 n 26 : hI (26) w(26) 0.54 0.46cos(2 26 / 54) 0.9968896 h(26) hI (26) w(26) 0.3112226 n 27 : hI (27) 2 f c 2 0.21875 0.4375 w(27) 0.54 0.46 cos(2 27 / 54) 1 h(27) hI (27) w(27) 0.4375 38/77 Fig. 7-9. 39/77 Example 7-3 – Obtain coefficients using Kaiser or Blackman window Stopband attenuation : 40dB passband attenuation : 0.01dB Transition region f : 500 Hz Sampling frequency f s : 10kHz Passband cutoff frequency f p : 1200 Hz • From filter specifications 20 log(1 p ) 0.01dB, 20log( r ) 40dB, p 0.00115 r 0.01 r p 0.00115 20 log(0.00115) 58.8dB 40/77 • Using Kaiser window – The number of filter order N N A 7.95 58.8 7.95 70.82 14.36F 14.36(500 /10000) N 71 – The ripple parameter 0.1102(58.8 8.7) 5.52 – Normalized cutoff frequency f c 1200 f / 2 1450 Hz f c f c' / f s 1, 450 /10, 000 0.145 41/77 – Calculation of FIR coefficients N 2 f c sin n c 2 hI (n) , 0n N N n c 2 h(n) hI (n) w(n) 42/77 – Symmetrical function h(n) » Calculation of h(0), h(1), , h(35) » Using the symmetry property to obtain the other coefficients 2 0.145 sin(35.5 2 0.145) 35.5 2 0.145 0.00717 n 0 : hI (0) 2 2 n N I0 1 N I (0) w(0) 0 0.023 I0 ( ) I 0 (5.52) h(0) hI (0) w(0) 0.000164935 43/77 n 1: hI (1) 2 0.145 sin(34.5 2 0.145) 34.5 2 0.145 0.0001449 2 69 I 0 5.52 1 71 I (1.3) w(1) 0 0.0337975 I 0 (5.52) I 0 (5.52) h(1) hI (1) w(1) 0.000004897 44/77 n 2 : hI (2) 2 0.145 sin(34.5 2 0.145) 33.5 2 0.145 0.007415484 2 69 I 0 5.52 1 71 I (1.8266) w(2) 0 0.04657999 I 0 (5.52) I 0 (5.52) h(2) hI (2) w(2) 0.000345413 45/77 n 35 : hI (35) 2 0.145 sin(0.5 2 0.145) 0.5 2 0.145 0.280073974 2 1 I 0 5.52 1 71 I (5.51945) w(35) 0 0.999503146 I 0 (5.52) I 0 (5.52) h(35) hI (35)w(35) 0.279934818 46/77 Fig. 7-10. 47/77 Advantages and disadvantages – Simplicity – Lack of flexibility – The passband and stopband edge frequencies cannot be precisely specified – For a given attenuation specification, filter designer must find a suitable window 48/77 The optimal method Basic concepts – Equiripple passband and stopband E ( ) W ( )[ H I ( ) H ()] Weighted Approx. error Weighting function Ideal desired response Practical response min[max E() ] • For linear phase lowpass filters – m+1 or m+2 extrema (minima and maxima) where m=(N+1)/2 (for type1 filters) or m =N/2 (for type2 filters) 49/77 Practical response Ideal response Fig. 7-11. 50/77 Fig. 7-12. 51/77 – The procedure of optimal method • Use the Remez exchange algorithm to find the optimum set of extremal frequencies • Determine the frequency response using the extremal frequencies • Obtain the impulse response coefficients 52/77 Optimal FIR filer design – Transfer function of lowpass filter N H ( z ) h( k ) z k (7-28) k 0 where h(n) h(n) • Symmetric property gives N /2 N /2 k 1 k 0 H ( ) h(0) 2h(k ) cos kT a(k ) cos kT where a (0) h(0) and a(k ) 2h(k ) , k 1, 2, ,N /2 53/77 • Let f / 2 f s T / 2 – f p / fs f p , fr / fs fr – Normalized passband : 0, f p – Normalized stopband : f r ,0.5 • Desired magnitude response 0 f fp 1, HI ( f ) 0, f r f 0.5 (7-30) • Weighting function 1 W f k 1 , , 0 f fp f r f 0.5 (7-31) 54/77 • Find a(k ) with min[max E( f ) ] , k 0,1, 2, , N / 2 H ( f ) H (e j 2 f N /2 ) a (k ) cos k 2 f (7-32) k 0 E ( f ) W ( f )[ H ( f ) H I ( f )] (7-33) where f are 0, f p and f r ,0.5 55/77 – Alternation theorem • Let F 0, f p f r , 0.5 • If E ( f ) has equiripple inside F and exhibit at least m+2 alternations, then H ( f ) HI ( f ) E ( fi ) E ( fi 1 ) e, f0 f1 where fl e i 0,1, , l 1 (7-34) (l m 1) max f 0, f p & f r ,0.5 E( f ) 56/77 • From equation (7-33) and (7-34) W ( fi ) H ( fi ) H I ( fi ) (1)i e, i 0,1, 2, , m 1 (7-35) • From equation (7-32) m a(k ) cos 2 kf k 0 i H I ( fi ) (1)i e , W ( fi ) i 0,1, 2, , m 1 • Matrix form cos 4 f 0 1 cos 2 f 0 1 cos 2 f cos 4 f1 1 1 cos 2 f m cos 4 f m 1 cos 2 f m 1 cos 4 f m 1 cos 2 mf 0 cos 2 mf1 cos 2 mf m cos 2 mf m 1 a (0) H I ( f 0 ) 1/ W ( f1 ) a (1) H I ( f1 ) ( 1) m / W ( f m ) a (m) H I ( f m ) ( 1) m ! / W ( f m 1 ) e H I ( f m 1 ) 1/ W ( f 0 ) 57/77 – Summary Step 1. Select filter length as 2m+1 Step 2. Select m+2 points of f i in F Step 3. Calculate a(k ) and e using equation (7-36) Step 4. Calculate E ( f ) using equation (7-29). If E( f ) e , go to step 5, otherwise go to step 6 Step 5. Determine m local minima or maxima points Step 6. Calculate h(0) a(0), h(k ) a(k ) / 2 , k 1, 2, ,m N H ( z ) h( k ) z k k 0 58/77 Example 7-4 – Specification of desired filter • Filter length : 3 • pT 1[rad], rT 1.2[rad] , k 2 N 2m 1 3 m 1 – Normalized frequency f0 0.5 / 2 , f1 1/ 2 , f 2 1.2 / 2 59/77 • From H I ( f0 ) H I ( f1 ) 1, H I ( f 2 ) 0, W ( f0 ) W ( f1 ) 1/ 2 and W ( f 2 ) 1 1 0.8776 2 a(0) 1 1 0.5403 2 a(1) 1 1 0.3624 1 e 0 a(0) 0.645, a(1) 2.32, e 0.196 H ( f ) 0.645 2.32 cos 2 f (7-37) 60/77 • Selection of new f i f 0 1 2 f1 1.2 2 f 2 0.5 H I ( f 0) 1, H I ( f1) H I ( f 2) 0, W ( f 0) 0.5, and W ( f1) W ( f 2) 1 1 0.5403 2 a(0) 1 1 0.3624 1 a(1) 0 1 1 1 e 0 a(0) 0.144, a(1) 0.45, e 0.306 H ( f ) 0.144 0.45cos 2 f (7-38) – Transfer function of optimal filter H ( z ) 0.225 0.144 z 1 0.225z 2 (7-39) 61/77 Fig. 7-13. 62/77 Optimal method using MATLAB – Based on Park-McClellan and Remez algorithm – Calculation of coefficient for FIR filter using Remez b remez(N,F, M ) b remez(N,F, M, WT ) where N is the filter length F is the normalized frequency band edges M is the magnitude response WT is the relative weight between ripples 63/77 Example 7-5 – Specification of desired filter • Pass band : 0 – 1000Hz • Transition band : 500Hz • Filter length : 45 • Sampling frequency : 10,000Hz – Normalized frequency band edges F [0, 0.2, 0.3, 1] – Magnitude response M [1 1 0 0] 64/77 Table 7-4. 65/77 Fig.7-14. 66/77 Example 7-6 – Specification of desired filter • Pass band : 3kHz – 4kHz • Transition band : 500Hz • Pass band ripple : 1dB • Rejection band attenuation : 25dB • Sampling frequency : 20kHz – Frequency band edges and magnitude response F [2500, 3000, 4000, 4500] M [0 1 0] 67/77 • Estimation of filter length – Pass and rejection band ripples Ap p 10 20 1 Ap 10 20 1 where A p and r 10 Ar 20 Ar are ripples of dB scale in pass and rejection band – Using Remezord in MATLAB 68/77 Table 7-5. 69/77 Fig. 7-15. 70/77 Frequency sampling method Design of FIR filter – Taking N samples of the frequency response at intervals of kFs / N , k 0,1, , N 1 – Filter coefficients h(n) 1 h( n) N where H ( k ), k 0,1, N 1 H ( k )e j (2 / N ) nk (7-40) k 0 , N 1 are samples of desired frequency response 71/77 – Linear phase filters with positive symmetrical impulse response • For N even N2 1 1 h( n) 2 H (k ) cos[2 k (n ) / N ] H (0) N k 1 (7-41) where ( N 1) / 2 • For N odd – Upper limit in the summation is ( N 1) / 2 72/77 Fig. 7-16. 73/77 Example 7-7 1 N /21 (1) Show the h(n) 2 H (k ) cos[2 k (n ) / N ] H (0) N k 1 • From equation (7-40) 1 h( n) N h(n) is real value N 1 H (k ) e j 2 nk / N k 0 N 1 1 N H (k ) e 1 N N 1 H (k ) e 1 N N 1 H (k ) cos[2 k (n ) / N ] j sin[2 k (n ) / N ] 1 N N 1 j 2 k / N e j 2 kn / N k 0 j 2 ( n ) k / N k 0 k 0 H (k ) cos[2 k (n ) / N ] k 0 • h(n) is symmetry 1 N /21 h(n) 2 H (k ) cos[2 k (n ) / N ] H (0) N k 1 (7-42) 74/77 (2) Design of FIR filter • Specification of desired filter – Pass band : 0 – 5kHz – Sampling frequency : 18kHz – Filter length :9 • Selection of frequency samples at intervals of kf s / N 1, H (k ) 0, k 0,1, 2 k 3, 4 Fig. 7-17. 75/77 • Coefficient of FIR filter using equation (7-42) Table 7-6. 76/77 Comparison of the window, optimum and frequency sampling methods Optimal method – Easy and efficient way of computing FIR filter coefficients – Making filter with good amplitude response characteristics for reasonable values of N Window method – In the absence of the optimal software or when the passband and stopband ripples are equal, the window method represents a good choice – Particularly simple method to apply and conceptually easy to understand Frequency sampling method – Filters with arbitrary amplitude-phase response can be easily designed – Lack of precise control for the location of the bandedge frequencies or the passband ripples 77/77
© Copyright 2026 Paperzz