Determining slow AI period with FFT in audiomaster ?

Status
Not open for further replies.

heliboy

Active member
I have an application trying to measure the period of an essentially sinusoidal oscillation. These are signals from a 3-axis accelerometer (I2C), although I could alternatively use a analog output accelerometer. The signal is very slow ranging from 0.1 to 0.6 Hz. I am using a teensy 3.1.

My question is it possible to use the functions in audiomaster to do this ? I was thinking of high-pass filter to get rid of steady signals, then maybe a low pass filter to get rid of fast vibration noise (>1Hz). Then process via the FFT to get the frequencies and voila the period. I could not find any documentation on audiomaster so I trying to work my way through the examples and stuff on the forum.

Any help or comments appreciated.
 
My feeling is basically no, the audio library would not be a useful approach.

The 2 input objects have high-pass filters, which could be defeated, but by default that will filter away such a low frequency. The FFT object is only 256 points, which means the frequency bins are 172 Hz, which is far from the resolution you seek.

Even if you had an extremely long FFT, or if the library operated at a much lower sample rate, discrete fourier transform is a pretty terrible way to measure a frequency. The trouble is that the FFT output is discrete bins. To get higher resolution, you need a very long FFT, which would be many minutes or even hours of data to get high resolution for such a low frequency. Even then, the FFT behaves pretty badly if the frequency falls anywhere that's not close to the center of a bin. Normally the input is multiplied by a window function, which minimizes those effects, but it also smears the peak over a few bins.

The FFT is very good at telling you if an approximate frequency is present, and with a "flat top" window, it can be very good at telling you the amplitude of that frequency. Fourier transform is excellent at giving you good info even when there are lots of other signals present at other (not close by) frequencies. If there's a lot of higher frequency noise or other higher signals mixed in, the FFT might be worth investigating, despite all its limitations.

But if you have a pretty clean waveform and you just want to measure the frequency, by far the best approach is turning it into a square wave and measuring the elapsed time between edges. On a Teensy 2.0, you could use the FreqMeasure library. On either, you could use attachInterrupt() and read micros() to a variable or small array, and then in your main program compute the frequency based on the elapsed time.
 
Status
Not open for further replies.
Back
Top