DSPRelated.com
Forums

FFT Frequency Range

Started by B S August 11, 2011
Hi,

I have one very simple question. I hope some one will clearify my doubts.

The
range of frequencies covered in the output record from the FFT is 0 to
1/2 the sample rate of the acquired data record. For example, a sample
rate of 20 MS/s (megasamples per second) would give an FFT range of 0 to
10 MHz.

Does it mean that I can only see proper FFT peak of the signal with maximum frequency 5 MHz ?

-BAS
QWxpYXNpbmcgY2FuIGJlIGF2b2lkZWQgaWYgdGhlIHNhbXBsZSBmcmVxdWVuY3kgaXMgdHdp
Y2UgdGhlIGZyZXF1ZW5jeSBvZiBpbnRlcmVzdC4gU28gaWYgeW91IHdhbnQgYSAwIHRvIDEw
IE1oeiBzaWduYWwgeW91IG11c3Qgc2FtcGxlIGF0IHR3aWNlZCBvciAyMCBNZWdhIHNhbXBs
ZXMgcGVyIHNlY29uZCBhbmQgZGVwZW5kaW5nIG9uIHdoYXQgeW91IGFyZSBkb2luZyB3aXRo
IHRoYXQgZGF0YSB5b3UgbWlnaHQgaGF2ZSB0byBnbyBoaWdoZXIgb3IgbG93ZXIgeW91ciBy
YW5nZS4gICANClNlbnQgb24gdGhlIFNwcmludK4gTm93IE5ldHdvcmsgZnJvbSBteSBCbGFj
a0JlcnJ5rgoKLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tCgpZb3UgY2Fu
IG5vdyBwb3N0IGEgbWVzc2FnZSBvciBhY2Nlc3MgYW5kIHNlYXJjaCB0aGUgYXJjaGl2ZXMg
b2YgdGhpcyBncm91cCBvbiBEU1BSZWxhdGVkLmNvbToKaHR0cDovL3d3dy5kc3ByZWxhdGVk
LmNvbS9ncm91cHMvYzZ4LzEucGhwCgpfX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f
X19fX19fCk5vdGU6IElmIHlvdSBkbyBhIHNpbXBsZSAicmVwbHkiIHdpdGggeW91ciBlbWFp
bCBjbGllbnQsIG9ubHkgdGhlIGF1dGhvciBvZiB0aGlzIG1lc3NhZ2Ugd2ls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vic2NyaWJlQHlhaG9vZ3JvdXBzLmNvbQoKPCo+
IFlvdXIgdXNlIG9mIFlhaG9vISBHcm91cHMgaXMgc3ViamVjdCB0bzoKICAgIGh0dHA6Ly9k
b2NzLnlhaG9vLmNvbS9pbmZvL3Rlcm1zLwoK
Uawideo,

I know about aliasing.
If sampling frequency is 351.56 kHz, then the maximum frequency represented in FFT is FS/2, or 175.78 kHz. Does it mean that freq. resolution will be calculated using 175.78 kHz ?

I have 1 kHz sine wave which is sampling at 351.56 kHz then I computed 512-point FFT. FFT magnitude shows peak at 4th sample which doesn't seem correct. If freq. resolution is 351.56 kHz/512 = 686.64 Hz then peak should appear at 2nd sample (686.64*2 = 1373.28 Hz).

Thats why I am wondering if discarding half of the FFT buffer should affect the freq. resolution ? If not then why peak is appearing at 4th sample ?

I appreciate your help.

BAS
________________________________
From: "u...@yahoo.com"
To: c...
Sent: Friday, August 12, 2011 5:31 AM
Subject: [c6x] Re: FFT Frequency Range

Aliasing can be avoided if the sample frequency is twice the frequency of interest. So if you want a 0 to 10 Mhz signal you must sample at twiced or 20 Mega samples per second and depending on what you are doing with that data you might have to go higher or lower your range.
Sent on the Sprint Now Network from my BlackBerry

_____________________________________

http://docs.yahoo.com/info/terms/
B S,

Your formula for the Delta_F = Fs/N seem to be correct.

Since the signal frequency is not an even multiple of
Delta_F, your FFT might have missed it, instead you are
catching one of the sidelobes.

You might want to simulate a signal at 1373.28Hz and
look at the FFT data.

