• No results found

ELEN E4810: Digital Signal Processing Topic 9: Filter Design: FIR. 1. Windowed Impulse Response 2. Window Shapes 3. Design by Iterative Optimization

N/A
N/A
Protected

Academic year: 2021

Share "ELEN E4810: Digital Signal Processing Topic 9: Filter Design: FIR. 1. Windowed Impulse Response 2. Window Shapes 3. Design by Iterative Optimization"

Copied!
30
0
0

Loading.... (view fulltext now)

Full text

(1)ELEN E4810: Digital Signal Processing. Topic 9: Filter Design: FIR 1. Windowed Impulse Response 2. Window Shapes 3. Design by Iterative Optimization. Dan Ellis. 2012-11-19. 1.

(2) 1. FIR Filter Design . FIR filters  . . no poles (just zeros) no precedent in analog filter design. Approaches  . Dan Ellis. windowing ideal impulse response iterative (computer-aided) design. 2012-11-19. 2.

(3) Least Integral-Squared Error . Given desired FR Hd(ej!), what is the best finite ht[n] to approximate it?. best in what sense? . Can try to minimize Integral Squared Error (ISE) of frequency responses:. =. 1 2.   H d (e )  H t (e ) . j. j 2. d. = DTFT{ht[n]} Dan Ellis. 2012-11-19. 3.

(4) Least Integral-Squared Error . . Ideal IR is hd[n] = IDTFT{Hd(ej!)}, (usually infinite-extent) .  hd [n]  ht [n]. By Parseval, ISE  =. 2. n= . But: ht[n] only exists for n = -M..M ,  =. M. hd [ n]  ht [ n]  n =M. minimized by making ht[n] = hd[n], -M ≤ n ≤ M Dan Ellis. 2012-11-19. 2. +. hd [n]  n< M , n> M. 2. not altered by ht[n] 4.

(5) Least Integral-Squared Error . Thus, minimum mean-squared error approximation in 2M+1 point FIR is truncated IDTFT:. ht [n] = . 1 2. Hd (ej )ej. n. d. M n otherwise. 0. Make causal by delaying by M points → h′t[n] = 0 for n < 0 zero. ht[n]. h't[n]. n. n –M. Dan Ellis. M. 0. 2012-11-19. M. 2M. 5. M.

(6) Approximating Ideal Filters . From topic 6, ideal lowpass has:. 1 0. HLP (e ) = j. and: hLP [n] =. sin. −º. n. !c. º. | |< c c <| |<. h[n]. cn. −!c. !. 0.2. 0.15 0.1 0.05 0. (doubly infinite) Dan Ellis. -0.05 -20. -15. 2012-11-19. -10. -5. 0. 5. 10. 6. 15. n.

(7) Approximating Ideal Filters Thus, minimum ISE causal approximation to an ideal lowpass. ˆ LP [n] = h Causal shift. sin. c (n. M) (n M ). 0. 0 hLP[n]. . n. 2M. otherwise. 1.2 1 0.8 0.6 0.4 0.2 0 -0.2. 0. 5. 10. 15. 20. 25. 2M+1 points Dan Ellis. 2012-11-19. 7. n.

(8) Gibbs Phenomenon Truncated ideal filters have Gibbs’ Ears:. Increasing filter length → narrower ears (reduces ISE) but height the same. Ht(ejW). . 1.2. Gibbs ‘ears’. 1. (~9% overshoot). 0.8 0.6 0.4. → not optimal by minimax criterion. 0 -0.2. Dan Ellis. 129 point. 0.2. 0. 0.2. 2012-11-19. 25 point. 0.4. 0.6. 0.8. 8. WP.

(9) Where Gibbs comes from . Truncation of hd[n] to 2M+1 points is multiplication by a rectangular window:. ht [n] = hd [n] · wR [n] wR [n] = . 1 0. M n otherwise. h[n]. 0.2. 0.15. M. wR[n]. 0.1 0.05 0 -0.05 -20. -15. -10. -5. 0. 5. 10. Multiplication in time domain is convolution in frequency domain: g[n] · h[n]. Dan Ellis. 1 2. G(ej )H(ej( 2012-11-19. ). )d 9. 15. n.

