09-11-2012 11:09 PM
I was playing around with some exercise from Labview Signal Processing Course Manual (NI, 1997), when I stumbled upon unexpected result. I have included below the block diagram for exercise 3.1 (one sided FFT) from the manual. This demo vi had left the FFT size (default). I am not sure what that default value is. It is not stated in the context help. I tried to add in FFT size. Unfortunately the FFT analysis did not give an accurate answer when I put in FFT size. For example, I have set the sine wave frequency at 100s, Fs 300Hz and No of sine wave samples 500. When the FFT size was set at 256 I get 2 frequency peaks at 51 and 102 Hz. At FFT size of 512, I get one peak at 102 Hz. At FFT size 1024, I get a polymorphic waveform!!!
However when I set the FFT size to -1 then I got back the correct peak at 100Hz. I suppose this is the default FFT size value. I could also get the correct FFT frequency if I set the FFT size (500) at the same value with # no of samples (500).
Is there anyway I could set the FFT size value and yet get the correct FFT output. Thanks.
Solved! Go to Solution.
09-13-2012 07:25 PM
There is a mistake in the VI. If you change the FFT size, that affects the scale factor for the spectrum plot (you're basically changing the resolution of the FFT). So taking Fs and dividing by # of samples isn't correct. If you take Fs and divide by the FFT size you'll see that the peak stays at the correct frequency as you change FFT size.
From the help, an FFT size of <=0 will use the data set size. If the FFT size is >0 but less than the dataset size, it will only use the FFT size number of data points. If the FFT size is greater than the number of the data points, it will pad the input array with 0s up to the FFT size.
09-16-2012 09:10 PM
Dear 'Dad',
Thanks for the correction. I have made adjustment as you have mentioned. It seems to work but I noticed some new problems.
1) If the following parameters are used ( sine wave 100Hz, Fs 400Hz, FFTsize 512, Sample Size 512) then everything is fine.
BUT when
2) When the number of samples was increased to 1000, I ended up with 2 peaks at 100Hz and 300 Hz. (This vi was suppose to be one sided, the negative side of FFT was removed)
3) Things get even weird when Fs is increased to 500Hz. Then the 2nd peak moves from 300 to 400 Hz. !!!
09-17-2012 08:35 AM
Look at your VI more carefully. The reason that you're seeing two peaks for case 2 is that you're taking the input sample set size and dividing that by two and using that result to try and split the FFT result. But with 1000 points, dividing by 2 basically gives you the entire output of the FFT, so you're seeing more than you think.
Compare the attached VI with your VI.
10-01-2012 11:43 PM
Sorry for such a late reply. I was not able to open your attached vi as I had a lower version of Labview (2011). Will appreciate if you kindly repost your vi saved to lower version (2011). Thanks.
10-02-2012 08:42 AM
This was saved for 2011.
10-02-2012 11:34 PM
Dear 'Dad'
So my mistake was to take the array size directly from the signal source following sampling, for my frequency spacing calculation and sub-array selection of positive FFT’s only. You have pointed out that I should have taken the array size after FFT for the two calculations. From the hindsight, what a silly error! It’s a pity NI gave out a misleading example. By the way thank you very much for the correction.