Rgds,

Andrew

> Subject: Re: FFT Frequency Range
> Posted by: "B S" m...@yahoo.com matlab_fft
> Date: Fri Aug 12, 2011 1:47 pm ((PDT))
>
> Uawideo,
>
> I know about aliasing.
> If sampling frequency is 351.56 kHz, then the maximum frequency represented
> in FFT is FS/2, or 175.78 kHz. Does it mean that freq. resolution will be
> calculated using 175.78 kHz ?
>
> I have 1 kHz sine wave which is sampling at 351.56 kHz then I computed
> 512-point FFT. FFT magnitude shows peak at 4th sample which doesn't seem
> correct. If freq. resolution is 351.56 kHz/512 = 686.64 Hz then peak should
> appear at 2nd sample (686.64*2 = 1373.28 Hz).
>
> Thats why I am wondering if discarding half of the FFT buffer should affect
> the freq. resolution ? If not then why peak is appearing at 4th sample ?
>
> I appreciate your help.
>
> BAS

_____________________________________
BAS-

> I know about aliasing.
> If sampling frequency is 351.56 kHz, then the maximum frequency represented in FFT is FS/2, or 175.78 kHz. Does it
> mean that freq. resolution will be calculated using 175.78 kHz ?
>
> I have 1 kHz sine wave which is sampling at 351.56 kHz then I computed 512-point FFT. FFT magnitude shows peak at 4th
> sample which doesn't seem correct. If freq. resolution is 351.56 kHz/512 = 686.64 Hz then peak should appear at 2nd
> sample (686.64*2 = 1373.28 Hz).
>
> Thats why I am wondering if discarding half of the FFT buffer should affect the freq. resolution ? If not then why
> peak is appearing at 4th sample ?

3 possibilities:

1) Your sine wave is 2 kHz, not 1 kHz.

2) Your sampling rate is 700 kHz, not 350 kHz.

3) Your code is messed up.

My guess is #3. Suggest that you use CCS to capture a segment of your sampled 1 kHz sine wave and post as a .dat
file, then people on the group can run MATLAB or other program to eliminate #1 and #2.

-Jeff

_____________________________________
Jeff,

Sorry didn't have time to look over this problem earlier..

You were right, I encountered possiblity no. 3. Code is woring fine but that shows one strange spike at 512th sample that is out of my understanding. You can look the snapshot but I am trying to fix this problem.

http://i55.tinypic.com/jpii69.jpg
Thanks.

________________________________
From: Jeff Brower
To: BAS
Cc: c...
Sent: Sunday, August 14, 2011 11:19 PM
Subject: Re: [c6x] Re: FFT Frequency Range
 
BAS-

> I know about aliasing.
> If sampling frequency is 351.56 kHz, then the maximum frequency represented in FFT is FS/2, or 175.78 kHz. Does it
> mean that freq. resolution will be calculated using 175.78 kHz ?
>
> I have 1 kHz sine wave which is sampling at 351.56 kHz then I computed 512-point FFT. FFT magnitude shows peak at 4th
> sample which doesn't seem correct. If freq. resolution is 351.56 kHz/512 = 686.64 Hz then peak should appear at 2nd
> sample (686.64*2 = 1373.28 Hz).
>
> Thats why I am wondering if discarding half of the FFT buffer should affect the freq. resolution ? If not then why
> peak is appearing at 4th sample ?

3 possibilities:

1) Your sine wave is 2 kHz, not 1 kHz.

2) Your sampling rate is 700 kHz, not 350 kHz.

3) Your code is messed up.

My guess is #3. Suggest that you use CCS to capture a segment of your sampled 1 kHz sine wave and post as a .dat
file, then people on the group can run MATLAB or other program to eliminate #1 and #2.

-Jeff
BAS-

> Sorry didn't have time to look over this problem earlier..
>
> You were right, I encountered possiblity no. 3. Code is
> woring fine but that shows one strange spike at 512th sample
> that is out of my understanding. You can look the snapshot
>but I am trying to fix this problem.
>
> http://i55.tinypic.com/jpii69.jpg

Your spike at N/2 indicates a strong frequency component at Fs/2. For example if you're sampling at 20 MHz then your
plot shows significant energy at 10 MHz. If you don't think that's correct, then probably a coding or buffering
problem is still lingering.