(10) Where Gibbs comes from . Thus, FR of truncated response is convolution of ideal FR and FR of rectangular window (pd.sinc):. P. P. Hd(ej!). Dan Ellis. W.  P. P. DTFT{wR[n]} periodic sinc... sin Nx sin x 2012-11-19. W. P. W. P. Ht(ej!). convanim.mp4. 10.

(11) Where Gibbs comes from . Rectangular window: 1 0. wR [n] = . . M n otherwise. WR (e ) =. M. =. Mainlobe width ( / 1/L) determines transition band Sidelobe height determines ripples. WR(ejW) Mainlobe pP 2M + 1. Sidelobes. 0. ≈ invariant with length. Dan Ellis. M j n e n= M sin(2M +1) 2 sin 2. j. -P. -0.5P. 0. 0.5P. “periodic sinc” 2012-11-19. 11. P. W.

(12) 2. Window Shapes for Filters .  . Windowing (infinite) ideal response → FIR filter: ht [n] = hd [n]  w[n] Rectangular window has best ISE error Other “tapered windows” vary in:  . . mainlobe → transition band width sidelobes → size of ripples near transition. Variety of ‘classic’ windows.... Dan Ellis. 2012-11-19. 12.

(13) Window Shapes for FIR Filters Rectangular: w[n] = 1 M  n  M . Hann: 0.5 + 0.5 cos(2 2Mn +1)  Hamming: 0.54 + 0.46 cos(2 2Mn +1)  Blackman: 0.42 + 0.5 cos(2 2Mn +1) +0.08 cos(2 2M2n+1) . Dan Ellis. 20. 1. big sidelobes!. 15 10. 0.5. 5 0. -10. -5. 0. 5. 10. n. 0. 0. 8. 1. 0.4. 0.6. 0.8. PW. double width mainlobe. 6 4. 0.5. 0.2. 2 0. -10. -5. 0. 5. 10. n. 0. 0. 8. 1. 4 2. 0. -10. -5. 0. 5. 10. n. 0. 0. 8. 1. 0.6. 0.8. PW. 0.2. 0.4. 0.6. 0.8. PW. triple width mainlobe. 6 4. 0.5. 0.4. reduced 1st sidelobe. 6 0.5. 0.2. 2 0. -10. -5. 2012-11-19. 0. 5. 10. n. 0. 0. 0.2. 0.4. 13. 0.6. 0.8. PW.

(14) Window Shapes for FIR Filters Comparison on dB scale: \W(ejW)\ / dB. . 0. Blackman Hann. -10. Rectangular. -20. -30. -40. -50. Hamming -60. -70. -80. Dan Ellis. 2º 2M+1 0. 0.1. 0.2. 0.3. 0.4. 0.5. 0.6. 2012-11-19. 0.7. 0.8. 0.9. W. P. 14.

(15) Adjustable Windows So far, discrete main-sidelobe tradeoffs..  Kaiser window = parametric, continuous tradeoff: I0  1  ( Mn )2 M  n  M modified zero-order w[n] = I0 ( ) Bessel function  Empirically, for min. SB atten. of Æ dB: . (. =. 0.11( 0.58( 0 Dan Ellis. 8.7) 21)0.4 + 0.08(. 21). ). > 50 21 < 21. 2012-11-19. required order. 50. N=. 8 2.3. transition width 15.

(16) Windowed Filter Example . . . Design a 25 point FIR low-pass filter with a cutoff of 600 Hz (SR = 8 kHz) No specific transition/ripple req’s → compromise: use Hamming window Convert the frequency to radians/ 600  2 = 0.15 sample:  c = 8000 H(ej!) 0.15 º 600 Hz. Dan Ellis. º 4 kHz 2012-11-19. !. 2º 8 kHz (fs) 16.

