Electronic – Relationship of FFT Size, Sampling Rate and Buffer Size

fftsampling

I am asking this question because I want to make sure I understand the relationship of FFT length, the sampling rate and the buffer size. This question is with respect to the CMSIS DSP library, although I imagine it could be any FFT processing function.

Because of configuration constraints, my ADC is sampling at a rate of 10.68ksps. Then, I am taking the average of 4 samples to end up at a rate of 2.67kbps. I need resolution of 0.5Hz for signals from 100Hz to 300Hz. So here's the part I am missing – I do not understand what sample rate I need to scale to in order to properly conserve frequency information. For example, if I wanted to run a 1024 length FFT, what sample rate should I scale to, and what buffer size should I pass to the fft function?

I do have it working, but the bin information is not quite correct – for example, it is out by 1 bin at 100Hz, but 2 bins at 300Hz. I'm sure it's related to the odd sampling rate.
Do I need a sampling rate that is equal to the FFT length? And how does the buffer size passed in impact the operation?

Thank you for any answers.

Best Answer

There is a direct, and actually quite simple, relationship between all the figures.

Let's start with the sample size. The numbers of bins (or "buckets") is equal with half of the samples in your set. For instance, if you have 1024 samples, then you get 512 bins. As simple as that.

Now for the sample rate. The maximum frequency is half the sample rate (see Nyquist-Shannon sampling theorem). So if you have a sample rate of 2.67ksps then your frequency range is 0-1.335kHz.

Again pretty straight forward - just another divide by two.

Now the bins are spread evenly over the frequency range - so your 512 bins, over 1355Hz is 2.607421875 Hz per bin.

For 0.5Hz per bin up to 300Hz you want 600 bins. Your target sample rate would be 600Hz. How you down-sample to that would be up to you.

Most FFT code I have seen works on 2n sample sizes, so 600 bins isn't a nice number. That would be 1200 samples - not a 2n. So you'd probably want to round it up to 211, or 2048 samples. That would give you 1024 bins, and you'd want a target sample rate of 1024sps for 0-512Hz range.

Related Topic