An *N*th-order linear constant-coefficient difference equation is of the form

The frequency response of such a system can be determined by finding its
impulse response *h*[*n*], and taking the Fourier transform of *h*[*n*]. In
this week's lab, you will implement a second-order difference equation
in real time, measure its frequency response, and compare it to the
theoretical response.

Consider the difference equation

- 1.
- Find the impulse response
*h*[*n*] of the system. - 2.
- Find the Fourier transform
of the impulse response.
- 3.
- Plot the magnitude of
vs.
and the phase of
vs.
using MATLAB (or some other program).
- 4.
- The 56002 samples signals at 48 kHz. Thus the Nyquist frequency
is 24 kHz. The highest possible discrete-time frequency is ,
and
this corresponds to the Nyquist frequency of 24 kHz. Plot the magnitude
of
vs. the input continuous-time frequency
*f*, and the phase of vs. the input continuous-time frequency*f*using MATLAB (or some other program). - 5.
- Implement the difference equation on the 56002. Use the program
from Lab 2 which reads data from the A/D and writes it to the D/A at
48 kHz. Between reading and writing the data, process it with the
difference equation. On one channel of the D/A put out the processed
data. On the other channel put out the unprocessed data. You will have to
set aside storage locations for
*x*[*n*-1],*x*[*n*-2],*x*[*n*-3],*y*[*n*-1] and*y*[*n*-2]. To do this, you should set aside storage for these variables in one of the data spaces. Here is how you might set aside storage for*x*[*n*-1]:org x:$100 ; put data starting at $100 in X data space ynm1 ds 1 ; set aside one word for y[n-1]

You also need to set aside storage for the coefficients

*a*_{1},*a*_{2},*b*_{0},*b*_{1},*b*_{2}, and*b*_{3}. Here is how you might do that:org y:$0 ; put data starting at $0 in Y data space a1 dc -0.5 ; set aside one word for a1

You could then calculate

*y*[*n*] like this:move x:ynm1,x0 move y:a1,y0 mpy -x0,y0,a ; -a1 y(n-1) -> acc a move x:ynm2,x0 move y:a2,y0 mac -x0,y0,a ; -a1 y(n-1) -a2 y(n-2) -> acc a

When you get done calculating

*y*[*n*] you will need to update your variables: what is now*x*[*n*-1] will, next time through, be*x*[*n*-2]:move x:xnm1,x0 ; Replace x[n-2] by x[n-1] for next pass move x0,xnm2 ; through filter

- 6.
- Use a sine wave from your function generator. Measure
and plot the amplitude and phase of the output from 100 Hz to 20 kHz.
Compare to the plots of Part 3. One possible way to plot your data is to
record the data in a table, and then enter it into MATLAB. You can then plot
your data points as, say, and `
*o*', and plot it over the plot you made for Part 4. - 7.
- Use an audio CD as a signal source. How does the music sound different
after being filtered?