LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

calculating frequency from array measurements

I have a 1D array of sine wave measurements.  1Khz, 1000 samples, 10000 samples per seconds.  I need to determine the best way in CVI to analyze the array to determine the frequency.  I was thinking about finding the peaks and recording the array location for each peak.  Since the sampling rate is known I can determine the time between peaks and determine the frequency.  Are there built in functions that will find peaks and give you the array location? or can I perfrom some sort of FFT analysis to determine the frequency?

 

 

0 Kudos
Message 1 of 9
(4,002 Views)

Hi,

 

I have used the function ThresholdPeakDetector from the Advanced Analysis Library which returns the indices of peaks exceeding a certain threshold. There might be even better suited functions but I haven't used them Smiley Wink

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

I will give it a try.  I wrote my own quick and dirty peak detection algorithm.  So far I'm about 1-3hz difference between my scope measurements and the daq card measurements.  I'm currently using a signal generator which is a nice clean signal.  I'm worried about measuring a live signal with noise riding on top of the signal.

 

0 Kudos
Message 3 of 9
(3,997 Views)

Savitzky-Golay filtering may help here, CVI provides the function SavitzkyGolayFiltering, I used it with a polynomial order of 4. 

0 Kudos
Message 4 of 9
(3,994 Views)

Or perform a power FFT with Spectrum(), get the index position of the peak and multiply by the sampling frequency. It's a good method if it's noisy and if you need a precision of more than an integer multiple of the index freq, you can do a fit with a gaussian very near the peak.

0 Kudos
Message 5 of 9
(3,992 Views)

I used the peak detect function and determined the frequency.  Its accurate.  I am having some noise issues.  I am generating a tone while a device is recording the tone.  I then play it back and use a microphone to measure the amplitude/freq.  This is a go/no go production test to verify manufacturing hooked the microphone/speaker up correctly.  My freq measurement seems ok but the voltage measurement is all over the place (background noise).  I also noticed the peak detect function has a threshold.  You need to determine what your peak value is initially to make it more accurate.  I set the threshhold to  .25 volts and it missed .36 peaks.

 

0 Kudos
Message 6 of 9
(3,980 Views)

I use the power FFT spectrum(...) function as gdargaud suggested.  With an NI DAQ card, you can create your own spectrum analyzer easily.

0 Kudos
Message 7 of 9
(3,951 Views)

Are there any examples of this in CVI?

0 Kudos
Message 8 of 9
(3,923 Views)

If you have the Advanced Analysis library installed you can consider e.g. spectrum.cws

0 Kudos
Message 9 of 9
(3,920 Views)