# Filter Design Techniques

• Filter
– Filter is a system that passes certain frequency components and totally rejects all others – Specification of the desired properties of the system – Approximation of the specification using a causal discrete-time system – Realization of the system
Filter Design-FIR (cwliu@twins.ee.nctu.edu.tw) 1

• Stages of the design filter

Review of discretetime systems
Frequency response : • periodic : period = 2π • for a real impulse response h[k] jω Magnitude response H ( e ) is even function Phase response ∠H (e jω ) is odd function • example :
1 0 .5 0 -4 5

Nyquist frequency

e jπk = ...,1,−1,1,−1,1,...

−π

-2

0

2

π

4

0

-5 -4

-2

Filter Design-FIR 2 (cwliu@twins.ee.nctu.edu.tw) 0 4

2

nctu.tw) π π π 3 .edu.ee.Review of discretetime systems `Popular’ frequency responses for filter design : low-pass (LP) high-pass (HP) band-pass (BP) π band-stop multi-band π … π Filter Design-FIR (cwliu@twins.

.tw) 4 ..edu..... h [ N ] = b N . “all zero” filters corresponds to difference equation impulse response y [ k ] = b 0 u [ k ] + b1 u [ k − 1 ] + . Filter Design-FIR (cwliu@twins. + b N u [ k − N ] h [ 0 ] = b 0 .Review of discretetime systems “FIR filters” (finite impulse response): B(z) H (z) = = b 0 + b1 z − 1 + .. h [1] = b1 ..ee.. + b N z − N zN • • • • • “Moving average filters” (MA filters) N poles at the origin z=0 (hence guaranteed stability) N zeros (zeros of B(z)). h [ N + 1] = 0 ...nctu.

k k H (e ) = jω k =− L ∑ h[k ]e +L = . k=1..L frequency response is L − jω .h[-1]..h[0].nctu..….h[1].tw) 5 .ee..causal implementation by introducing (group) delay Filter Design-FIR (cwliu@twins. real-valued (=zero-phase) transfer function .h[L] h[k]=h[-k].e.edu.Linear Phase FIR Filters Non-causal zero-phase filters : example: symmetric impulse response h[-L]..i... = ∑ ak cos(ωk ) k =0 L .

.. = e − jω L ∑a k =0 L k cos(ωk ) = i. causal implementation of zero-phase filter.edu.L 0 frequency response is N k H (e ) = ∑ h[k ]e jω k =0 N − jω .Linear Phase FIR Filters • Causal linear-phase filters = non-causal zero-phase + delay example: symmetric impulse response & N even h[0].h[N] N=2L (even) h[k]=h[N-k]..ee. k=0. k = .tw) 6 .…. by introducing (group) delay z − L = e − jωL z = e jω Filter Design-FIR (cwliu@twins..nctu.h[1].e.

Linear Phase FIR Filters Type-1 N=2L=even symmetric h[k]=h[N-k] e − jωN / 2 Type-2 N=2L+1=odd symmetric h[k]=h[N-k] − jωN / 2 Type-3 N=2L=even anti-symmetric h[k]=-h[N-k] L−1 k =0 Type-4 N=2L+1=odd anti-symmetric h[k]=-h[N-k] k =0 ∑ ak cos(ωk ) e k =0 L L cos( )∑ ak cos(ωk ) je− jωN / 2 sin( ) a cos( k) ω∑ k ω j.e − jωN / 2 sin( ω )∑ ak cos(ωk ) 2 k =0 2 ω L zero at ω LP/HP/BP LP/BP =π zero at ω = 0.ee. π zero at ω HP =0 Filter Design-FIR (cwliu@twins.nctu.edu.tw) 7 .

edu.nctu.Linear Phase FIR Filters u[k] • example: efficient direct-form realization. Δ Δ Δ Δ Δ Δ Δ Δ + bo + + + + b1 b2 b3 b4 x x x x x + + + + y[k] • PS: IIR filters can NEVER have linear-phase property ! Filter Design-FIR (cwliu@twins.tw) 8 .ee.

Stopband Cutoff Stopband Ripple δS 0 0.ee.2 0 Passband Ripple ωP ωS Passband Cutoff -> <.edu.5 3 9 Filter Design-FIR (cwliu@twins.nctu.5 2 2.8 0.4 0.6 0.Filter Specification Ex: Low-pass 1.2 1−δP 1 0.tw) .5 1 1.

Filter Design Problem • Design of filters is a problem of function approximation • For FIR filter.tw) 10 .ee. it implies approximation by a rational function of z Filter Design-FIR (cwliu@twins.nctu. it implies polynomial approximation • For IIR filter.edu.

.Filter Design by Optimization (I) Weighted Least Squares Design : • select one of the basic forms that yield linear phase L e...nctu..... a L −π −π 14444244443 min 2 2 F ( a0 .g..BP..edu.. Type-1 jω − jω N / 2 − jω N / 2 H (e ) = e ∑a k =0 k cos(ωk ) = e A(ω ) • specify desired frequency response (LP.HP. a L ) +π where W (ω ) ≥ 0 is a weighting function Filter Design-FIR (cwliu@twins...tw) 11 .…) H d (ω ) = e − jωN / 2 Ad (ω ) • optimization criterion is +π W (ω ) H (e jω ) − H d (ω ) dω = min ∫ W (ω ) A(ω ) − Ad (ω ) dω a0 . a L ∫ a0 .ee.

....edu. cos( Lω ) ] μ = .. 0 π =standard ‘Quadratic Optimization’ problem xOPT = Q−1 p Filter Design-FIR (cwliu@twins..tw) 12 ..Filter Design by Optimization • …this is equivalent to F ( 0 ... a L ] Q = ∫ W (ω )c (ω )c T (ω ) dω 0 p = ∫ W (ω ) Ad (ω )c (ω ) dω c T (ω ) = [1 cos(ω ) . a L 644 a74)44 4 8 min{ x T Qx − 2 x T p + μ } x T = [a0 π x a1 ..ee.nctu.

.2 i. Filter Design-FIR (cwliu@twins. ω < ω P Ad (ω ) = 0.5 2 2.band stop .ee.6 0.band) (stop .band 2 2 ∫ A(ω ) − 1 +π 0 0 0. ∫ A (ω )dω = .5 1 1...8 0.nctu..Filter Design by Optimization 1.. aL ) = ωP 0.tw) 13 .band) Passband Ripple Stopband Ripple optimization function is F ( a0 .5 3 W (ω ) = . 0 ωS 14 244 4 3 14 244 4 3 pass .2 1 0.. ω S ≤ ω ≤ π (pass .edu.Stopband Cutoff • Example: Low-pass design Ad (ω ) = 1. dω + γ .e...4 Passband Cutoff -> <.

ee..) by… ⎧ ⎫ ⎡ a0 ⎤ 2 ⎪ ⎪ F (a0 . ∑ W (ω i ) c (ω i ) c T (ω i ) A A { T T T i i i +++ : simple --...12 14 .: unpredictable behavior in between sample frequencies...nctu..edu.Filter Design by Optimization • a simpler problem is obtained by replacing the F(. ∑ . aL ) = ∑ W (ωi ) A(ωi ) − Ad (ωi ) = ∑ W (ωi )⎨cT (ωi ) ⎢ : ⎥ − Ad (ωi )⎬ ⎢ ⎥ i i ⎪ ⎪ ⎢aL ⎥ ⎣ ⎦ ⎩ ⎭ 2 where the wi’s are a set of n sample frequencies The quadratic optimization problem is then equivalent to a least-squares problem min Ax − b x 2 2 = min { x T x x − 2 x T { + b b} A b { ∑ .tw) xLS = (A A)−1 A b T T Compare to p... Filter Design-FIR (cwliu@twins..

Filter Design by Optimization • …then all this is often supplemented with additional constraints Example: Low-pass (LP) design pass-band ripple control : A(ω ) − 1 ≤ δ P .tw) 15 . ω < ω P (continued) (δ P is pass .nctu.band ripple) stop-band ripple control : A(ω ) ≤ δ S .ee.band ripple) Filter Design-FIR (cwliu@twins. ω S ≤ ω ≤ π (δ S is stop .edu.

aL ] (pass-band constraints) (stop-band constraints) AS x ≤ bS = `Quadratic Linear Programming’ problem Filter Design-FIR (cwliu@twins.. ω Sn in the stop-band The resulting optimization problem is : minimize : F ( a . x T = [a0 subject to AP x ≤ bP 0 L a1 ..ee.... is to impose the constraints (only) on a set of sample frequencies ω P1 .. ω Pm in the pass-band and ω S 1 ..nctu....tw) 16 .. ω P 2 ...edu. ω S 2 ...Filter Design by Optimization Example: Low-pass (LP) design (continued) a realistic way to implement these constraints.. a ) = .

…) optimization criterion is a0 .edu.ee....a L 0≤ω ≤π H d (ω ) = e − jωN / 2 Ad (ω ) min max W (ω ) H (e jω ) − H d (ω ) = min max W (ω ) A(ω ) − Ad (ω ) a0 ...nctu.tw) 17 .HP.Filter Design by Optimization (II) `Minimax’ Design : • select one of the basic forms that yield linear phase L e..g.BP. Type-1 H (e jω ) = e − jωN / 2 a[ k ] cos(ωk ) = e − jωN / 2 A(ω ) ∑ k =0 • • specify desired frequency response (LP...a L 0≤ω ≤π where W (ω ) ≥ 0 is a weighting function Filter Design-FIR (cwliu@twins.

nctu.ee.tw) 18 . procedures to translate filter design problems into standard optimization problems • In practice (and in textbooks): emphasis on specific (ad-hoc) procedures : .Filter Design by Optimization • Conclusion: (I) weighted least squares design (II) minimax design provide general `framework’.equi-ripple design Filter Design-FIR (cwliu@twins.edu.filter design based on ‘windows’ .

Filter Design using ‘Windows’ Example : Low-pass filter design • ideal low-pass filter is ⎧1 ω < ωC H d (ω ) = ⎨ ⎩0 ω C < ω < π • hence ideal time-domain impulse response is 1 hd [k ] = 2π • +π π − ∫π H d (e )e jω jω .k sin(ωc k ) dω = . = α ωc k Non-causal and infinitely long truncate hd[k] to N+1 samples : • add (group) delay to turn into causal filter ⎧ hd [ k ] h[ k ] = ⎨ ⎩ 0 − N /2 < k < N /2 otherwise 19 Filter Design-FIR (cwliu@twins.tw) .edu..nctu..ee.

large ripple in pass-band and stop-band.…) --. Filter Design-FIR (cwliu@twins.edu. and weighting function W (ω ) = 1 truncation corresponds to applying a ‘rectangular window’ : • h[k ] = hd [k ]w[k ] ⎧1 w[ k ] = ⎨ ⎩0 • • − N /2 < k < N /2 otherwise +++: simple procedure (also for HP.BP.e. i.Filter Design using ‘Windows’ Example : Low-pass filter design (continued) • note : it can be shown that time-domain truncation corresponds to solving a weighted least-squares optimization problem with the given Hd.tw) 20 . which cannot be reduced by increasing the filter order N.nctu.ee.: truncation in the time-domain results in ‘Gibbs effect’ in the frequency domain.

tw) 21 . Blackman. Hamming.ee. Kaiser.…. (see textbooks) window choice/design = trade-off between side-lobe levels (define peak pass-/stop-band ripple) and width main-lobe (defines transition bandwidth) Filter Design-FIR (cwliu@twins.edu.Filter Design using ‘Windows’ Remedy : apply windows other than rectangular window: • time-domain multiplication with a window function w[k] corresponds to frequency domain convolution with W(z) : h[k ] = hd [k ]w[k ] H ( z ) = H d ( z ) ∗W ( z ) • • candidate windows : Han.nctu.

nctu.edu.Windowing Effect Gibbs phenomenon Filter Design-FIR (cwliu@twins.tw) 22 .ee.

Windowing 23 .

L + 2 • • • …that hence will exhibit the same maximum ripple (‘equiripple’) Iterative procedure for computing extremal frequencies. e.... etc... a L 0 ≤ω ≤π min max W (ω ) A(ω ) − Ad (ω ) = min max E (ω ) a0 .tw) 24 ..Equiripple Design • Starting point is minimax criterion. (Remez exchange algorithm..nctu. Parks-McClellan algorithm) Very flexible... a L 0 ≤ω ≤π • Based on theory of Chebyshev approximation and the ‘alternation theorem’. a0 .ee.edu.. etc.. available in many software packages Details omitted here (see textbooks) Filter Design-FIR (cwliu@twins. which (roughly) states that the optimal ai’s are such that the ‘max’ (maximum weighted approximation error) is obtained at L+2 extremal frequencies… 0 ≤ω ≤π max E (ω ) = E (ωi ) for i = 1.g..

Software • FIR Filter design abundantly available in commercial software • Matlab: b=fir1(n.window).m.f.edu. type is `high’.`stop’. n is filter order. windowed linear-phase FIR design.nctu. windowed FIR design based on inverse Fourier transform with frequency points f and corresponding magnitude response m b=remez(n.window).Wn.f.… b=fir2(n. Wn defines band-edges.ee.type.tw) 25 .m). equiripple linear-phase FIR design with Parks-McClellan (Remez exchange) algorithm Filter Design-FIR (cwliu@twins.

Sign up to vote on this title