EE 451

Lab 3: Frequency Response of Difference Equations

An Nth-order linear constant-coefficient difference equation is of the form


\begin{displaymath}\sum^N_{k=0} a_k \, y[n-k] = \sum^M_{k=0} b_k \, x[n-k]. \end{displaymath}

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

y[n] = 0.5 y[n-1] - 0.7 y[n-2] + 0.75 x[n] + 0.75 x[n-3]

1.
Find the impulse response h[n] of the system.

2.
Find the Fourier transform $H(e^{j \omega})$ of the impulse response.

3.
Plot the magnitude of $H(e^{j \omega})$ vs. $\omega$ and the phase of $H(e^{j \omega})$ vs. $\omega$.

4.
The 56002 samples signals at 48 kHz. Thus the Nyquist frequency is 24 kHz. The highest possible discrete-time frequency is $\pi$, and this corresponds to the Nyquist frequency of 24 kHz. Plot the magnitude of $H(e^{j \omega})$ vs. the input continuous-time frequency f, and the phase of $H(e^{j \omega})$ vs. the input continuous-time frequency f.

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 a1, a2, b0, b1, b2, and b3. 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.



Bill Rison
1999-09-10