ECE107 Project

The Challenge: To write a computer program to detect the presence of a particular fequency of an input, in this case W = p/2.
The program should detect this fequency by two different methods, a nonrecursive filter and a FFT design.

Oscillator
x[n] = Cos (Wn), 0£n£7

Enter a value for W (in degrees): p/2 p/4

Nonrecursive Filter
Design a nonrecursive filter that responds strongly to W = p/2
Start with an ideal lowpass filter with unity passband gain in the range -p/8 < W < p/8
Since the input is LTI (linear time invariant), the impulse response can be written as such:
      
I will only keep terms corresponding to -15 <= n <= 15 for this impulse response creating a desired impulse response with a window M = 15. This desired hd[n] impulse response looks as such:
Using a Hamming window to improve the filter response with equation w[n] = 0.54 + 0.46 * cos(np/M) where M=15
This gives the actual impulse response ha[n] = hd[n] * w[n]
Here is a graph of ha[n]:
The next two steps will be combined. In order to achieve a bandpass filter with its peak response at p/2, ha[n] is multiplied by cos(np/2)
The result is then shifted forward to begin at n = 0
Here is a graph of that result:
To implement the filter, the convolution of ha[n] and the input x[n] is taken
The graph of y[n] = ha[n]·x[n] is shown below for the input selected above:
As you can see, the response of the filter to x[n] is greatest when W = p/2

FFT (Fast Fourier Transform)
An 8 point, radix-2, in-place, decimation-in-time FFT is defined in stages as follows:

      
A graph of |X[k]| for the input selected above looks like this:
Once again |X[k]| responds in greater magnitude to W = p/2 and in a unique fashion.