ELEN E48: Digital Signal Processing Topic 8: Filter Design: IIR. Filter Design Specifications 2. Analog Filter Design 3. Digital Filters from Analog Prototypes
. Filter Design Specifications The filter design process: Problem Analysis magnitude response phase response cost/complexity performance constraints Design FIR/IIR subtype order G(z) transfer function Implement platform structure... Solution 2
Performance Constraints.. in terms of magnitude response: G(ej) passband ripple gain / db - -2-3 Passband transition band optimal filter will touch here Stopband minimum stopband attenuation -4..2.3.4.5.6.7.8.9 frequency passband edge frequency stopband edge frequency 3
Performance Constraints Best filter: narrowest Transition Band smallest Passband Ripple greatest Minimum SB Attenuation improving one usually worsens others But: increasing filter order (i.e. cost) can improve all three measures 4
Passband Ripple - -2 G(ej) Passband detail G(e j ) -3-4..2.3.4.5.6.7.8.9 PB ripple parameter Assume peak passband gain = then minimum passband gain = + 2 Or, ripple max = 2log + 2 db 5
Stopband Ripple - -2 G(e j ) Stopband detail -3-4..2.3.4.5.6.7.8.9 SB ripple parameter A freq Peak passband gain is A larger than peak stopband gain Hence, minimum stopband attenuation s = 2 log A = 2log A db 6
BUT Filter Type Choice: FIR vs. IIR FIR No feedback (just zeros) Always stable Can be linear phase High order (2-2) Unrelated to continuoustime filtering IIR Feedback (poles & zeros) May be unstable Difficult to control phase Typ. < /th order of FIR (4-2) Derive from analog prototype 7
FIR vs. IIR If you care about computational cost use low-complexity IIR (computation no object linear phase FIR) If you care about phase response use linear-phase FIR (phase unimportant go with simple IIR) 8
IIR Filter Design IIR filters are directly related to analog filters (continuous time) via a mapping of H(s) (CT) to H(z) (DT) that preserves many properties Analog filter design is sophisticated signal processing research since 94s Design IIR filters via analog prototype need to learn some CT filter design 9
2. Analog Filter Design Decades of analysis of transistor-based filters sophisticated, well understood Basic choices: ripples vs. flatness in stop and/or passband more ripples narrower transition band Family PassBand StopBand Butterworth flat flat Chebyshev I ripples flat Chebyshev II flat ripples Elliptical ripples ripples
Transform Frequency response Pole/zero diagram CT Transfer Functions Analog systems: s-transform (Laplace) frequency response still from a polynomial H a s stable poles Continuous-time ( )e st dt H d z ( ) = h a t H a Discrete-time ( ) = h d n ( ) ( j) H d e j Im{s} j Re{s} s-plane s scales freq stable poles Im{z} e j! Re{z} [ ]z n z-plane
Butterworth Filters Maximally flat in pass and stop bands Magnitude response (LP): H a ( j) 2 = + ( ) 2N c filter order N 3dB point c, H a (j ) 2 = c, H a (j ) 2 = / 2 Ha(j).8.6.4.2 N N 2 3 / c analog freq 2
Butterworth Filters c, H a (j ) 2 ( c / ) 2 N 6N db/oct rolloff Log-log magnitude response Ha(j) / db - -2-3 -4-5 N N slope -6N db/oct -6 flat d n d n H a -7 - ( j ) 2 = / c analog freq @ = for n =.. 2N- 3
Butterworth Filters How to meet design specifications? A H a (j) p s + ( ) 2N p + 2 c + s c k = A 2 = discrimination, ( ) 2N A 2 Design Equation N 2 log k = p s = selectivity, < log ( A 2 ) 2 ( ) s p Dan Ellis 23-- 4
Butterworth Filters H a ( j) 2 = + ( c ) 2N... but what is H a (s)? Traditionally, look it up in a table calculate N normalized filter with ΩΩ c = scale all coefficients for desired ΩΩ c In fact, where H a ( s) = p i = c e ( i s p ) i j N +2i 2N i =..N odd-indexed uniform divisions of c-radius circle Im{s} ΩΩc Re{s} s c 2N s-plane = 5
Butterworth Example Design a Butterworth filter with db cutoff at khz and a minimum attenuation of 4 db at 5 khz A db = - db = -4 db db = 2log 2 =.259 + 2 4dB = 2log A A = s p = 5 khz p N 2 5kHz s log 9999.259 log 5 N = 4 3.28 Dan Ellis 23-- 6
Butterworth Example Order N = 4 will satisfy constraints; What are ΩΩ c and filter coefficients? from a table, ΩΩ -db =.845 when ΩΩ c = ΩΩ c = /.845 =.84 khz Dan Ellis from a table, get normalized coefficients for N = 4, scale by 84 2º Or, use Matlab: [B,A] = butter(n,wc, s ); 23-- gain / db - -2-3 -4-5 -6 2 4 6 7 freq / Hz M
Chebyshev I Filter (Чебышёв) Equiripple in passband (flat in stopband) minimize maximum error H(j ) 2 = + 2 T 2 N ( p ) gain / db - -2 N ripple depth -3 N Chebyshev polynomial of order N -4.5.5 2 T N ( ) = cos(n cos ) cosh(n cosh ) > 8
Chebyshev I Filter H(j ) 2 = + 2 T 2 N ( p ) T N ( ) = cos(n cos ) cosh(n cosh ) > T 5 ( ) T 2 5 ( ) 2 - -2 3 2 - T 5 () T 5 2 () +.T 2 5 ( ).5 2 /(+. T ( )) 5-2 -.5 - -.5.5.5 2 9
Chebyshev I Filter Design procedure: desired passband ripple " min. stopband atten., ΩΩ p, ΩΩ s N : A = 2 + 2 T 2 N ( s p ) = + 2 cosh N cosh s [ ( )] 2 p N cosh ( A 2 ) ( ) cosh s p /k, discrimination /k, selectivity cosh - grows slower than log 2
Chebyshev I Filter What is H a (s)? complicated, get from a table.. or from Matlab cheby(n,r,wp, s ) all-pole; can inspect them: Im{s}.5 -.5 - - -.5.5 Re{s}..like squashed-in Butterworth (why?) 2
Chebyshev II Filter Flat in passband, equiripple in stopband H a ( j) 2 = constant + T 2 N ( s T N ( s p ) -6 ~/T N (/ΩΩ).5.5 2 ) Filter has poles and zeros (some ) Complicated pole/zero pattern 2 gain / db - -2-3 -4-5 N N peak of stopband ripples zeros on imaginary axis 22
Elliptical (Cauer) Filters Ripples in both passband and stopband H a ( j) 2 = + 2 R N 2 ( p ) function; satisfies R N (ΩΩ - ) = R N (ΩΩ) - zeros for ΩΩ< poles for ΩΩ> gain / db - -2-3 -4-5 N N -6.5.5 2 very narrow transition band PB ripple depth peak SB ripples Complicated; not even closed form for Ν Dan Ellis 23-- 23
Analog Filter Types Summary Butterworth Chebyshev I gain / db - -2-3 gain / db - -2-3 r gain / db -4-5 -6.5.5 2 - -2-3 -4-5 c Chebyshev II A s -6.5.5 2 gain / db -4-5 -6.5.5 2 - -2-3 -4-5 Elliptical p r A p -6.5.5 2 N = 6 r = 3 db A = 4 db 24
lowpass prototype Analog Filter Transformations All filters types shown as lowpass; other types (highpass, bandpass..) derived via transformations i.e. H LP s ( ) s ˆ = F ( s) H D ( s ˆ ) Desired alternate response; still a rational polynomial General mapping of s-plane ^ BUT keep LHHP & jωω jωω; poles OK, frequency response shuffled 25
Lowpass-to-Highpass Example transformation: H HP take prototype H LP (s) polynomial replace s with ( s ˆ ) = H LP ( s) s= p ˆ p ˆ p s ˆ simplify and rearrange new polynomial H HP (s) ^ p s ˆ 26
Lowpass-to-Highpass What happens to frequency response? s = j s ˆ = p ˆ p = j ( p ˆ p ) j ˆ = p ˆ p...freq. freq. ^ HPF = p ˆ = ˆ p < p ˆ < ˆ LPF LP passband p HP passband > p ˆ > ˆ LP stopband p HP stopband Frequency axes inverted imaginary axis stays on self... ^ p p 27
N 2 Transformation Example Design a Butterworth highpass filter ^ with PB edge -.db @ 4 khz (ΩΩ p ) ^ and SB edge -4 db @ khz (ΩΩ s ) Lowpass prototype: make ΩΩ p = s = ( ) ˆ p p = ( )4 Butterworth -.db @ ΩΩ p =, -4dB @ ΩΩ s =4 ( A 2 ) 2 p @.db. + ( = p log log ( ) s p N=5, 2N= 28 ˆ s c ) c = p /.6866 =.4564
Transformation Example LPF proto has H LP ( s) = p = c e c N N =( s p ) j N +2 2N Im{s} ΩΩc Re{s} H HP Map to HPF: ( s ˆ ) = H HP N c p ˆ N p p =( ) s ˆ ( s ˆ ) = H LP s ( ) s= p ˆ s ˆ s N 29 = N cn ˆ p N zeros @ ^s = p ˆ p p s ˆ =( ) new poles @ s ^ = ΩΩ p ΩΩ ^ p /p l
Transformation Example In Matlab: ΩΩ p ΩΩ s R p R s [N,Wc]=buttord(,4,.,4,'s'); [B,A] = butter(n, Wc, 's'); [U,D] = lp2hp(b,a,2*pi*4); Im{s} x 4.5.5 -.5 - -.5-2 - x 4 Re{s} gain / db - -2-3 -4-5 -6 2 3 4 5 / Hz 3
3. Analog Protos IIR Filters Can we map high-performance CT filters to DT domain? Approach: transformation H a (s) G(z) i.e. G( z) = H a ( s) s=f ( z ) where s = F(z) maps s-plane z-plane: Every value of G(z) is a value of H a (s) somewhere on the s-plane & vice-versa Im{s} Re{s} s-plane s = F(z) z = F - (s) Im{z} H a (s ) G(z ) 3 Re{z} z-plane
CT to DT Transformation Desired properties for s = F(z): s-plane jωω axis z-plane unit circle preserves frequency response values s-plane LHHP z-plane unit circle interior preserves stability of poles s-plane Im{s} jωω Imu.c. Re{s} LHHPUCI Im{z} e j! Re{z} z-plane 32
Bilinear Transformation Solution: Hence inverse: Freq. axis? Poles? s = z +z = z z + z = + s s s = j z = 33 Bilinear Transform unique, : mapping + j j s = + j z = + ( )+ j ( ) j z 2 = + 2 + 2 + 2 2 + 2 + 2 σ < z < z = i.e. on unit circle
Bilinear Transformation How can entire half-plane fit inside u.c.? 4 3 2 - -2 4 3 2 - -2-3 -4-4 -2 2 4 Highly nonuniform warping! s-plane -3 z-plane -4-4 -2 2 4 Moebius Transformations Revealed http://www.youtube.com/watch?v=g87ehdmheac Dan Ellis 23-- 34
Bilinear Transformation What is CTDT freq. relation ΩΩ!? z = e j 2 j sin /2 s = = j tan 2 cos /2 2 u.circle i.e. j e = +e j = tan( ) 2 = 2 tan infinite range of CT frequency < < maps to finite DT freq. range < < nonlinear; d as! º d 35.5 -.5 (DT) im.axis - -5 5 (CT) pack it all in!
Frequency Warping Bilinear transform makes G e j for all!, ΩΩ.8.6.4.2 ( ) = H a j G(e j ) -6-4 -2-2 -4 ( ) =2 tan = 2tan () H a (j) -6 2 3 4 5 6 Same gain & phase (", A...), in same order, but with warped frequency axis 36
Design Procedure Obtain DT filter specs: general form (LP, HP...), p, s, Warp frequencies to CT: + 2, A Oldstyle p = tan p 2 s = tan s 2 Design analog filter for p, s, H a (s), CT filter polynomial Convert to DT domain: G(z), rational polynomial in z Implement digital filter! + 2, A G( z) = H a ( s) s= z +z 37
Bilinear Transform Example DT domain requirements: Lowpass, db ripple in PB,! p =.4º, SB attenuation 4 db @! s =.5º, attenuation increases with frequency G(e j ) / db - PB ripples, SB monotonic Chebyshev I -4.4. 5 38
Bilinear Transform Example Warp to CT domain: p = tan p = tan.2 =.7265 rad/sec 2 s = tan s = tan.25 =. rad/sec 2 Magnitude specs: db PB ripple = /2 =.893 =.587 + 2 4 db SB atten. A =4 /2 =. A = 39
Bilinear Transform Example Chebyshev I design criteria: ( A 2 ) N cosh = 7.9 i.e. need N = 8 cosh ( ) s p Design analog filter, map to DT, check: >> N=8; >> wp=.7265; >> pbripple =.; Dan Ellis Ha(j) / db - -2-3 -4-5 CT -6.5.5 2 23-- freqs(b,a) G(e j ) / db - -2-3 -4-5 DT freqz(b,a) / -6.2.4.6.8 >> [B,A] = cheby(n,pbripple,wp,'s'); >> [b,a] = bilinear(b,a,.5); 4 M
Other Filter Shapes Example was IIR LPF from LP prototype For other shapes (HPF, bandpass,...): DT specs Bilinear warp CT specs Analog design H LP (s) CT trans Bilinear transform H D (s) G LP (z) DT trans Bilinear transform G D (z) Transform LP X in CT or DT domain... 4
DT Spectral Transformations Same idea as CT LPF HPF mapping, but in z-domain: G D ( z ˆ ) = G L ( z) z=f ( z ˆ ) = G ( L F ( z ˆ )) To behave well, z = F z ˆ should: i.e. ( ) map u.c. u.c. (preserve G(e j! ) values) map u.c. interior u.c. interior (stability) F z ˆ ( ) = ˆ F( z ˆ ) z = F z ˆ ( ) < ˆ in fact, matches the definition of an allpass filter... replace delays with 42 z < F z ˆ ( )
DT Frequency Warping Simplest mapping z = F( z ˆ ) = z ˆ ˆ z has effect of warping frequency axis: z ˆ = e j ˆ z = e j = e j ˆ e j ˆ.8 =.6 Æ > : expand HF tan( 2 ) = + ( ) tan 2 ˆ.6.4.2 = -.6.2.4.6.8 ^ Æ < : expand LF 43
Another Design Example Spec: Bandpass, from 8-6 Hz (SR = 8kHz) Ripple = db, min. stopband atten. = 6 db 8th order, best transition band Use elliptical for best performance Full design path: prewarp spec frequencies design analog LPF prototype analog LPF BPF CT BPF DT BPF (Bilinear) 44
Another Design Example Frequency prewarping 8 Hz @ SR = 8kHz = 8/8 x 2 rad/sample L =.2, U =6/8 x 2 =.4 L = tan L/2 =.3249, U =.7265 Note distinction between: application s CT domain (8-6 Hz) and CT prototype domain (.3249-.7265 rad/s) Dan Ellis 23-- 45
Another Design Example Or, do it all in one step in Matlab: [b,a] = ellip(8,,6, [8 6]/(8/2)); Magnitude (db) -2-4 -6-8..2.3.4.5.6.7.8.9 Normalized Frequency ( rad/sample) Phase (degrees) 5-5 -..2.3.4.5.6.7.8.9 Normalized Frequency ( rad/sample) 46