Digital Introduction – Digital Filters

A Digital Filter is used to modify a digital signal by passing certain frequencies and attenuating others. This Digital Signal might come from an Analog to Digital converter. It might also be generated by a computer. The range of frequencies that pass through the filter without attenuation is called the passband. A filter that attenuates high frequencies is called low pass. What does a high pass filter do? Bandpass? Band Pass Filter Demo (Installation instructions):

Passband = 750 – 1250 Hz

Stop Band Attenuation Transition = 40 dB Bands

Stop Bands=1-500 Hz, 1.5KHz to 5.5KHz

CD quality audio is low pass filtered to 20 KHz. Why? Telephone signals are low pass filtered to 3.3 KHz. Why? Your stereo’s bass and treble knobs control the volume of the built-in low pass and high pass filter outputs before they are added back together.

Z:\Home\cse465\Lectures\Lecture 3 - DSP Introduction.doc Page 1 of 4 Digital Filters

There are many types of Digital Filters. In this class, we will use FIR (Finite ) Linear Phase (constant delay) filters. One way to implement a Digital Filter is to multiply the Filter Frequency Response (FrequencyDomain graph, green trace) and the of the input (FrequencyDomain graph, white trace). Then take the inverse Fourier Transform of the result. The Inverse Fourier Transform of the Filter Frequency Response is called the Impulse Response of the filter. A more common way to implement a Digital Filter is to convolve the input (TimeDomain graph, white trace) with the Impulse Response of the Filter. (Multiplication in the FrequencyDomain is equivalent to in the Time Domain for a Linear Time Invariant system,) Use a tool like LPFDesign or BPFDesign (installed on the Urbauer 115 computers) to generate the Impulse Response for your filter constraints (shown in the text boxes above). Question: What operation do Digital Signal Processors (DSPs) do better than traditional microprocessors?

Z:\Home\cse465\Lectures\Lecture 3 - DSP Introduction.doc Page 2 of 4 Convolution

So, if x[n] is the input to the filter, h[n] is the impulse response, and y[n] is the output of the filter, y[n] x[n]*h[n] x[k]h[n k] k For h(white), x(red) and y(green) shown below:

n y[n] x[k]h[n k] since h[k] 0 for k 0 and k 4 k n 4 So, for example

y[6] x[2]*h[4] x[3]*h[3] x[4]*h[2] x[5]*h[1] x[6]*h[0] y[6] 3.8

y[7] x[3]*h[4] x[4]*h[3] x[5]*h[2] x[6]*h[1] x[7]*h[0] y[7] 3.6

In other words, Reverse h in time around 0. y[n] is the dot product of x and the reversed h with h[0] at point n.

Z:\Home\cse465\Lectures\Lecture 3 - DSP Introduction.doc Page 3 of 4 This low pass filter shown above is called a moving average or a sinc filter. Note the delay of the filter (N-1)/2 = 2 samples where N is the length of the Impulse Response. The elements of the Impulse Response are often called Taps or the Filter Coefficients.

Fractional Arithmetic

Typically, the filter coefficients are expressed as numbers from -1 to 1. To solve this problem using integer math, use 2’s complement, fixed point representation with the binary point between the MSB (sign bit) and the next most significant digit. In a 16 bit system, this is called 1.15 or Q-15. For example,

0.110 0000 0000 0000 = 0+2-1+2-2 = 0.75 1.110 0000 0000 0000 = -20+2-1+2-2 = -0.25 0.111 0000 0000 0000 = 0+2-1+2-2+2-3 = 0.875 1.111 0000 0000 0000 = -20+2-1 +2-2+2-3 = -1+0.875= -0.125

The product of two 1.15 numbers will be 2.30. For example:

0.75 * 0.875 = 0.65625

In 1.15,

0.110 0000 0000 0000 x 0.111 0000 0000 0000 ______0110 0000 0000 0 000 0000 0000 0000 + 0 1100 0000 0000 0 000 0000 0000 0000 + 01 1000 0000 0000 0 000 0000 0000 0000 ______00.10 1010 0000 0000 0 000 0000 0000 0000 = 2-1 + 2-3 + 2-5 = 0.5+0.125+0.03125=0.65625

To convert a floating point number to fractional (1.15), multiply the floating point number by 32768. For example,

-0.125*32768 = -4096(16.0) = 0xf000 = 1.111 0000 0000 0000(1.15) 0.875*32768 = 28672(16.0) = 0x7000 = 0.111 0000 0000 0000(1.15)

Z:\Home\cse465\Lectures\Lecture 3 - DSP Introduction.doc Page 4 of 4