Forums

Low frequency component from FFT?

Started by jski April 2, 2012
As a DFT/FFT newbie I have a (probably naive) question: I was asked to
use an FFT to find the low frequency term in data collected from an
accelerometer. I used the routines in FFTW appropriate for 1D real-
valued data.  Looking at "out" - the array of complex-valued
coefficients for F - assuming the zero-th indexed value corresponds to
the lowest frequency, which is guaranteed to have a zero-valued
imaginary part:  how do I calculate the frequency from this value?

How do I calculate the frequency from any of F's complex coefficients?

---John
On Mon, 02 Apr 2012 12:29:49 -0700, jski wrote:

> As a DFT/FFT newbie I have a (probably naive) question: I was asked to > use an FFT to find the low frequency term in data collected from an > accelerometer. I used the routines in FFTW appropriate for 1D real- > valued data. Looking at "out" - the array of complex-valued > coefficients for F - assuming the zero-th indexed value corresponds to > the lowest frequency, which is guaranteed to have a zero-valued > imaginary part: how do I calculate the frequency from this value? > > How do I calculate the frequency from any of F's complex coefficients?
Question: How do you calculate the price of tea from a teacup? Answer: You don't have enough data. You don't calculate the frequency from the value in an FFT bin. The FFT bin sort of corresponds to a frequency range (it's more complicated than that), but to know that range you must know the sampling rate, then length of the FFT, and to make that knowledge useful it's exceedingly helpful to know the windowing function that was used. As a rough approximation, the center frequency of a given bin's response to the input is equal to the sampling rate times the bin number divided by the length of the FFT. So if you're sampling at 65536Hz, and you're taking a 65536-sample FFT, then bin 0's response is centered around 0Hz, bin 1's response is centered around 1Hz, etc. Question: If you're directed to do something that's not a good idea, should you do it? Answer: I don't know, but you'd better start thinking, because if all you want to do is low-pass the output of your accelerometer, there are far more efficient, and less error-prone, ways to go about it. -- My liberal friends think I'm a conservative kook. My conservative friends think I'm a liberal kook. Why am I not happy that they have found common ground? Tim Wescott, Communications, Control, Circuits & Software http://www.wescottdesign.com
>> assuming the zero-th indexed value corresponds to the lowest frequency
Hi, it may be only a simple mistake that needs fixing: The "first" bin is AFAIK the constant input term (at a frequency of zero). The "second" bin corresponds to a sine (cosine) wave with one cycle in your measurement period. The next bin to two cycles, and so on. You'll probably save time if you use matlab (or freeware "octave") for experiments, and only start coding in C when you know exactly what you want. Been there, got the T-shirt...