[DSP homepage]

Lab Exercise:

A Notch Filter

This exercise should be done in Excel.

Use Excel to simulate the following difference equation for at least 1000 steps (up to n=1000):

y(n) = -r2 y(n-2) + 2 r cos( w0 ) y(n-1) + x(n-2) - 2 cos ( w0 ) x(n-1) +x(n)

with input

x(n) = cos (2 pi f0 n / 8000) u(n)

(a cosine of frequency f0 sampled at
a rate of 8000 Hz starting at t=0)

and all initial conditions zero.

Use the values of r, w0, and f0 assigned to you. [parameter assignments]

Plot both the input and output on a single XY(scatter) graph.

Verify the results of your simulation by solving the difference equation with the given input and initial conditions. This may be done by either

Graph the particular solution and compare it with the output of the simulation. Since the input is a cosine, the particular solution may be expressed as a cosine of the same frequency, but possibly of a different amplitude and phase:

yp(n) = A cos( 2 pi f0 n / 8000 - phi) u(n)

What is the magnitude and phase of the particular solution?

 

"Vector form" of the difference equation:

The difference equation may also be written as

y(n) = [-r2    2r cos(w0)] * [y(n-2)   y(n-1)]) ]T + [1   -2cos(w0)   1] * [x(n-2)   x(n-1)   x(n)]) ]T .

One way of implementing the difference equation would be to use the MMULT function of Excel, which multiplies matrices, and hence, vectors as well. In this rendering of the difference equation, constant vectors are multiplied with variable vectors containing past and present inputs and outputs. Note that CTRL-SHIFT-ENTER should be used in entering matrix multiplication formulas.

About the difference equation:

The difference equation is that of a notch filter with poles, as described in sec. 4.5.4. The difference equation may be written as

y(n) - 2 r cos( w0 ) y(n-1) + r2 y(n-2) = x(n) - 2 cos ( w0 ) x(n-1) +x(n-2).

Taking z-Transforms of this equation, factoring out Y(z) and X(z), and computing the ratio Y(z)/ X(z) gives the system function

H(z) = [ 1 - 2 cos ( w0 ) z-1 + z -2 ] / [ 1 - 2 r cos( w0 ) z-1 + r2 z-2 ]

which is essentially equation (4.5.31) of sec. 4.5.4. On the other hand, we may reverse the process and obtain the difference equation from this system function. Every system function has an equivalent difference equation, and vice versa.

If the input to this system is a sinusoid (either a sine or a cosine) at the resonant frequency, the output goes to zero.

 


 

This page has been accessed
Counter
times since January 18, 2002.

Last updated: January 18, 2002
lui_agustin@yahoo.com
1