(17) Windowed Filter Example Get ideal filter impulse response: n  c = 0.15  hd [n] = sin 0.15 n 2. Get window: Hamming @ N = 25 → M = 12 (N = 2M+1)  w[n] = 0.54 + 0.46 cos(2 25n ) 12  n  12 3. Apply window: h[n] 1.. 0.15. 0.1. h[n] = hd [n]  w[n]. 0.05 0 -20. -10. 0. n. 10. n 0.54 + 0.46 cos 2 n = sin 0.15 12  n  12 ( n 25 ) Dan Ellis. 2012-11-19. 17. M.

(18) Freq. Resp. (FR) Arithmetic. wouldn’t work if phases were nonzero!. . Ideal LPF has pure-real FR i.e. µ(!) = 0, H(ej!) = |H(ej!)|. → Can build piecewise-constant FRs by combining ideal responses, e.g. HPF: 1. !. + 0 -1. ! =. 1. −º Dan Ellis. −!c. !c. º. ! 2012-11-19. ±[n] +. i.e. H(ej!) = 1 HLP(ej!) = 1 for |!| < !c. -hLP[n] = hHP[n] = ±[n] - (sin!cn)/ºn 18.

(19) 3. Iterative FIR Filter Design . . Can derive filter coefficients by iterative optimization: Filter coefs h[n]. Goodness of fit criterion → error ". Update filter to reduce ". Estimate derivatives ∂"/∂h[n]. Desired response H(ej!). Gradient descent / nonlinear optimiz’n. Dan Ellis. 2012-11-19. 19.

(20) Error Criteria p j j  =  R W ( )  [D(e )  H (e )] d error measurement error actual desired region weighting response response. exponent: 2 → least sq ∞ → minimax. R H(ejW) W1 W(W) E(W) Dan Ellis. W2 W3. D(ejW) W4. W W W = W(!)·[D(ej!) – H(ej!)]. 2012-11-19. 20.

(21) Minimax FIR Filters . Iterative design of FIR filters with:  . . equiripple (minimax criterion) linear-phase → symmetric IR h[n] = (–)h[-n]. (type I order 2M). n. M. Recall: symmetric FIR filters have FR j  jM ˜ H e =e H ( ) with pure-real M a[0] = h[M] ˜ H ( ) =  a[k ] cos(k ). ( ). k=0. a[k] = 2h[M - k]. i.e. combo of cosines of multiples of ! Dan Ellis. 2012-11-19. 21.

(22) Minimax FIR Filters . k=0. Now, cos(k!) can be expressed as a polynomial in cos(!)k and lower powers . . M ˜ H ( ) =  a[k ] cos(k ). e.g. cos(2!) = 2(cos!)2 - 1. Thus, we can find Æs such that. ˜ H(⇥) =. M. M. a[k]cos(k⇥) = k=0. . Dan Ellis. [k](cos⇥). k. k=0. Mth order polynomial in cos!. Æ[k]s easily lead to a[k]s 2012-11-19. 22.

