firfir1fir2fir2firfir3EECS 451 FIR FILTER DESIGN AND EXAMPLESFIR: Finite Impulse Response: h[n] has finite duration. All poles at origin.MA: Moving Average filter: y[n]=b0x[n]+b1x[n-1]+. . .+bNx[n-N] (order=N).Why? Always stable; add delay to make causal; easy to design (see below).LINEARPHASE:TYPE FORM OF h[n] APPLICATION RESTRICTIONI {b, a, c, a, b} Low or highpass NoneII {b, a, a, b} Lowpass only H(ejπ) = 0III {b, a, 0, −a, −b} Differentiator H(ej0) = H(ejπ) = 0IV {b, a, −a, −b} Differentiator H(ej0) = 0Why? No phase distortion (just time delay); affects only Fourier magnitudes.Zeros: Complex conjugate reciprocal quadruples: {zo, z∗o,1zo,1z∗o}. Coincide?THREE FIR FILTER DESIGN TECHNIQUESWINDOWDESIGN: h[n]= hIDEAL[n]w[n] for some data window (e.g., Hamming) w[n].Example: Design a 5-point digital differentiator using a rectangular window.hIDEAL[n] =12πRπ−π(jω)ejωndω=(−1)nn={. . . −12, 1, 0, −1,12. . .}.IMAGODD→REALEVEN.Solution: h[n] = {−12, 1, 0, −1,12} → y[n]=–12x[n+2]+x[n+1]–x[n-1]+12x[n-2].Matlab: h=fir1(N-1,W,’ftype’,window); W=vector of passband cutoffs.FREQUENCYSAMPLING: SolvePN−1n=0h[n]e−jωkn= HDESIRED(ejωk) for some frequencies ωk.Example: Design a 5-point digital lowpass filter using fr equency sa mpling.Constraints: Type I filter. H(ej0) = 1. H(ejπ/2) = 3/4. H(ejπ) = 0. (Lowpass)Solution: h[n]={a, b, c, b, a}. H(ejω)=c+2bcos(ω)+2acos(2ω)=DTFT{h[n]}.ω = 0: c+2b+2a=1. ω = π: c–2b+2a=0. ω = π/2: c–2 a=3/4.Answer: Solving gives: h[n]={a, b, c, b, a}={−116,14,58,14, −116}.Alternate: ifft([1 3/4 0 3/4])=[5/8 1/4 -1/8 1/4]=aliased h[n]:116+116=18.Matlab: h=fir2(N-1,F,M,window) where M=magnitudes at frequencies=F.EQUI−:RIPPLEMINh[n]MAXω|E(ejω)|W (ejω)=MINh[n]MAXωW (ejω)|HD(ejω)−PN−1n=0h[n]e−jωn|Huh? Minimize largest error: No frequency far off. Worst case m inimized.Solution: Iterative algorithm using Remez exchange and alternation theorems.Matlab: h=firpm(N-1,F,M,weights,ftype) M=magnitudes at frequencies=F.where: F=vector ofωπ: Maximum frequency ω=π → F =1. F includes 0,1.EECS 451 FIR FILTER DESIGN EXAMPLESGoal: Design a 7-point digital differentiator using:(a) Rectangular window; (b) Hamming window;(c) Frequency sampling; (d) Inverse DFT.(a),(b) h[n]=hIDEAL[n]w[n]wherew[n]=the window and:hIDEAL[n]=inverse DTFT of HDESIRED(ejω).Here: HDESIRED(ejω)=jω for |ω| <πsince Ha(jΩ)=jΩ.Then: hIDEAL[n]=12ππ−π(jω)ejωndω=(−1)nn.Also,hIDEAL[0]=0.hIDEAL[n]={...15, −14,13, −12, 1, 0, −1,12, −13,14, −15...}Note: HDESIRED(ejω) imaginary and odd⇔ hIDEAL[n] real and odd.(a) w[n]={...0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0 ...} (7-point rectangular window).h[n]=hIDEAL[n]w[n]={13, −12, 1, 0, −1,12, −13}.(b) w[n]=0.54+0.46cos(πn3), |n|≤3={.08,.31,.77, 1,.77,.31,.08}.Note: w[n]goesfrom 0to6:Usew[n ]=0.54 – 0.46cos(πn3).Here: w[n]goesfrom–3to3:Usew[n]=0.54+0.46cos(πn3).h[n]=hIDEAL[n]w[n]={.083, −.312, 0.77, 0, −0.77,.312, −.083}.h[n]={0.0267, −0.155, 0.77, 0, −0.77, 0.155, −0.0267}.(c) Solve3n=−3h[n]e−jωn=jω for 7 values of ω from −π to +π:ω=2πk7, |k|≤3={−67π, −47π, −27π, 0,27π,47π,67π}.Useh[−n]=−h[n].Note: Don’t include ±π : H(ejω) is discontinuous at ±π! Jumps jπ to −jπ.Then:3n=−3h[n]e−jωn=3n=1(h[−n]ejωn+h[n]e−jωn)=3n=1h[n](e−jωn− ejωn)=−2j3n=1h[n]sin(ωn)=jω.−2sin(27π)sin(47π)sin(67π)sin(47π)sin(87π)sin(127π)sin(67π)sin(127π)sin(187π)h[1]h[2]h[3]=27π47π67π.This has the solution h[1]=–1.03; h[2]=0.574;h[3]=–0.46 usingA=-2*sin(pi/7*2*[1 2 3]’*[1 2 3]);B=pi/7*2*[1 2 3]’;A\BThen h[n]={0.46, −0.574, 1.03, 0, −1.03, 0.574, −0.46}.(d) Take the periodic extension of h[n]:{...h[−3],h[−2],h[−1],h[0],h[1],h[2],h[3],h[−3],h[−2],h[−1],h[0] ...}This has DTFS hk=173n=−3h[n]e−j2πnk/7(use any period of h [n]).But: This is what we get setting ω=2πk7, |k|≤3in3n=−3h[n]e−jωn.So:3n=−3h[n]e−jωn=jω, |ω|=2πk7=⇔ 7hk=2πk7, |k|≤3.DFT: Hk=7−1n=0h[n]e−j2πnk/7=7hkfor k=0,1,2,3,4,5,6.where: hk=hk−7for k =4, 5, 6. So use {h0,h1,h2,h3,h−3,h−2,h−1}.So: real(ifft(j*pi/7*[0 2 4 6 -6 -4 -2]))Gives: [0,-1.03,0.574,-0.46,0.46,-0.574,1.03]This is:
View Full Document