LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Verify bin at certain frequency

hello,  

 

I am using the FFT method to get the amplitude of a desired frequency of a inputted sing wave. the frequency is 200 Hz, I can get the peak at this frequency bin as shown. I just can not  get the exact voltage reading at 200 Hz.  It is probably right in front of my face. I do not have a lot of experience with FFT and do not have any coworker to shoot ideas off of . I know this is using a Labjack DAQ device it works quite good.   I am trying to learn more about the use of FFT with LabVIEW.  Thanks for any advice. 

fft VI.PNG

bin.PNG

0 Kudos
Message 1 of 10
(4,215 Views)

@montcuky wrote:

I am using the FFT method to get the amplitude of a desired frequency of a inputted sing wave. the frequency is 200 Hz, I can get the peak at this frequency bin as shown. I just can not  get the exact voltage reading at 200 Hz. 


I'm not sure what exactly you are looking for.  You just want to filter out the 200Hz signal and get the peak measurement on it?



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 10
(4,199 Views)

What's the loop rate? I.e. do your samples always cover an integer number of oscillations? If you cannot guaranteed that, you'll get spectral leakage and a distorted peak that is wider than one bin. It can be partially fixed by windowing. If you look at the default data in the plots, the time trace does not match if you would append multiple such segments.

 

If you know the frequency exactly, you actually don't even need to do a FFT. You can just extract the amplitude of that single frequency.

0 Kudos
Message 3 of 10
(4,192 Views)

To be more illustrative, here's the same code using a variable subset of the 5000 point data in your V vs t graph.

 

As you can see the full length will give you spectral leakage, but if you would be truncating to 4985 points instead the start and end of the time trace mesh near perfectly and the FFT will give you a single bin.

 

 

altenbach_0-1639500009987.png

 

FFT assumes that all frequency components have an integer number of cycles and if start&end don't mesh, you violate that. There is not wave with an integer number of periods that can match your data and you'll get a hiccup that requires a significant amount of other frequencies.

 

Here's how it looks if we append two of your datasets. Notice anything unusual at the splice point?

 

altenbach_1-1639500512460.png

 

 

 

 

Message 4 of 10
(4,167 Views)

I am just experimenting using a wave generator to input a known sine wave to understand how to use FFT operations with LabVIEW.   I am not really understanding you last point. So it seems that is is the bin is skewed a little.  

 

I was think of some way  to filter out the 200Hz signal and get the peak measurement on it  , just like you stated. 

 

I am not sure how to fix the distorted peak, or of that matter not sure how to  apply windowing to fix it.  

 

thanks 

0 Kudos
Message 5 of 10
(4,112 Views)

@montcuky wrote:

I am just experimenting using a wave generator to input a known sine wave to understand how to use FFT operations with LabVIEW.   I am not really understanding you last point. So it seems that is is the bin is skewed a little.  


FFT is the same, independent of the programming language. Maybe some textbooks would help?

 

All frequency components of an FFT have an integer number of cycles over the data interval, so if your main frequency component does not have an integer number of cycles, it cannot be characterized with a single frequency bin in the transform.

0 Kudos
Message 6 of 10
(4,110 Views)

I strongly recommend a sine fit (or extract single tone information) and monitor the residual.

The phase jump shown will mess up FFT and tone detection (and sine fit) ... only a RMS measurement would be more robust...

 

So you need to make shure to avoid these phase jumps! 

Detection via rms of residuals (or RMS of all other FFT bins) or if you apply a  300 Hz highpass filter on the signal  the jump will show up. 

 

Looks like a non continious data aquisition or a failed continious sine generation to me  😉

 

 

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


0 Kudos
Message 7 of 10
(4,090 Views)

@Henrik_Volkers wrote:

like a non continious data aquisition or a failed continious sine generation to me  

 


No, the generation might very well be continuous, but if he grabs a subset of 5000 points, he ends up with a non-integer number of cycles. I already showed that taking slightly fewer samples (4880) results in a single bin.

 

altenbach_0-1639500009987.png

0 Kudos
Message 8 of 10
(4,062 Views)

Altenbach, sorry my fault, I overhead that the phase jump was created by you ..

 

Still prefer a linear sine fit 😉

Any signal not fitting the window will mix into the fft bin... Like hum.

Ok, 200Hz here with 50Hz grid isn't a good choice anyway ;). 250 Hz even worse...

 

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


0 Kudos
Message 9 of 10
(4,053 Views)

@Henrik_Volkers wrote:

 

Still prefer a linear sine fit 😉


Yes, there are plenty of better ways to get the phase/amplitude of course. Especially since you already know the exact frequency as in this case. This trace is incredibly boring!

 

FFT is useful if the frequency is unknown or if there are other interesting frequency components such as harmonics, etc. Some nice windowing might help too, of course.

0 Kudos
Message 10 of 10
(4,047 Views)