I am working on a pedometer application and I am running a real-time fft on accelerometer data where I use the arduinoFFT (kosme) library on an Arduino 101.
So let's say my sampling frequency is at 100Hz. I am interested in the up an down motion of the body which matches walking or running frequencies at around 1-4Hz. Many of the libraries including the one I am using seem to have a compute magnitude function. This effectively gives me half the number of bins used number of amplitudes (if I was inputting 64 samples, it will give me 32 amplitudes).
So my question is what frequencies does these amplitudes correspond to? In the example code the library provides, the frequencies are calculated as follows:
for (int i=0; i<(noofbins>>1); i++) {
freq[i]=((i*samplingfreq)/(noofbins>>1));
}
I truly do not understand why this is the case and please excuse me if I am being completely silly about it. Furthermore, this indeed gives me frequencies from 0 to 100Hz (the sampling frequency I use). Is there any way of refining the fft about the frequency of interest without lowering the sampling frequency to 'match' it (which would be a terrible idea here)?
Fs / N = 100 / 64 = 1.5625 Hz
in your case - so bin index 3 will correspond to a frequency of3 * 1.5625 = 4.6875 Hz
- see linked duplicate answer for more details. – Paul R