LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Getting wrong frequency from fft?

Hi,
Im trying to use FFT on a 140Hz sine wave and i only get valid results if my samplerate is equal to the number of samples i use.
Like if I use 10kHz sample speed and say 50k samples the fft reports it as about 700Hz.
How do I work around this?
0 Kudos
Message 1 of 7
(4,236 Views)
Are you using arrays or waveforms? The waveform datatype includes sample rate information (dt) and the spectrum analysis VIs can use it. If you are using arrays for your data, you need to explicitly calculate the dt = 1/df. Make sure you are doing these calculations correctly.

If this does not resolve the issue for you, please post your VI with a set of the incorrect data saved as default.

Lynn
Message 2 of 7
(4,224 Views)

Im using arrays,  im not sure how to use the fact that
dt = 1/df? i tried to input it in the fft block, but it doesn't make any differance?
I've attached the part of the vi thats supposed to do the fft stuff.

//Kongo

Message Edited by Kongo on 05-23-2007 09:50 AM

0 Kudos
Message 3 of 7
(4,218 Views)
See attachment... The Y-axis data was correct - it was the X-Axis on your plot that was hosed. A graph like you were using shows the Y-axis data relative to their position in the array - essentially, the X-axis value increments by one for each datapoint. Unfortunately, (as the fft function was telling you) there is an increment of .2 Hz between successive points so the X axis needs to increment by .2 from one data point to the next. To plot his data correctly you need to use an XY plot.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 4 of 7
(4,212 Views)
Another approach is to use the X Scale Multiplier property node on the graph.

Another way is to convert to waveform data type.

Lynn
Message 5 of 7
(4,204 Views)
A plain array output has no timing information.
 
If you wire dt, you need to make use of the df output. Simply feed it to the "xscale.multiplier" property.
 
(Same as if you want to plot the input data correctly, you would need to wire dt to the "xscale.multiplier" property. If you don't, dt is assumed to be 1 in all cases.)
 
(You never need an xy graph if the points are spaced equally :))

Message Edited by altenbach on 05-23-2007 08:23 AM

Download All
Message 6 of 7
(4,202 Views)
Thank you everyone for the replies, it works! 🙂

Message Edited by Kongo on 05-23-2007 10:26 AM

0 Kudos
Message 7 of 7
(4,197 Views)