PHYS 352. Recap: Digital Filter Kernel. More Digital Filters

PHYS 352 More Digital Filters Recap: Digital Filter Kernel       the values h[m] are the kernel these are the weighting factors in the calcul...
13 downloads 0 Views 484KB Size
PHYS 352

More Digital Filters

Recap: Digital Filter Kernel      

the values h[m] are the kernel these are the weighting factors in the calculation h[m] represents the time domain impulse response DFT of h[m] gives the transfer function H(ω) (frequency domain) in the previous lecture, we looked at the moving average filter let’s look at some more examples…

Exponential Kernel 

h[m] values are a decaying exponential 

i.e. earlier values of x[n] are weighted less



write exponential kernel as continuous function: h(t) = e−bt u(t)



Fourier transform:

1-pole low pass transfer function

Gaussian Kernel 



h[m] are filled with values from a Gaussian function Fourier transform of a Gaussian is … a Gaussian 



transfer function is a low-pass filter

Gaussian kernels used in 2D image processing  

Gaussian blur to smooth out noise also used for highpass sharpening

How to Make a High-Pass Filter? 

technique is called “spectral inversion”

High-Pass Filter Explained 

a delta function kernel: y[n] = x[n], is “all-pass” basically, you take what would be the output from the low pass filter and subtract it off from the original

remember: the digital filter acts in time domain

High Pass Math !"#$%&'((%)'*$ here's here's the the math... math...  ‡ time time domain domain  ‡

& " % ³ >į W  $ W @# "  IJ !IJ

& " % ³ į W # "  IJ !IJ  ³ $ W # "  IJ !IJ & " % # "  ³ $ " # "  IJ !IJ

‡ 

frequency domain domain frequency ) Ȧ % ( $*+$ Ȧ ' Ȧ

) Ȧ % ' Ȧ  ( ,-. Ȧ ' Ȧ

how it's done: take the low-pass digital filter kernel, how it's done: take the low-pass digital filter kernel, change the sign of all the kernel samples, then add one change thefunction) sign of all then t=0 add one (the delta at the the kernel centre samples, of symmetry, (the delta function) at the centre of symmetry, t=0

Sinc Kernel 

an ideal low-pass filter has a square frequency response  flat passband (e.g. unity gain), infinitely sharp cutoff, zero stopband



inverse Fourier transform is the sinc function in time domain

Sinc Kernel Filter Features  

sinc(t) is the impulse response → the kernel in theory  



the sinc function extends to infinity, both + and − the sinc function is non-causal, has values for t0

in a real implementation 

non-causal is not a big deal  





the kernel must be chopped so it has finite length 



can add a time shift the Fourier transform of a time shift is a phase shift (and it’s a “linear” phase shift which we know is good for filters) shift the kernel h[m] to get a causal filter again  so that h[m] = 0 for m < 0 mathematical a “window” function multiplies the sinc kernel

otherwise, the sinc kernel would be an ideal filter

Truncated Sinc – Non Ideal 

truncate the kernel to M+1 points, where M is even



shift so that there are no t < 0 values what's the effect of the shift?





it's just a time delay between input and output; still linear phase so this has no impact on pulse shape

Window Function multiple by a window function to smooth the abrupt ends  improves passband ripple and stopband attenuation  slower roll-off 

Window Function 

non-ideal frequency domain response is due to abrupt truncation (finite length)



making the truncation less abrupt… do this by multiplying the truncated sinc function with a smoothly tapered curve at the ends → improves the frequency response



Blackman or Hamming Window 

Blackman window



Hamming window



window functions go from 0 to M also

Filter Performance 

Hamming windowed sinc has ~20% faster roll-off than Blackman windowed sinc



Blackman has -74 dB stopband attenuation while Hamming has only -53 dB



Blackman passband ripple 0.02% while Hamming is 0.2%

Digital Filter Design 

two parameters are at your disposal  

 

kernel length determines speed of roll-off transition width = 4/M  



cutoff frequency length of filter kernel

in units of sampling frequency e.g. M = 40, width = 0.1 fs

trade-off is between  computation time vs.  sharpness of filter

Windowed Sinc Filter Design cont'd  

note: roll-off sharpness does not change with cutoff frequency final expression:     

fc is a fraction of sampling rate  between 0 and 0.5 M is an even integer i runs from 0 to M K is a normalization constant (sets unity gain for DC) for i = M/2 (at the sinc peak), h[i] = 2 π fc K



sinc

Blackman

Max'ed Out Windowed Sinc! 

how to get -148 dB stopband attenuation? 



two-stage Blackman windowed sinc filter

how to get incredible roll-off? 

32,001-point Blackman (from pass to stop in 0.000125 fs) 

e.g. fs=8 kHz; transition width is 1 Hz



0.02% ripple and residue

Digital Filters Summary straightforward to design  straightforward to use  near optimum frequency domain performance achievable  linear phase → good pulse shape fidelity in time domain also  only thing you trade off for higher performance is computation time (due to longer kernel) 

Band Pass 

cascading filters works; also equivalent to convolution

Band Reject