Digital Filter Design

Digital Filter Design

Digital filter design 1 FREQUENCY RESPONSE OF FILTERS x(t) - G - y(t) For input x(n) = cos(!n) the output is y(n) = AG(!) cos(!n + 'G(!)) AG(!): filter gain or magnitude 'G(!): filter phase 2 Reason: the output can always be written as y(n) = h(0) cos(!n) + h(1) cos(!n − !) + ··· h(k) cos(!n − !k) + ··· = AG(!) cos(!n + 'G(!)) The functions AG(!), 'G(!) form the frequency response of a filter Matlab routine: freqz(B,A,W) where B= [b0 a2 : : : bM ], B= [1 a1 a2 : : : aN ], W: vector with frequencies (if specified) 3 Relation between transfer function and frequency response Let x(n) = ej!n = cos(!n) + j sin(!n) Then: y(n) = h(0)ej!n + h(1)ej!(n−1) + ··· h(k)ej!(n−k) + ··· ( ) = h(0) + h(1)e−j! + ··· h(k)e−j!k + ··· ej!n = H(ej!) ej!n where H(z) is the transfer function of the system. 4 H(ej!) is the frequency response: determines how a frequency component ! is affected in magnitude and phase. H(ej!) is a complex number which can be written in polar form: j! H(ej!) = jH(ej!)j ej arg(H(e )) Then for input x(n) = ej!n = cos(!n) + j sin(!n) we have: y(n) = H(ej!) ej!n j! = jH(ej!)j ej arg(H(e )) ej!n j! = jH(ej!)j ej(!n+arg(H(e ))) ( ) = jH(ej!)j cos(!n + arg(H(ej!))) + j sin(!n + arg(H(ej!))) or y(n) = AH(!) cos(!n + 'H(!)) + jAH(!) sin(!n + 'H(!)) where j! AH(!) = jH(e )j (filter gain) and j! 'H(!) = arg(H(e )) (phase shift of filter) 5 FREQUENCY RESPONSE OF SERIES CONNECTION y1(n) - - - x(n) H1 H2 y(n) For x[n] = cos(!n) we have: y1(n) = A1(!) cos(!n + '1(!)) y(n) = A2(!)A1(!) cos(!n + '1(!) + '2(!)) ) Magnitude of series connection is multiplicative: A(!) = A2(!) · A1(!) Phase of series connection is additive: '(!) = '2(!) + '1(!) 6 FILTER DESIGN Example: Low-pass filter magnitude specs 1.2 1 0.8 0.6 0.4 0.2 0 0 0.1 0.2 0.3 0.4 0.5 - maximum deviation in passband, 1 − δp ≤ A(f) ≤ 1 + δp - damping in stopband, A(f) ≤ δs - width of transition band (normalized) 7 Filter magnitude specs often defined in dB (decibel) units: - maximum deviation in passband: Ap = 20 log(1 + δp) (dB) Note: Ap ≈ 8:7δp for small δp - damping in stopband: As = −20 log δs (dB) 8 FUNDAMENTAL RELATIONSHIP BETWEEN AMPLITUDE AND PHASE Z 1 π d log(A(!0)) sin((!0 + !)=2) d!0 ≤ · '(!) 0 log 0 − 0 π 0 d log(! ) sin((! !)=2) ! 0 sin((! +!)=2) where log sin((!0−!)=2) > 0 Implication: d log(A(!)) Low-pass filter with large magnitude slope, d log(!) << 0 results in large negative phase shifts, '(!) << 0! 9 EFFECT OF PHASE SHIFT - LINEAR PHASE FILTERS Observation: Phase shift in passband may cause signal distortion. Illustrative Example Consider a signal consisting of two sinusoidal components s(n) = s1(n) + s2(n) where s1(n) = sin(!1n) s2(n) = sin(!2n) 10 1 0.5 s 1 0 −0.5 −1 1 0.5 s 2 0 −0.5 −1 2 1 s 0 −1 −2 Top: s1(n) Middle: s2(n) Below: s(n) 11 Add a high-frequency disturbance e(n), x(n) = s(n) + e(n) where e[n] = sin(!en);!e > !1;!2 2 1 s 0 −1 −2 1 0.5 e 0 −0.5 −1 2 x 0 −2 12 Use low-pass filtering to suppress the disturbance 1 1 0.5 0.5 s ,y s ,y 1 1 0 1 1 0 −0.5 −0.5 −1 −1 1 1 0.5 0.5 s ,y s ,y 2 2 0 2 2 0 −0.5 −0.5 −1 −1 2 2 1 1 s,y s,y 0 0 −1 −1 −2 −2 Left: Nonlinear phase filter gives passband signal distortion Right: Linear phase filter reconstructs delayed version of passband signal 13 Linear phase property: x(t) - G - y(t) For input x(n) = cos(!n) we have the output y(n) = A(!) cos(!n + '(!)) To avoid phase distortion we require that all frequencies in passband delayed are by the same time, i.e., y(n) = A(!) cos(!(n − τ)) in passband. This is achieved if the filter gives phase shift '(!) = −! · τ 14 PHASE SHOULD BE A LINEAR FUNCTION OF FREQUENCY IN PASSBAND! Implication for frequency response: j! We should have 'H(!) = arg(H(e )) = −!τ or H(ej!) = jH(ej!)je−j!τ in passband. • Linear phase property can be achieved with symmetric FIR filters • Linear property can be achieved only approximately with IIR filters 15 LINEAR PHASE FIR FILTERS Linear phase property is achieved by symmetric FIR filters: y(n) = h(0)x(n) + h(1)x(n − 1) + ··· +h(1)x(n + 2 − N) + h(0)x(n + 1 − N); n = 0; 1; 2;:::;M where h(k) = h(N − 1 − k); k = 0; 1;:::;N − 1 For input x(n) = cos(!n) the output is y(n) = A(!) cos(!n − !(N − 1)=2) = A(!) cos(!(n − (N − 1)=2)) ) Each frequency component delayed by (N − 1)=2 time steps. 16 REASON: Pairwise combination of terms k and N − 1 − k gives ( ) h(k) x(n − k) + x(n + 1 − N + k) = ( ) = h(k) cos(!(n − k)) + cos(!(n + 1 − N + k)) ( N−1 N−1 = h(k) cos(!(n − ) + !( − k)) 2 2 ) N−1 N−1 + cos(!(n − ) − !( − k)) 2 2 N−1 = h(k)2 cos(!( − k)) · cos(!(n − (N − 1)=2)) 2 where we have used cos(α ± β) = cos α · cos β ∓ sin α · sin β ) All frequency components x(n) = cos(!n) are delayed by (N −1)=2 samples 17 From above, we have (for N even) y(n) = AH(!) cos(!n + 'H(!)) N=X2−1 N−1 = h(k)2 cos(!( − k)) · cos(!(n − (N − 1)=2)) 2 k=0 ) Filter has frequency response with: • Linear phase: 'H(!) = −!(N − 1)=2 • Gain: N=X2−1 N−1 A (!) = 2 h(k) cos(!( − k)) H 2 k=0 Similarly if N is odd-valued (see lecture notes) 18 FIR FILTER DESIGN We consider two important FIR filter design methods: • Windowed-Sinc filters • Optimization-based FIR filters 19 Windowed-Sinc filters The idea is to modify the ideal filter. The ideal low-pass filter with bandwidth fc has impulse response hD(0) = 2fc sin(2πf k) h (k) = c ; k = ±1; ±2;::: D πk Cannot be implemented, because: • impulse response hD(k) cannot be realized by any finite-dimensional difference equation • not causal (output depends on future inputs) 20 Practical low-pass FIR filter: • cut the ideal filter response to finite length N = 2M + 1 (hD(k); k = −M; −M + 1;:::;M), y(n) = hD(−M)x(n + M) + ··· + hD(−1)x(n + 1) + +hD(0)x(n) + hD(1)x(n − 1) + ··· + hD(M)x(n − M) • make it causal by introducing a delay M: y(n) = hD(−M)x(n) + ··· + hD(−1)x(n − M + 1) + +hD(0)x(n − M) + ··· + hD(M)x(n − 2M − 1) • multiply impulse response coefficients by a window function w(k) in order to smooth out end effects: y(n) = hw(−M)x(n) + ··· + hw(0)x(n − M) + ··· + hw(M)x(n − N); where hw(k) = w(k)hD(k), N = 2M + 1. 21 Some common window functions: • Rectangular window (trivial), w(k) = 1; jkj ≤ (N − 1)=2 • Hanning window, w(k) = 0:5 + 0:5 cos(2πk)=N); jkj ≤ (N − 1)=2 • Hamming window, w(k) = 0:54 + 0:46 cos(2πk=N); jkj ≤ (N − 1)=2 • Blackman window, w(k) = 0:42 + 0:5 cos(2πk=N) + 0:08 cos(4πk=N); jkj ≤ (N − 1)=2 22 Observe that: • Length of windowed filter is N = 2M + 1 (odd) • Windowed filters are linear phase, as they satisfy symmetry property: hD(−k) = hD(k) and w(−k) = w(k) ) hw(−k) = hw(k) Selection of window function is a trade-off between performance and complexity: • Performance (deviation in passband and damping in stopband) is determined by the window function. • Filter length N is determined by width ∆f of transition band: for each window function, ∆f = cw=N, where cw = window-specific constant. • Better passband and stopband performance implies increased filter length for a given width of transtion band. 23 Summary of windowed filter properties: Window Width of Maximal passband Damping in function transition band deviation stopband (Hz, normed) (dB) (dB) Rectangular 0:9=N 0.7416 21 Hanning 3:1=N 0.0546 44 Hamming 3:3=N 0.0194 53 Blackman 5:5=N 0.0017 74 Kaiser 2:93=N (β = 4:54) 0.0274 50 4:32=N (β = 6:76) 0.00275 70 5:71=N (β = 8:96) 0.000275 90 24 IIR FILTERS Good filter performance requires a sufficiently long memory in order to allow distinct response to different frequency components. In FIR filters this implies a large number of taps. IIR filters have infinite memory due to recursiveness ) simpler filter for given magnitude performance specifications Standard IIR filters: - Butterworth - Chebyshev - Elliptic 25 Butterworth filters Digital low-pass Butterworth filter with cut-off frequency !c = 2πfc has frequency response magnitude [ ]1=2 j j! j 1 BN (e ) = 2N (1) 1 + [tan(!=2)= tan(!c=2)] - monotonically varying gain in both passband and stopband Matlab routines: [B,A]=butter(N,Wn,'ftype') designs filter [N,Wn]=buttord(Wp,Ws,Rp,Rs) computes required minimum order 26 Chebyshev filters • Chebyshev filter type I has equiripple gain in passband and monotonically varying gain in stopband.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    37 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us