FFT resolution and sampling frequency

I am computing FFT of the data which I am receiving from an ADC with SPI protocol. Since resolution of FFT is related to $F_s/N$ where $N$ is the FFT length and $F_s$ is the sampling frequency of ADC, when I lower sampling frequency, it should decrease frequency range that I see due to Nyquist–Shannon sampling theorem and conversely it should also increase my FFT resolution.

I am plotting this FFT in realtime and I've given 1 Hz sinusoidal signal via arbitrary signal generator and tested various sampling frequencies to see which point 1 Hz equals to.

╔═══╦═══════════════╦═══════════════╗
║   ║ Sampling Freq ║ Point of 1 Hz ║  0. point included
╠═══╬═══════════════╬═══════════════╣
║ 1 ║ 20k           ║ 3             ║
║ 2 ║ 10k           ║ 6             ║
║ 3 ║ 1k            ║ 9             ║
║ 4 ║ 100           ║ 9             ║
╚═══╩═══════════════╩═══════════════╝


No matter how I lower sampling frequency, it doesn't go further than 9. By the way, my FFT length is 1024.

One issue is that, for the first two sampling frequencies, you are not sampling a full wave of the signal.

Below is a plot of the time domain signal (1024 samples) and the resulting FFT. For the first two, the DC bin (0 index) will capture all the energy. For the 1kHz example, the first bin (the one after 0 index) will capture it. Bin 10 is where the peak is for 100 Hz sampling rate.

Perhaps your sampling isn't happening quite the way you expect?

R Code Below

# 43563

N <- 1024

fs <- c(20000, 10000, 1000, 100)
res <- c(0,0,0,0)
idx <- 1

par(mfrow=c(4,2))
for (freq in fs)
{
res[idx] <- freq / N
idx <- idx + 1
t <- seq(0,N-1) / freq
x <- sin(2*pi*t + 0.892340923)
plot(x, type='l')
title(paste('time domain for ', freq))
x_fft <- abs(fft(x))
plot(x_fft[1:100], type='l')
title(paste('100 bins in frequency domain for ', freq))
}

• You were right. My sampling isn't happening quite the way I expected.
– Pyro
Sep 5, 2017 at 14:02
• @Peter K. This was great ( I'm an R person also ) but what was the reason for adding 0.892 inside the sine function. Thanks. Dec 9, 2017 at 16:08
• @markleeds Because otherwise sin(2*pi*t) = 0 or all integer t. I realize this isn't the case here, but I am in the habit of putting a non-zero phase offset on my cos and sin terms. I've been caught too many times finding wonderful things happening, only to have them fall apart because of the phase offset not being zero.
– Peter K.
Dec 9, 2017 at 20:38
• @Peter K. Gotcha. Thanks. This whole thread and particularly your post, helped me tounderstand better what's going on with the DFT. FFT education is down the road for me. All the best. Dec 10, 2017 at 3:21

You can estimate your frequency resolution through your sampling rate and the length of the FFT with the following formula:

Freq_Resolution = Sampling_Rate/length_FFT


Which in your case should be

19.5   9.75   0.97    0.09


This is why I am confused how you get your results.

For 20k and 10kHz Fs (Sampling Rate) the first bin of your fft is including the 1Hz.

In the case of 1kHz Fs it should be around the 1-2 bin depending how you are rounding. And the bin 11-12 for the 100Hz Fs.

So the question is how are calculating the bin/point?

• If the frequency (bin) resolution for 1kHz is 0.97Hz, why should the bin be $10 \times 0.97$ for 1Hz?
– Peter K.
Sep 5, 2017 at 14:04
• You are right I. Some how I was thinking of 10 Hz instead of 1 Hz Sep 6, 2017 at 5:18