05-31-2023 02:11 AM
Hi,
I am sampling signal with my PXIe-5774 fpga (3.2 GS/s) and sending that data to my pc. The signal coming to my PXIe-5774 is a 20 MHz sine-wave (other input is just noise). The raw data looks like this:
When I calculate an FFT from it using this code:
the frequency spectrum looks like this (I have scaled it as there are no other peaks at higher frequencies):
As you can see the peak is not at 20 MHz but is a bit off at around 30 MHz. Why is this? I have tried all the windowing functions and have changed the sine-wave frequency to have it have an interger multiple of periods per sample but this phenomenon persists.
Thanks:
Aarni
Solved! Go to Solution.
05-31-2023 04:59 AM
The short answer is that you're using the wrong method to get the amplitude spectrum. If you use "FFT Power Spectrum and PSD", the peak should appear at the correct frequency, although the spectrum will be in squared "power" units.
Andy
05-31-2023 06:27 AM
OK, that *shouldn't* make a difference to where the peak in the spectrum appears - it was just the first thing I tried.
The correct answer is that your complex arithmetic functions aren't doing quite what you expect because they're operating on clusters. The Re/Im To Complex gives you correct data values but sets the f0 and df elements of the output cluster to complex numbers. This causes a problem because Waveform Graph uses these to determine the x-axis values, i.e. the frequency base.
Extract the data arrays from the real and imaginary clusters before doing any further calculation, or maybe just use the version of the FFT Spectrum VI that gives you magnitude and phase output in the first place?
Andy
05-31-2023 09:25 AM
In other words, don't take the magnitude of the x axis information.
Simple solution: Instead of using the FFT Re-IM, use the FFT mag-phase and just graph the magnitude. No math needed!