One thing you might try is to feed your FFT all zeros and see if you still see the spike. If not, then feed it a 1
followed by zeros, etc. Basically try some simple inputs for which you expect specific output, and see what happens.

-Jeff

> ________________________________
> From: Jeff Brower
> To: BAS
> Cc: c...
> Sent: Sunday, August 14, 2011 11:19 PM
> Subject: Re: [c6x] Re: FFT Frequency Range
>  
> BAS-
>
>> I know about aliasing.
>> If sampling frequency is 351.56 kHz, then the maximum frequency represented in FFT is FS/2, or 175.78 kHz. Does it
>> mean that freq. resolution will be calculated using 175.78 kHz ?
>>
>> I have 1 kHz sine wave which is sampling at 351.56 kHz then I computed 512-point FFT. FFT magnitude shows peak at
>> 4th
>> sample which doesn't seem correct. If freq. resolution is 351.56 kHz/512 = 686.64 Hz then peak should appear at 2nd
>> sample (686.64*2 = 1373.28 Hz).
>>
>> Thats why I am wondering if discarding half of the FFT buffer should affect the freq. resolution ? If not then why
>> peak is appearing at 4th sample ?
>
> 3 possibilities:
>
> 1) Your sine wave is 2 kHz, not 1 kHz.
>
> 2) Your sampling rate is 700 kHz, not 350 kHz.
>
> 3) Your code is messed up.
>
> My guess is #3. Suggest that you use CCS to capture a segment of your sampled 1 kHz sine wave and post as a .dat
> file, then people on the group can run MATLAB or other program to eliminate #1 and #2.
>
> -Jeff

_____________________________________
Jeff,
I am sure code is working fine. Some thing is wrong with memory, some variables are overwriting and showing different values than expected which is causing a peak at 512th samples. Don't know how to figure out what's going on..

________________________________
From: Jeff Brower
To: BAS
Cc: c...
Sent: Friday, September 2, 2011 8:25 PM
Subject: Re: [c6x] Re: FFT Frequency Range
 
BAS-

> Sorry didn't have time to look over this problem earlier..
>
> You were right, I encountered possiblity no. 3. Code is
> woring fine but that shows one strange spike at 512th sample
> that is out of my understanding. You can look the snapshot
>but I am trying to fix this problem.
>
> http://i55.tinypic.com/jpii69.jpg

Your spike at N/2 indicates a strong frequency component at Fs/2. For example if you're sampling at 20 MHz then your
plot shows significant energy at 10 MHz. If you don't think that's correct, then probably a coding or buffering
problem is still lingering.

One thing you might try is to feed your FFT all zeros and see if you still see the spike. If not, then feed it a 1
followed by zeros, etc. Basically try some simple inputs for which you expect specific output, and see what happens.

-Jeff

> ________________________________
> From: Jeff Brower
> To: BAS
> Cc: c...
> Sent: Sunday, August 14, 2011 11:19 PM
> Subject: Re: [c6x] Re: FFT Frequency Range
>  
> BAS-
>
>> I know about aliasing.
>> If sampling frequency is 351.56 kHz, then the maximum frequency represented in FFT is FS/2, or 175.78 kHz. Does it
>> mean that freq. resolution will be calculated using 175.78 kHz ?
>>
>> I have 1 kHz sine wave which is sampling at 351.56 kHz then I computed 512-point FFT. FFT magnitude shows peak at
>> 4th
>> sample which doesn't seem correct. If freq. resolution is 351.56 kHz/512 = 686.64 Hz then peak should appear at 2nd
>> sample (686.64*2 = 1373.28 Hz).
>>
>> Thats why I am wondering if discarding half of the FFT buffer should affect the freq. resolution ? If not then why
>> peak is appearing at 4th sample ?
>
> 3 possibilities:
>
> 1) Your sine wave is 2 kHz, not 1 kHz.
>
> 2) Your sampling rate is 700 kHz, not 350 kHz.
>
> 3) Your code is messed up.
>
> My guess is #3. Suggest that you use CCS to capture a segment of your sampled 1 kHz sine wave and post as a .dat
> file, then people on the group can run MATLAB or other program to eliminate #1 and #2.
>
> -Jeff