LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

fft

Hi, I'm trying to do an FFT on an array of data in LV7.0, but it isn't working out.  I've tried 2 types of FFT vi.s, but no luck.  I just need to see a graph of an fft.  Does anyone know how to do this in LV7.0?  Thanks.

 

0 Kudos
Message 1 of 9
(2,506 Views)

I have done exactly that in LV 7 and many other versions.

 

What is "not working out," exactly? The more specific you are about what you have tried and what does not work, the easier it will be for someone to help you.

 

Please post your code with your data saved as default so we can see what you have tried.

 

Lynn

0 Kudos
Message 2 of 9
(2,502 Views)

This is the basic idea.  I just want to do an FFT on an array of data.  I know I need to do something to tell the FFT about sample rate, but I don't know how to do that.  As for output, I haven't been saving it.  I just want to know what's causing noise in a samples system, and I figure if I can see any frequency spikes it might clue me in on where it's coming from.  Anyway, the FFT graph, as created with the circuit shown, is a fluctuating output around 0Hz.  All the data is shown less than 1Hz.  The sample rate just over 4000 sps, and so I want to see frequency content out to 2kHz.  Thanks.

0 Kudos
Message 3 of 9
(2,499 Views)

OK.  I cannot tell everything from an image but some of your concerns can be addressed.

 

1. Timing. The data in FFT Array contain no timing information. The array is just a series of numbers.

2. Conversion to the Dynamic Data type does not add any timing information, although the DDT is capable of carrying that information.

3. The basic FFT VI or function which is at the root of most of the spectral VIs does not use or care about the timing information.  The timing -> frequency scaling takes place outside the FFT, although it must be done in a manner consistent with the FT alogorithm.

4. In the absence of timing information the spectral VIs assume that delta t is 1.  That makes the default sampling frequency fs = 1/dt = 1.  The frequency resolution or spacing between elements of the FFT output array is df = fs/N where N is the number of samples or elements in the input array.

 

5. This explains why you see all your spectrum at low frequencies.  If you scale the X-axis according to your real values of dt or fs and N, you should get the correct frequencies.  Without knowing how you have the Express VI configured, I cannot tell exactly how things will be scaled.

 

Lynn

0 Kudos
Message 4 of 9
(2,489 Views)

I didn't configure it at all.  That is, I didn't change any configurations.  They are whatever they are when the vi is placed... default values.

0 Kudos
Message 5 of 9
(2,487 Views)

I converted it to a subVI and then opened its block diagram.  Several layers down it does a basic spectrum and then manipulates the data for presentation.  It does produce a single sided spectrum, going from 0 to the Nyquist frequency.  It sets dt = 1 if no other information is provided.  So you should be able to scale the frequency axis by the relationships I posted earlier suing dt and N.

 

Lynn

0 Kudos
Message 6 of 9
(2,481 Views)

Ok, I think I have it.  I took the sample rate (4340) and divided by the number of samples in the array (4600) and multiplied that by the sample rate again.  The result of all this, I set to the XScale.Multiplier on the graph.  I now have a Frequency scale that goes up to just over 2000Hz.  Does this sound correct to you?  Thanks.

 

0 Kudos
Message 7 of 9
(2,459 Views)

I have been away for a few days.

 

No, that does not sound correct.  fs/N works as a scale multiplier if you are using the regular FFT.  If you create a waveform with dt = 1/fs and use it as the input to the Express Spectral Measurments VI, the output is correctly scaled.  Whe I do what you suggested I get a df of 4094.7 and a maximum frequency scale of 1E7.

 

I calculate 2169.06 Hz as the highest frequency component.

 

 

Lynn

0 Kudos
Message 8 of 9
(2,428 Views)

Perhaps either method works.  I injected a frequency into the front end and could see the frequency as a spike on the FFT at the correct frequency.

0 Kudos
Message 9 of 9
(2,424 Views)