Tell me more ×
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It's 100% free, no registration required.

If I have sampled a signal using proper sampling methods (Nyquist, filtering, etc) how do I relate the length of my FFT to the resulting frequency resolution I can obtain?

Like if I have a 2,000 Hz and 1,999 Hz sine wave, how would I determine the length of FFT needed to accurately tell the difference between those two waves?

share|improve this question

4 Answers

up vote 18 down vote accepted

The frequency resolution is dependent on the relationship between the FFT length and the sampling rate of the input signal.

If the sampling rate of the signal is 10khz and we collect 8192 samples for the FFT then we will have:

8192 / 2 = 4096 FFT bins

Since, via nyquist, our signal contains content up to 5khz our bin resolution is:

5000Hz / 4096 bins = 1.22 Hz/bin

This is may be the easier way to explain it conceptually but simplified, your bin resolution is just:

\$\frac{F_S}{N}\$

where \$F_S\$ is the input signal's sampling rate and N is the number of FFT points used.

We can see from the above that to get smaller FFT bins we can either run a longer FFT or decrease our sampling rate.

The Catch:

There is always a trade off between temporal resolution and frequency resolution.

In the example above, we need to collect 8192 samples before we can run the FFT, which when sampling at 10khz takes 0.82 seconds.

If we tried to get smaller FFT bins by running a longer FFT it would take even longer to collect the needed samples.

That may be OK, it may not be. The important point is that at a fixed sampling rate, increasing frequency resolution decreases temporal resolution. That is the more accurate your measurement in the frequency domain, the less accurate you can be in the time domain. You effectively lose all time information inside the FFT length.

In this example, if a 1999Hz tone starts and stops in the first half of the 8192 sample FFT and a 2002Hz tone plays in the second half of the window, we would see both, but they would appear to have occurred at the same time.

You also have to consider processing time. A 8192 point FFT takes some decent processing power. A way to reduce this need is to reduce the sampling rate, which is the second way to increase frequency resolution.

In your example, if you drop your sampling rate to something like 4096 Hz, then you only need a 4096 point FFT to achieve 1hz bins and can still resolve a 2khz signal. This reduces the FFT bin size but also reduces the bandwidth of the signal.

Ultimately with an FFT there will always be a trade off between frequency resolution and time resolution. You have to perform a bit of a balancing act to reach all goals.

share|improve this answer
with header tags and some formatting this post could go from good to great. You touched on everything I wanted to note, and very well, but the way the post is formatted fewer people will read it as its length is prohibitive, if you give headers with each section of what you are discussing people will jump to the juicy bit that suites them and your number of +1s will increase a lot. Not from me of course, as you already earned it. – Kortuk Apr 1 '11 at 18:53
@kurtuk I spit this one out in a rush, I'll clean up the formatting when i have some spare time (or feel free to edit it if you wish). – Mark Apr 1 '11 at 19:19
1  
@kortuk, name starts with an 'o'. I assumed you had, I was just sharing my view, both for you if you did not already know, but more for the community on the whole. – Kortuk Apr 2 '11 at 15:45
Note that you don't have to calculate the FFT. If you only want to know a few bins, it's cheaper to calculate the DFT of just those bins, than to run an optimized FFT which calculates all the bins at once by sharing many of the operations. – Chris Stratton Jan 26 at 0:10

Basic FFT resolution is \$f_s \over N\$, where \$f_s\$ is the sampling frequency.

The ability to differentiate two very closely spaced signals depends strongly on relative amplitudes and the windowing function used.

You may find that playing with the Baudline signal analyzer is a good way to develop some intuition on this matter - and no, running some FFTs and plotting one spectrum at a time in Matlab or Python/Numpy is really not the same.

EDIT: There is also a trick to pad the input with zeros and taking a bigger FFT. It will not improve your differentiation ability but may make the spectrum more readable. It is basically a trick similar to antialiasing in vector graphics.

share|improve this answer
Am I the only one who doesn't see the Latex code displayed properly formatted? – stevenvh Apr 1 '11 at 16:59
@stevenvh Not work for me too. – msutherl Apr 1 '11 at 18:40
Works for me. The latex is only 2 places. – Kortuk Apr 1 '11 at 18:49
Fixed (already for some time). Firefox's NoScript add-on blocked mathjax.org. – stevenvh Jul 15 '11 at 17:34

It's worth noting that an FFT is an alternative to computing a number of separate pairs of sums (k=0..sample_length-1) of Sample[k]*SineRefWave[j][k] and Sample[j]*CosRefWave[j][k], for all j up to half the sample length. If one needs amplitude readouts at all those frequencies, an FFT will compute them all in O(NlgN) time, whereas computing them individually would take O(N^2) time. On the other hand, if one only needs amplitude readouts at a few frequencies, one will often be better off simply computing them individually, especially if one is using a processor or DSP which can efficiently compute that style of sum.

share|improve this answer

The frequency resolution does not depend on the length of FFT, but the length of the total sampling time T, i.e. it's 1/T, which is also the lowest frequency component you obtained.

Note, zero padding does not increase the frequency resoltuion; DFT of the zero padding signal is merely a better approximation of the DTFT of the orginal signal.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.