FIR FILTER DESIGN The design of an digital filte is caied out in thee steps: ) Specification: Befoe we can design a filte we must have some specifications. These ae detemined by the application. ) Appoximations We use vaious concepts and mathematics to come up with a filte desciption that appoximates the given set of specifications. 3) Implementation: Using eithe the diffeence equation o the system function H[z] o the impulse esponse h[n] the filte is implemented eithe in hadwae o softwae. In many applications like speech o audio signal pocessing, digital filtes ae used to implement fequency-selective opeations. Theefoe specifications ae equied in the fequency-domain in tems of desied magnitude and phase esponse of the filte. Geneally a linea phase esponse in the passband is desiable. In the case of FIR filtes it is possible to have exact linea phase. In the case of IIR filtes a linea phase in the passband is not achievable. Hence we conside magnitude only specifications. Magnitude specifications ae given in one of two ways. The fist appoach is called absolute specifications, which povide a set of equiements on the magnitude esponse function. This set of specifications ae geneally used fo FIR filtes. The second appoach is called elative specifications, which povide equiements in decibels(db) given by: ( e ) ( e ) H db scale = 0log H This appoach is the most popula one in pactice and is used fo both FIR and IIR filtes. Absolute Specifications: A typical absolute specification of a lowpass filte is shown in figue whee: Band [0,w p ] is called the passband, and is the toleance(o ipple) that we ae willing to accept in the ideal passband esponse Band [w s,π] is called the stopband, and is the coesponding toleance Band [w p, w s ] is called the tansition band, and thee ae no estictions on the magnitude esponse in this band. max 0
H ( e ) + - Passband ipple Tansition band 0 w p w s π Stopband ipple w Figue : Absolute Specifications Relative (db) Specifications: A typical absolute specification of a lowpass filte is shown in figue whee: R p is the passband ipple in db A s is the stopband attenuation in db The paametes given in the two specifications above ae obviously elated. Since H ( e ) max in absolute specifications is equal to (+ ), we have: R p and s = 0log A = 0log > 0 + > 0 +
0 w p w s π w R p A s (db) Figue : Relative specifications Example: In a cetain filte s specifications the passband ipple is 0.5 db and the stopband attenuation is 50dB. Detemine and. R p A s = 0.5 = 0log + = 0.044 = 50 = 0log = 0log + + 0.044 = 0.003 Ealie it was mentioned that a linea phase is desied fo filtes. We ae geneally inteested in linea-phase due to the following advantages:. design poblem contains only eal aithmetic and not complex aithmetic. linea-phase filtes povide no delay distotion and only a fixed amount of delay. 3. fo the filte of length M,ode (M-), the numbe of opeations ae of the ode of M/ as we discussed in the linea-phase filte implementation.
Popeties of Linea Phase FIR Filtes Let h[n], 0<=n<=M-, be the impulse esponse of length M. Then the system function is: H M M n ( M ) [] z = h[] n z = z h[] n n= 0 n= 0 z M n this has (M-) poles at the oigin z=0 and (M-) zeos located anywhee in the z-plane. The Fequency esponse function is : M [ ] = n h[] n e, π < w < π H e n= 0 Fo linea phase thee will be some specific equiements on the foms of h[n] and [ e ] well as the equiement on the locations of (M-) zeos. H as Impulse esponse h[n] We impose a linea-phase constaint H [ e ] = αw π < w π whee α is a constant phase delay. Also the impulse esponse h[n] must be symmetic, that is [] n = h[ M n], h 0 n ( M ) with α = M Thee ae two possıble types of symmety : M odd : In this case α = M is an intege. (!!Show gaphs on boad!!) M even: In this case α = M is not an intege. We also have a second type of linea phase FIR filte if we equie that the phase esponse H e satisfies the condition: [ ] [ e ] = β w H α
which is a staight line but not though the oigin. In this case α is not a constant phase delay, but [ ] = α d H e dw is constant, which is the goup delay. Theefoe α is called a constant goup delay. Fequencies ae delayed at a constant ate. But some fequencies may get delayed moe and othes delayed less. h [] n = h[ M n], 0 n ( M ) M π α =, β = ± This means that the impulse esponse h[n] is antisymmetic. Once again we have two possible types: one fo M odd and one fo M even. Type- Linea-Phase FIR Filtes Symmetical impulse esponse and M odd. In this case = 0 and h( n ) =h( M --n), 0 n M -. Then we can show that ( M-) / H( e ) = a( n) coswn e n=0 whee sequence a( n ) is obtained fom h( n ) as Since then, we have whee H ( ) β, ( ) ( ) - M - / M- a ( 0 ) = h : the middle sample M - M -3 a( n ) =h -n, n ( M-)/ ( ) ( ) H w = a n coswn n=0 α= M - / is an intege, w is an amplitude esponse function and not a magnitude esponse function. function [H,w,a,L]=H_Type(h); % Computes Amplitude esponse H(w)of a Type- LP FIR filte % ----------------------------------------------------------- % [H,w,a,L]=H_Type(h) % H = Amplitude Response % w = 500 fequencies between [0,pi] ove which H is computed % a = Type- LP filte coefficients % L = Ode of H % h = Type- LP filte impulse esponse % M = length(h);
L= (M-)/; a = [h(l+) *h(l:-:)]; % x(l+) ow vecto n = [0::L] % (L+)x column vecto w = [0::500]'*pi/500; H = cos(w*n)*a'; Type- Linea-Phase FIR Filtes Symmetical impulse esponse and M even. In this case = 0 intege, and h( n ) =h( M --n), 0 n M -. Then we can show that whee ( M ) / H( e ) = b( n) cos w n- e n= M M b( n ) = h - n, n =,,..., β, ( ) ( ) - M - / α= M - / is not an Hence, ( M )/ ( ) ( ) cos H w = b n w n- n= whee H ( ) w is an amplitude esponse function. Note that w=π we get ( M )/ H ( w ) = b( n) cos π n- = 0 n= egadless of b( n ) o h( n ). Hence we cannot use this type (i.e. symmetical ( ) even.) fo highpass o bandstop filtes. h n and M Type-3 Linea-Phase FIR Filtes Antisymmetic impulse esponse and M odd. In this case β = π, α= ( M -)/ is an intege, and h( n ) =-h( M --n), 0 n M -, and h( M - ) =0. Then we can show that whee ( M-) / π ( ) H( e ) = c( n) sinwn e n= -j w M - /
M - M - c( n ) = h - n, n =,,..., Hence, ( M-)/ ( ) ( ) H w = c n sinwn n= Note that at w=0 and w=π we have H ( w ) = 0, egadless of c( n ) o ( ) jπ Futhemoe, e = j, which means that jh ( ) h n. w is puely imaginay. Hence this type of filte is not suitable fo designing a lowpass o a highpass filte. Howeve, this behavio is suitable fo appoximating ideal Hilbet tansfomes and diffeentiatos. function [H,w,c,L]=H_Type3(h); % Computes Amplitude esponse H(w) of a Type-3 LP FIR filte % ----------------------------------------------------------- % [H,w,c,L]=H_Type3(h) % H = Amplitude Response % w = fequencies between [0,pi] ove which H is computed % b = Type-3 LP filte coefficients % L = Ode of H % h = Type-3 LP filte impulse esponse % M = length(h); L = (M-)/; c = [*h(l+:-:)]; n = [0::L]; w = [0::500]'*pi/500; H = sin(w*n)*c'; Type-4 Linea-Phase FIR Filtes Antisymmetic impulse esponse and M even. This case is simila to Type-. We have whee ( M )/ π ( ) H( e ) = d( n) sin w n- e n= j w M- / M M d ( n ) = h - n, n =,,..., and ( M )/ ( ) ( ) sin H w = d n w n- n= Note that at w=0 and w=π we have ( ) = 0 H 0 and e jπ = j. Hence, this type is also suitable fo designing digital Hilbet tansfomes and diffeentiatos.
Estimation of the Kaise Filte Ode: Fo the design of an FIR lowpass digital filtes, fomulas fo estimating the minimum value of the filte length N diectly fom the specifications exist. Given the nomalized passband edge fequency w p and stopband edge fequency w s, peak passband ipple and peak stopband ipple, Kaise has developped the fomulas below: N N N ( ) 0log 3 = 4.6 / π ( w w ) s p ( ) 0log + 0. = / π ( w w ) s p ( ) 0log = 7 ( w w ) s p + 5.94 / π fo FIR fo FIR fo FIR filtes with modeate passband widths filtes with naow passband widths filtes with wide bands Example: Estimate the length of a linea-phase FIR tansfe function with the following specifications : Passband edge = 80 Hz Stopband edge = 00 Hz Passband ipple p = 0.00 Stopband ipple s = 0.00 Sampling ate is = khz.
We can use a MATLAB pogam to answe this poblem. % Computation of the length of a linea-phase FIR lowpass filte using Kaise s fomula Rp = input ( Type in the passband ipple = ) Rs = input ( Type in the stopband ipple = ) Fp = input ( Type in passband edge in Hz = ) Fs = input ( Type in stopband edge in Hz = ) FT = input ( Type in the sampling fequency ın Hz = ) Num = -0*log(sqt(Rp*Rs))-3; Den = 4.6 * (Fs-Fp)/FT; N = ceil(num/den); fpintf( Filte Length is %f \n, N ); The ode of the FIR filte, which is of length minus one can also be detemined using the MATLAB function emezod. Thee ae two usages of this function: od = filte ode f = nomalized fequency band-edge vecto m = fequency band magnitude vecto wgt = weight vecto fedge = band edges dev = maximum allowable deviation [od, f, m, wgt] = emezod (fedge, mag, dev ) [od, f, m, wgt] = emezod (fedge,mag, dev, FT ) Length of fedge is (two times that of mag) - The output data can then be diectly used in the filte design (used fo equi-ipple FIR filte design )
Example: Estimate the length of a linea-phase FIR tansfe function with the specifications f p = 80 Hz f s =00 Hz p = 0.00 s = 0.00 FT = khz. % Estimation of the FIR filte ode using emezod fedge = input( Type in the bandedges= ) mag = input( Desied magnitude values in each band= ) dev = input ( Allowable deviation in each band= ) FT = input( Type in the sampling fequency= ) [od, f0, m0, wgt]= emezod (fedge, mag, dev, FT) fpintf( Filte ode is %f \n,od ) fo example : fedge = [80 00 ] mag = [ 0 ] dev = [0.00 0.00 ] FT = 00 Ode of filte = 87 B = Remez (N,F,A) Will etun a length N+ linea-phase (eal, symmetic coefficients)