(23) Minimax FIR Filters M k M order ˜ H ( ) =   [k ](cos  ) polynomial in cos! k=0 th. . An Mth order polynomial has at most M - 1 maxima and minima: M. ˜ ) H(. [k](cos )k. cosW. k=0 0.2. 5th order 0.1 polynomial 0 in cos! -0.1. 0.2 0.1. 3. 3. 2. 4. -1. W. 0. cosW. 2. 4. -0.1. -0.2. WP. 1. 1. -0.2 -0.5. 0. 0.5. 1. W. 0. 0.2. 0.4. 0.6. 0.8. P.  H˜ ( ) has at most M-1 min/max (ripples) Dan Ellis. 2012-11-19. 23.

(24) Alternation Theorem . Key ingredient to Parks-McClellan: H˜ ( ) is the unique, best, weightedminimax order 2M approx. to D(ej!) ˜ ( ) has at least M+2 “extremal” freqs  H  0 < 1 < ... <  M <  M +1 over ! subset R . error magnitude is equal at each extremal:. . peak error alternates in sign:.  ( i ) =  i.  ( i ) =  ( i+1 ). Dan Ellis. 2012-11-19. 24.

(25) Alternation Theorem . Hence, for a frequency response: D(ejW) desired frq.resp.. 1 0.8. . If "(!) reaches a peak error magnitude " at some set of extremal frequences !i. . And the sign of the peak error alternates And we have at least M+2 of them Then optimal minimax. H(ejW) response mag.. 0.6 0.4. E scaled error. W(W). 0.2. bound. W. 0. Wp. 0. Wc. P. band-edge extrema. E. E(W) error 0. . -E. W0. W1 W2. W3W4 W5. W6. local min/max extrema. . (10th order filter, M = 5) Dan Ellis. 2012-11-19. 25.

(26) Alternation Theorem . . By Alternation Theorem, M+2 extrema of alternating signs optimal minimax filter But H˜ ( ) has at most M-1 extrema need at least 3 more from band edges. . 2 bands give 4 band edges can afford to “miss” only one. . Alternation rules out transition band edges, thus have 1 or 2 outer edges. Dan Ellis. 2012-11-19. 26.

(27) Alternation Theorem . For M = 5 (10th order): . . . Dan Ellis. 8 extrema (M+3, 4 band edges) - great! 7 extrema (M+2, 3 band edges) - OK! 6 extrema (M+1, only 2 transition band edges) → NOT OPTIMAL 2012-11-19. 1. ~ H1W 0.5. 0 0. 0.2. 0.4. 0.6. 0.8. P. 0.4. 0.6. 0.8. P. 0.4. 0.6. 0.8. P. W. 1. ~ H2W 0.5. 0 0. 0.2. W. 1. ~ H3W 0.5. 0 0. 0.2. 27. W.

(28) Parks-McClellan Algorithm . To recap: . . . . FIR CAD constraints D(ej!), W(!) → "(!) Zero-phase FIR ~ H(!) = ßkÆkcosk! → M-1 min/max Alternation theorem optimal → ≥ M+2 pk errs, alter’ng sign. Hence, can spot ‘best’ filter when we see it – but how to find it?. Dan Ellis. 2012-11-19. 28.

(29) Parks-McClellan Algorithm . . ~ ~ Alternation → [H(!)-D(!)]/W(!) must = ±" at M+2 (unknown) frequencies {!i}... Iteratively update h[n] with Remez exchange algorithm:    . . estimate/guess M+2 extremals {!i} solve for Æ[n], " ( → h[n] ) find actual min/max in "(!) → new {!i} repeat until |"(!i)| is constant. Converges rapidly!. Dan Ellis. 2012-11-19. 29. M.

(30) Parks-McClellan Algorithm . In Matlab, band edges ÷ º. filter order (2M). >> h=firpm(10, [0 0.4 0.6 1],. . [1 1 0 0], desired magnitude. at band. edges [1 2]); error weights  . per band. 0.6 0.4. h[n]. ~ H(W). 1. 1 0.5. 0.2. 0. 0.5. -0.5. 0 -0.2. Dan Ellis. -5. 0. 5. n. 0 0. 0.5. 2012-11-19. W 1. z-plane. -1 -1. 0. 1. 2. 30.

(31)

References

Related documents

Purpose: This study was carried out to investigate the effects of two doses (150 and 300 mg/kg) of ethanolic extract of strawberry leaves on antioxidant capacity of liver, kidney

1) The ancillary costs for wind are non-zero for small wind penetrations and escalate for increasing penetration ratios, although the amounts are not onerous but they are not

DE is a well-known technique for analyzing probabilistic message-passing inference algorithms that was originally developed to analyze belief-propagation decoding of

Menurut al-Baydawi pula, sesiapa sahaja daripada kalangan penganut agama-agama samawi tersebut yang beriman dan beramal sesuai dengan ketentuan ajaran agamanya

In this paper, we deal with the existence results for mild solutions of abstract fractional evolution equations with non-instantaneous impulses on an unbounded interval.. We

The purposes of this study are to: (1) investigate how pre-service art teachers are prepared to implement instructional technological tools for virtual museum experiences and

As showed in Table 2, after controlling for the effect of participants’ demographics (gender, age, education level and faculty) and family background (parental education and

In order to study the seasonal variations in species richness, composition and diversity of ant canopy community in a tropical deciduous forest, seven fogging were performed in