Introduction to Digital Filters - physics.queensu.caphys352/lect09.pdf · Introduction to Digital...

8
PHYS 352 Introduction to Digital Filters Reference The Scientist and Engineer's Guide to Digital Signal Processing by Steven W. Smith http://www.dspguide.com entire book available for free download I have used many figures from that book in this lecture

Transcript of Introduction to Digital Filters - physics.queensu.caphys352/lect09.pdf · Introduction to Digital...

Page 1: Introduction to Digital Filters - physics.queensu.caphys352/lect09.pdf · Introduction to Digital Filters Reference The Scientist and Engineer's Guide to Digital Signal Processing

PHYS 352

Introduction to Digital Filters

ReferenceThe Scientist and Engineer's Guide to Digital Signal Processing

by Steven W. Smith

http://www.dspguide.com entire book available for free download I have used many figures from that book in this

lecture

Page 2: Introduction to Digital Filters - physics.queensu.caphys352/lect09.pdf · Introduction to Digital Filters Reference The Scientist and Engineer's Guide to Digital Signal Processing

Filters and Transfer Functions the output from filter in frequency domain is:

Y(ω) = H(ω)X(ω) where H(ω) is the transfer function

behaves in time domain: because multiplication in frequency domain is

convolution in time domain (and vice versa)

h(t) is called the impulse response

y(t) = h(τ )δ (t − τ )dτ = h(t)0

t

filters have an impulse response h(t)

input filter output

x(t) h(t) y(t)

convolution of x(t) and h(t) gives y(t) it’s like decomposing the input function into a series of

impulses and using the linear property of the system to add up all the responses to all those impulses

Convolution

Page 3: Introduction to Digital Filters - physics.queensu.caphys352/lect09.pdf · Introduction to Digital Filters Reference The Scientist and Engineer's Guide to Digital Signal Processing

Digital Impulse Response delta function δ(t)

approaches infinity when t=0 otherwise equals zero; integral equals 1

for sampled signals, discrete in time δ[n]=1, when n=0 (i.e. for the zeroth sample) otherwise = 0, for all other samples

a linear system (e.g. electrical circuit or mechanical system) takes an input x(t), produces an output y(t) a digital linear system takes x[n], a sequence of numbers, and

outputs y[n], another sequence of numbers linear: two inputs to the system produce an output which is

just the sum of their individual outputs impulse response

for any linear system, the impulse response is the output of the system when the input is a delta function (unit impulse)

h[n] is used for the impulse response to δ[n]

sampled signals are a series of impulses!

e.g. y[3] = x[3]h[0] + x[2]h[1] + x[1]h[2] + x[0]h[3]

notation: y[n] = x[n] ∗ h[n] the ∗ means convolution the [ ] means discrete values

sum (or integration) limits can, in principle, go from −∞ to ∞ since the impulse response is zero for t<0 and x can have values for t<0

Discrete Convolution

Page 4: Introduction to Digital Filters - physics.queensu.caphys352/lect09.pdf · Introduction to Digital Filters Reference The Scientist and Engineer's Guide to Digital Signal Processing

Transfer Function time convolution is multiplication in frequency

domain and vice versa

y(t)=x(t) ∗ h(t) Y(ω)=X(ω)·H(ω)

the Fourier transform of the impulse response defines the transfer function of the filter

Digital Filtering: The Basic Idea amplitude and phase response of filter: H(ω)

Y(ω) = X(ω)·H(ω) to accomplish filtering (in the frequency domain), you

want to perform convolution in the time domain discrete convolution: produces output y[n] based upon

a weighted average of past x[n], x[n-1], x[n-2],... values

the weighting function is known as the filter kernel the weighting function is the impulse response digital filters that function by convolution are known as

Finite Impulse Response (FIR) filters

Page 5: Introduction to Digital Filters - physics.queensu.caphys352/lect09.pdf · Introduction to Digital Filters Reference The Scientist and Engineer's Guide to Digital Signal Processing

Recap: What is a Digital Filter? it’s a digital computation on sampled data (in general, it’s a

numerical system) could be software running on a computer could be a dedicated processor called a digital signal processor

(DSP) can be implemented on an FPGA (field programmable gate

array) takes a stream of number, probably from an ADC, and this

is the input stream does some calculations with those numbers produces an output stream of numbers if the nature of those calculations is like taking a weighted

average of previous values, it’s doing discrete convolution in time domain

thus, the output stream of numbers have been through a filter whose frequency and phase response is the Fourier transform of the kernel (the weighting function)

the kernel defines the properties of the digital filter

Example: Moving Average Filter the most common digital filter easiest to understand here’s a 5-point moving average filter

h[0]=0.2, h[1]=0.2, h[2]=0.2, h[3]=0.2, h[4]=0.2 it’s just averaging the most recent 5 input values y[0]=(x[0]+x[−1]+x[−2]+x[−3]+x[−4])/5 y[1]=(x[1]+x[0]+x[−1]+x[−2]+x[−3])/5 y[2]= …

it's the optimal filter for reducing random white noise while retaining a sharp step response (in time domain) no filter is better than the moving average for this purpose

“worst” filter for frequency domain separation of bands of frequencies

Page 6: Introduction to Digital Filters - physics.queensu.caphys352/lect09.pdf · Introduction to Digital Filters Reference The Scientist and Engineer's Guide to Digital Signal Processing

Result of Moving Averagetime domain

Moving Average – Transfer Function square wave impulse response function Fourier transform should be a sinc function

Page 7: Introduction to Digital Filters - physics.queensu.caphys352/lect09.pdf · Introduction to Digital Filters Reference The Scientist and Engineer's Guide to Digital Signal Processing

Moving Average Frequency Domain slow roll-off terrible stopband attenuation accepted frequency band is narrower when a larger #

of points is used in the average

frequency domain

a digital filter's output y[n] could also depend on previous values of y[n-1], y[n-2], y[n-3],... in addition to previous values of the input x[n]

recursion allows for the possibility that an impulse response lasts forever, and these are also known as Infinite Impulse Response (IIR) filters

IIR filters thus have feedback; produce a steeper response for the same number of coefficients

recursion implementation of a 5-point moving average filter

Recursion

Page 8: Introduction to Digital Filters - physics.queensu.caphys352/lect09.pdf · Introduction to Digital Filters Reference The Scientist and Engineer's Guide to Digital Signal Processing

Digital Versus Analog Filters they can have superior performance (perfectly flat

passband, large stopband rejection, incredibly steep transition)

in addition, they can have perfect linear phase response guaranteed performance (no need to worry about

variations of components, accuracy and stability of resistors and capacitors)

filter response can be programmed (field programmed!) flexibility of implementation

analog: cheaper, faster, larger bandwidth feasible whereas that would require a large number of coefficients for the filter kernel

analog: larger dynamic range