LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

FFT block giving incorrect magnitude plot

Solved!
Go to solution

Hey guys, 
I am trying to get the FFT of a 1D array which is basically an excited sine wave (or what many know as a 'chirp').
However, the data points seem to be too large in magnitude. Is there a scaling factor or anything of that sort that I may be missing?
I have made sure that the inputs to the FFT block are what I am expecting and that the FFT is set to process a 1D array.
Since this partial work-product, I am unable to supply the VI but have added extensive pics detailing the issue.

'Alpha 4' shows the chirp mid way and shows the waves are clean and without distortion at a high frequency.
'Beta 1' shows the same thing but at a lower frequency.
'AlphaOut' is the signal that I want and I have probed/zoomed to verify this.
The top 4 graphs are all the same (i.e. a sine wave being excited from 0-1500Hz in 5 secs at a rate of 300Hz/second). All graphs have been zoomed in at different points to show clarity.
The 'Real Part' graph is where I am stuck.
Please let me know if any other info is needed.
Any ideas or help would be greatly appreciated.
Thanks

Download All
0 Kudos
Message 1 of 14
(3,760 Views)

Check the help for the FFT function.  Those functions do require you to supply your own scaling factor.  I believe they bin the values at the most basic level and you need to do some math on both the magnitude axis and the frequency axis (especially frequency since a plain 1-D array has no timing information with it).

 

Instead of messing with fancy chirp functions, work with a simple sine way as you would easily know what the FFT would look like for that.  Once you get the scaling factors correct, you can apply that to your more complicated waveform.

 

Drill down until you find "Output Units for FFT-Based VIs".  It looks like you divide bin 0 by N/2, and all the other bins by N where N is the total number of data points.

Message 2 of 14
(3,739 Views)

You should try what RavensFan suggested before sending a private message.

  1. In your picture you are looking at Mag and Phase NOT Re and Im. Look at the complex math block.
  2. Below is a convoluted way to scale for RMS for the magnitude. I'll leave it to you to figure out alternative scaling.

Please keep messages to the thread and do not PM people asking the same question.

 

mcduffsnip.png

 

Message 3 of 14
(3,695 Views)

I tried working with sine waves of a constant frequencies, however the scaling factor in them is the same(i.e. 10000 *input amplitude =magnitude). When I added two sine waves together at different frequencies, there was no evident scaling factor.
Since I am working with all frequencies b/w 0 and 1500 in my chirp, I am unable to define what my scaling factor will e.
Also, I was unable to understand what you meant by "you divide bin 0 by N/2, and all the other bins by N ". I don't know what these 'bins' are.
Could you please help explain?
Thanks.

0 Kudos
Message 4 of 14
(3,692 Views)

Yes, you are right. I am looking at Mag and Phase. But I am only really interested in the Magnitude, so didn't really pay too much attention to what else the block was outputting.
I did try what RavensFan had suggested, but didn't really get me anywhere. I am an intern at a company, and only getting used to how forums like these work. 
Sincere apologies for the PM. 
Could you please attach your VI? I am unfamiliar with some of the blocks you have used and wanted to read their 'help' as to what they do?
Thanks.

0 Kudos
Message 5 of 14
(3,690 Views)

Out of the office now. It is a snippet if you have 2018.

 

mcduff

0 Kudos
Message 6 of 14
(3,687 Views)

Unfortunately, I am using LV 2015.
That's alright though.
Thanks a lot for your help!

0 Kudos
Message 7 of 14
(3,684 Views)

I will send a 2015 version tomorrow 

 

mcduff

0 Kudos
Message 8 of 14
(3,670 Views)
Solution
Accepted by topic author DevDhyani

@DevDhyani wrote:

I tried working with sine waves of a constant frequencies, however the scaling factor in them is the same(i.e. 10000 *input amplitude =magnitude). When I added two sine waves together at different frequencies, there was no evident scaling factor.
Since I am working with all frequencies b/w 0 and 1500 in my chirp, I am unable to define what my scaling factor will e.
Also, I was unable to understand what you meant by "you divide bin 0 by N/2, and all the other bins by N ". I don't know what these 'bins' are.
Could you please help explain?
Thanks.


Bins.  An FFT is essentially a histogram where each frequency point is a "Bin".  If you have a 1000 points in your array and they all fit a specific frequency, all those points will be placed in that frequency's bin.

 

Bin 0, or the 0th index of the resulting FFT is the DC component.  If you have N points in your original 1D array, take the value you get at index 0 of the FFT array and divide by N/2.   All other values in the array, divide by N.  Now you'll have the result of the FFT function scaled to the correct amplitudes.

 

 

Here is an interesting YouTube video I saw last year that gives a very good explanation on FFT's from a perspective I had not seen before.  https://www.youtube.com/watch?v=spUNpyF58BY

Message 9 of 14
(3,652 Views)

2015 version attached

 

 

Message 10 of 14
(3,625 Views)