LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Numeric measurements and Spectral Analysis VI

I am curious as to finding way to have the peak numeric value (which would represent the value of an input frequency) of an FFT from a Spectral Analysis VI. I want the graphical representation (works fine) but I also want to put a numeric indicator that shows the peak frequency as well. How can I do this when the input signal into the waveform graph is dynamic data? My numeric display keeps changing because of the array of numbers.
0 Kudos
Message 1 of 4
(2,934 Views)
There are lots of ways to do this.

If you're just trying to find the fundamental fequency and amplitude, the easiest way is to just use the extract single tone VI.

Another method is to use the From DDT express VI to cast the dynamic data type representing the spectrum into an array of doubles or a waveform and then use the min/max function from the array palette to locate the peak (I think there is a similar VI for waveforms, but I don't have LabVIEW open at the moment). This has the advantage of skipping the extra FFT which the extract single tone VI uses, i.e. it's a bit quicker for large data sets. However, if you use the array function it will return an index rather than a frequency, so you'll have to use the df property to calculate the frequency from the index (frequency = index*df).

There are other methods as well, but there are two quick ones.

Regards,
Ryan K.
Message 2 of 4
(2,919 Views)
Thank you, that solved the problem! I hope that it will not be too much of a burden since I already have 4 FFT's running as well. I appreciate the help!
0 Kudos
Message 3 of 4
(2,916 Views)
In the majority of programs, the performance difference will not be a big issue. Typically, performance is only really important in time critical programs or programs which are attempting to acquire data at high rates and for long periods of time (i.e. avoiding buffer overflow for high speed buffered data acquisition). My suggestion is usually to write the initial version of your program using good coding style and techniques which feel comfortable to you. While coding, note areas like this as potential points for optimization. If you find later that the performance is unsatisfactory, you can always come back and optimize the code segments in question.

If you decide later that you need to optimize this particular code segment one thing to note is that you can actually open the block diagram of the Extract Single Tone Information VI and get the SubVI which takes the frequency domain data and returns the applicable information (called Extract Single Tone Information from Hann Spectrum.vi). By choosing your FFT carefully, using the SubVI, and applying some math functions to get it into the proper coordinate systems you can eliminate the extra FFT used by Extract Single Tone without changing any of the functionality. This technique is used in one of the exercises for the LabVIEW Modular Instruments course which is being offered next year, and if I get some time I'll post it as an example on DevZone at some point.

Regards,
Ryan K.
Message 4 of 4
(2,895 Views)