Sometimes, when you’re working with waveforms, it’s helpful to get a live picture of the frequency spectrum. Since I’m trying to develop audio visualization algorithms, I thought it would be a good idea to create a tool to plot the FFT of a signal. I was inspired by this excellent project, which uses an Atmel ATMEGA8 and an LCD to display a waveform and its corresponding FFT with a delay only on the order of milliseconds. The project designer built a nice FFT library, which I incorporated into my project along with his recommendation for an anti-aliasing filter.
The problem was that I didn’t have an LCD to play with, so I had to settle for something slightly different; I wrote up a quick block to display the FFT data on my trusty Tektronix 335 oscilloscope.
There are basically two parts to the modification: first, I created an 8-bit DAC resistor ladder so that I could represent the intensity of each frequency of an FFT as an analog value. Secondly, I created a low-frequency clock line that changed with each transition to a new frequency. Finally, I just needed to trigger on the clock line with the oscilloscope to be able to view the full FFT. This is easier to explain with a picture:
This FFT from an audio clip shows a large low-frequency component and a smaller mid-range component. I tried playing some sine waves, sawtooth waves, etc. as well and the output was pretty accurate. Here are a few pics of my setup (yes, I’m really bad at board layouts):
There are still a few major problems that I need to work through. The biggest one is due some pretty painful noise coming from the clock lines and what looks to be my computer. The latter can probably be solved by implementing a decent filter, though I’m not sure how the other project’s designer had so much success with his setup. The other sources of noise seem to be coming from the clock lines and other lines around the board. These can be solved by properly implementing this circuit on a PCB like the author did. I’m seeing a lot of strange low-frequency noise in the FFT as well (the quick fix was to just remove the lowest few bars from the FFT output). In addition to solving the noise problem, I need to fine tune some of the delay values I have for oscilloscope output to make it look better.
I’ll have code and schematics up in a few days.