Transcription of Design of Digital Filters
1 Chapter8 DesignofDigitalFiltersContentsOverview.. ltersusingwindows.. (90 phaseshift).. ltersbyfrequency sampling.. Optimum equiripplelinear-phaseFIR lters.. lterdesignbybilineartransformation.. Transformations.. J. Fessler, May27,2004,13:18(studentversion) nallyhave lters,so,at leastforLTIsystems,to Design a systemmeanstodesigna Digital lter.(Thedesignofnonlinearortime-varying systemsis generallymorecomplicated,andoftenmorecas especi c.)Goal:givendesired magnituderesponsejHd(!)j phaseresponse\Hd(!) tolerancespeci cations(how farfromideal?),wewanttochoosethe lterparametersN,M,fakg,fbkgsuchthatthesy stemfunctionH(z) =PMk=0bkz 1 PNk=0akz 1=gQi(z zi)Qj(z pj);wherea0= 1, yieldsa frequency responseH(!) Hd(!).RationalH(z), soLTIsystemdescribedbya constant-coef cientdifferenceequation,socanbeimplement edwith nite# ofadds,multiplies, , lterdesignmeanschoosingthenumberandlocat ionsofthezerosandpoles,orequivalentlythe numberandvaluesofthe ltercoef cients,andthusH(z),h[n],H(!)
2 Overview N= 0, N >0, IdeallywouldlikeNandMorN+Mtobeassmallasp ossibleforminimalcomputation/ storage. Causal(fornow) willfocusondesigningcausaldigital lters, lterdesign( , foroff-lineapplications)is mucheasierandmany causaliff input/outputrelationship:y[n]dependsonly oncurrentandpastinputsignalvalues. impulseresponse:h[n] = 0forn <0 systemfunction:numberof nitezeros numberof nitepoles frequency response:Whatcanwe say aboutH(!)?Fact:ifh[n]is causal,then Paley-WienerTheorem:H(!)cannotbeexactlyz eroover anybandoffrequencies.(Exceptin thetrivialcasewhereh[n] = 0.) Furthermore,jH(!)jcannotbe at(constant)overany niteband. HR(!)andHI(!)areHilberttransformpairs. Thereforethey lterswith nitebandsofzeroresponsecannotbeimplement edwitha causal ,wemustdesign ltersthatapproximatethedesiredfrequency responseHd(!).c J. Fessler, May27,2004,13:18(studentversion) ltersNoperfectly atregionsFact:sincecausal lterscannothave a bandoffrequencieswithzeroresponse,norcan they haveanybandoffrequenciesoverwhichthefreq uency responseis a (!)
3 =cfor!1 ! !2, withcorrespondingimpulseresponseh[n]. Now de nea new lterg[n] =h[n] c [n]. Thencertainlyg[n]is (!) =H(!) c= 0for!1 ! !2, whichis impossibleifg[n]is causal. Causal lterscannothave a have anin have perfectly typicalrealisticmagnituderesponselooksli ke RipplePassbandStopband1 Transition BandPassband RipplePSfragreplacements1 + 11 1!p!s 2!jH(!)jPractical lterdesignmeanschoosing 1, 2,!cand!s, andthendesigningN,M,fakg, (!)jusingdB, ,20 log10jH(!)j, notde nedpeak-to-peak, sincethehighestmagnituderesponseinthesto pbandis moreimportantthanhow wigglytheresponseis :CDdigitalcrossoverSeparatewooferandtwee tersignalsdigitallyinsideCDplayer, ratherinanalogat is passbandrippletolerableinthiscontext(dis tortion)?Roomacousticsactasanother lter. Speakerresponseis notperfectly lterripplebelow imaginethatwehave speci ed 1, 2,!cand!s, andwewishtodesignN,M,fakg, , wehave two focus J. Fessler, May27,2004,13:18(studentversion) lteroflengthMis anLTIsystemwiththefollowingdifferenceequ ation1:y[n] =M 1Xk=0bkx[n k] , whendiscussingrationalsystemfunctions, thenumberof nonzero elementsofh[n], whichcorrespondstoatmostM 1zeros.
4 (Moreprecisely, weassumebM 16= 0andb06= 0, butsomeofthecoef cientsinbetweencouldbezero.)Theproblem:g iven 1, 2,!c, and!s, wewishtochooseMandfbkgM 1k=0toachieve focusonlinear-phaseFIR lters,becauseif linearphaseis notneeded,thenIIRis focusonlowpass lters,sincetransformationscanbemadetofor mhighpass,bandpassfromlowpass, lterh[n] = bn; n= 0; : : : ; M 10;otherwise:Soratherthanwritingeverythi ngintermsofbk's, wewriteit directlyintermsoftheimpulseresponseh[n]. Infact,forFIR lterdesignweusuallydesignh[n]directly, ratherthanstartingfroma pole-zeroplot.(Anexceptionwouldbenotch lters.) ltersI :H(z) =M 1Xn=0h[n]z n:How dowemake a lterhavelinearphase?We weexamineit lterhaslinearphaseifh[n] =h[M 1 n]; n= 0;1; : : : ; M 5:h[n] =fb0; b1; b2; b1; b0g:SuchanFIR lteris calledsymmetric. Caution:thisis not evensymmetry related, ForM= 3andh[n] =n1=2;1;1= lterhave linearphase?Is it lowpassorhighpass?H(!) =12+ e |!+12e |2!= e |! 12e|!+ 1 +12e |!
5 = e |!(1 + cos!);sosince1 + cos! 0,\H(!) = !;whichis worksforthisparticularexample,butwhy doesthesymmetryconditionensurelinearphas eingeneral? 1k=0apparently. ThisinconsistentwithMATLAB, sothereare M 1 thinkthatMATLABis J. Fessler, May27,2004,13:18(studentversion) lters,h[n] =h[M 1 n]; n= 0; : : : ; M 1, even:H(z) =M 1Xn=0h[n]z n=M=2 1Xn=0h[n]z n+M 1Xn=M=2h[n]z n(splitsum)=M=2 1Xn=0h[n]z n+M=2 1Xn0=0h[M 1 n0]z (M 1 n0)(n0=M 1 n)=M=2 1Xn=0h[n]z n+M=2 1Xn=0h[n]z (M 1 n)(symmetryofh[n])=M=2 1Xn=0h[n]hz n+z (M 1 n)i(combine)=z (M 1)=2M=2 1Xn=0h[n]hz(M 1)=2 n+z ((M 1)=2 n)i(splitphase).Thusthefrequency responseisH(!) =H(z) z=e|!= e |!(M 1)=2M=2 1Xn=0h[n]he|!((M 1)=2 n)+ e |!((M 1)=2 n)i= 2 e |!(M 1)=2M=2 1Xn=0h[n] cos ! M 12 n =e |!(M 1)=2Hr(!)Hr(!) = 2M=2 1Xn=0h[n] cos ! M 12 n :(Realsinceh[n]is real.)Phaseresponse:\H(!) = !M 12;Hr(!)>0 !M 12+ ;Hr(!)<0:ThecaseforModdis similar, andleadstothesamephaseresponsebutwitha slightlydifferentHr(!)
6 J. Fessler, May27,2004,13:18(studentversion)Infact,t heoddMcaseis eveneasierbynotingthath[n+ (M 1)=2]is anevenfunction,soitsDTFTis real,sotheDTFTofh[n]ise |!(M 1)=2timesa (M 1)=2is (We wanttobeabletorecognizeFIRlinear-phase ltersfrompole-zeroplot.)Fromabove,H(z) =z (M 1)=2PM=2 1n=0h[n] z(M 1)=2 n+z ((M 1)=2 n) soH z 1 =z(M 1)=2PM=2 1n=0h[n] z (M 1)=2 n+z((M 1)=2 n) =zM 1H(z):ThusH(z) =z (M 1)H z 1 :Soifqis a zeroofH(z), then1=qis alsoa zeroofH(z). Furthermore,intheusualcasewhereh[n]is real,ifqis a zeroofH(z),thensoisq .Example. Herearetwo pole-zeroplotsofsuchlinear-phase (z)Im(z)2r1rRe(z)Im(z)4 Whatis differencebetweenthisandall-pass lter?It waspolesandzerosinreciprocalrelationship sforall-pass weknow conditionsforFIR dowedesignone?DelaysIncontinuoustime,the delaypropertyoftheLaplacetransformisxa(t )L$e s Xa(s):How dowe builda circuitthatdelaysa signal?Sincee s is nota rationalfunction,soit timedelaysystemis anLTIsystem,wecannotbuildit usingRLCcomponents!
7 We canmake anapproximation, ,e s 1 s +12s2 2whichisrationalins, , wecanusemoremechanicalapproachestodelayl ike a write,read, / torelyonsignalpropagationtimedowna longwire,andtapintothewireat discretetime?We justneeda digitallatchorbuffer( ip ops)toholdthebitsrepresentinga J. Fessler, May27,2004,13:18(studentversion) ltersusingwindowsPerhapsthesimplestappro achtoFIR lterdesignistotake theidealimpulseresponsehd[n]andtruncatei t,whichmeansmultiplyingit bya rectangularwindow, ormoregenerally, tomultiplyhd[n]bysomeotherwindow function,wherehd[n] =12 Z Hd(!) e|!nd! :Typicallyhd[n]willbenoncausalorat Asshownpreviously, ifHd(!) = 1;j!j !c;0;otherwise;= rect !2!c thenhd[n] =!c sinc !c n :We cancreateanFIR lterbywindowingtheidealresponse:h[n] =w[n]hd[n] = hd[n]w[n]; n= 0; : : : ; M 10;otherwise;wherethewindow functionw[n]is nonzeroonlyforn= 0; : : : ; M theeffectonthefrequencyresponse?W(!) =M 1Xn=0w[n] e |!nandbytime-domainmultiplicationpropert yofDTFT, akathewindowingtheorem:H(!)
8 =W(!) 2 Hd(!) =12 Z Hd( )W(! ) d ;(8-1)where 2 denotes2 ,theidealfrequency responseHd(!)issmearedoutbythefrequency responseW(!)ofthewindow ideal window be?W(!) = 2 (!) =P1k= 12 (! 2 k);a window wouldcausenosmearingoftheidealfrequency , thecorresponding window functionwouldbew[n] = 1, whichis [n] = 1; n= 0; : : : ;20;otherwise;withHd(!) = e |!2 rect ! , ,!c= = :hd[n] = sinc 12(n 1 )andh[n] =nsinc 12 ;1;sinc 12 owheresinc 12 = 2= 0 responseisH(!) = e |! 1 +4 cos(!) :PictureThisis onlya J. Fessler, May27,2004,13:18(studentversion) [n] = 1; n= 0; : : : ; M 10;otherwise;W(!) =M 1Xn=0e |!n= = e |!(M 1)=2Wr(!);whereWr(!) =8<:sin(!M=2)sin(!=2); !6= 0M;!= 0:Inthiscasetheidealfrequency responseis smearedoutbya sinc-like function,becauseWr(!) Msinc M!2 :Thefunctionsin(!M=2)Msin(!=2)is muchis theidealfrequency responsesmearedout? ThewidthofthemainlobeofW(!)is 4 =M, becausethe rstzerosofWr(!)areat!= 2 =M. AsMincreases,widthofmainlobeW(!)
9 Decreases, Hereis thecase!c= = [n]Rectangular Window-p 0 (w) / MWindow Response-p 0 |H(w)|Magnitude [n]Rectangular Window-p 0 (w) / MWindow Response-p 0 |H(w)|Magnitude ResponseHow didI make these gures?UsingH = freqz(h,1, om)sinceb = hforcausalFIR J. Fessler, May27,2004,13:18(studentversion) |!(M 1)=2inW(!)above comesfromthefactthattherectangularwindow is notcenteredaroundn= 0, butratheris time-shiftedtobecenteredaroundn= (M 1)=2. Thisphasetermwillcauseadditionaldistorti onofHd(!), unlessHd(!) lowpass lterwithcutoff!c, windowedbya length-Mwindow function,theappropriatedesiredresponseis :Hd(!) = e |!(M 1)=2;j!j !c;0;otherwise;=) jHd(!)j= 1;j!j !c;0;otherwise;sothathd[n] =!c sinc !c n M 12 :Thisis illustratedbelow. Notethatfrom(8-1),H(!) =12 Z Hd( )W(! ) d =12 Z!c !ce | (M 1)=2e |(! )(M 1)=2sin((! )M=2)sin((! )=2)d = e |!(M 1)=212 Z!c !csin((! )M=2)sin((! )=2)d :Thusthereis anoveralldelayof(M 1)=2samplesfromsucha length-McausalFIR ,theconvolutionintegralis severelyaffectedAudioapplication,Fs= 44kHzandsayM= 45.
10 Thedelayin samplesis(M 1)=2 = 22. ThetimedelayisM 12T=22=44kHz= about330meters/ second, 0 Frequency ResponseHd(w) 20 1001020 [n]Ideal Impulse 20 1001020 [n]Causal FIR filter 1-p 0 Response 1|H(w)| 20 1001020 [n]Causal FIR filter 2 Shiftedby (M 1)/2-p 0 |H(w)|Magnitude Response J. Fessler, May27,2004,13:18(studentversion)Sidelobe sTherectangularwindow hashighsidelobesinW(!), and thesidelobeamplitudeis relativelyunaffectedbyM. Sidelobescauselargepassbandripple,relate dtoGibbsphenomena. Sidelobescausedbyabruptdiscontinuityat :usesomeotherwindow function. Examples:Bartlett,Blackman,Hanning,Hammi ng,Kaiser, Lanczos,Tukey. MATLAB'swindowfunctionhas16choices! Allhave lowersidelobesthanrectangular, hencelesspassbandripple. Tradeoff? :w[n] =12 1 cos2 nM 1 :Whatis thefrequency responseW(!)? dowe plotW(!)?W = freqz(w,1, om)whichinturnusestheDFT/FFTwithN :thisis thehannfunctioninMATLAB, notthehanningfunction! [n]Rectangular WindowM=9-p 0 p-80-32-130|W(w)| / |W(0)| (dB)Norm.