12-14-2021 08:02 AM
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.
12-14-2021 08:42 AM
@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?
12-14-2021 09:34 AM
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.
12-14-2021 10:49 AM
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.
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?
12-15-2021 03:12 PM
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
12-15-2021 03:25 PM
@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.
12-16-2021 04:01 AM
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 😉
12-16-2021 10:30 AM - edited 12-16-2021 12:31 PM
@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.
12-16-2021 12:27 PM - edited 12-16-2021 12:35 PM
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...
12-16-2021 12:41 PM
@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.