LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Saving Peak Detector Data with Time Information

Solved!
Go to solution

I am using the Peak Detector VI to find the peak frequency of FFT data. I am trying to save the values output by the peak detector along with the relative time at which the peak was recorded. (To clarify, I want the value the peak detector reads, and the amount of time into the program running it was read at.) The end goal is to create a Frequency vs Time graph. Below is a screenshot of how I have it finding the peaks. 

0 Kudos
Message 1 of 12
(3,766 Views)

First your VI can be greatly simplified. The DAQms Read returns an array of waveforms (Wfm)  and most of what you are doing can be done using waveforms as well.

1 - Use the IIR Filter Wfm VI in the Signal Processing >> Wfm Condition palette, it takes both single waveforms and array of waveforms as input directly so no need to extract and re-insert data array.

 

2 - Instead of peak detection of a Power Spectrum you can use the Extract Multiple Tone Information VI in the Signal Processing >> Wfm Measure paletter. That VI does it all for you (FFT and peak detection) and returns an array of detected tones (and is significantly more accurate than the peak detection).

 

   To get the relative time of your measurements subtract the very first timestamp (t0) value from your different timestamps. The result is a double precision number. You can then create a 2D array with your relative time values in the first column and save it using for example the Write to Spreadsheet File VI (eventually inside your loop using the append feature).

0 Kudos
Message 2 of 12
(3,722 Views)

Thank you for taking the time to help me. I'll try out your suggestions and reply with the results

0 Kudos
Message 3 of 12
(3,707 Views)

Hello, 

I could not get the Wfrm Filter VI you suggested to work because of a an error message saying the cutoff freuencies had to be less than half of the sampling frequency, but there is not sampling frequency input possible. I can upload the code if it would be helpful

 

 

0 Kudos
Message 4 of 12
(3,690 Views)

   The sample rate information is included in your waveform (Fsampling = 1 / dt , where dt is one of the parameter you copied over when you unbundled your waveform in your original VI) and it is the sample rate that DAQmx used when you acquired your data. I suppose you specified that when you configured your acquisition.

 

  The filter expects a cut-off frequency less that half the sample rate - the Nyquist criterium.

 

 

0 Kudos
Message 5 of 12
(3,680 Views)

My sampling rate seems to be 6000. 3000 is still well above the cutoff frequency which is where my confusion is

0 Kudos
Message 6 of 12
(3,673 Views)

Can you post your VI with all front panel parameters saved as default?

0 Kudos
Message 7 of 12
(3,669 Views)

Sure, here it is. The basic function of it is to recieve data from a laser proximity sensor (in the form of analog voltage) that is pointed at a speaker outputting a known frequency, convert the voltage into frequency, and find the peak. The peak should be at the value that the speaker is outputting. A graph of frequency peak vs. time is what I'm after.

0 Kudos
Message 8 of 12
(3,665 Views)
Solution
Accepted by topic author BradleyEngineer

You didn't post the VI thar used the IIR Filter Wfm, so i can't see what's wrong. But conceptually here is how it should look if you use a sample rate (DAQmx) of 10 kS/s and configure your filter as a second order Butterworth lowpass with a cutoff frequency of 1 kHz.

 

Extract Tones.jpg

 

I also show the multiple tone extraction VI that returns an array of clusters with your tones frequency, amplitude and phase. Note that if you are interested in power you'll have to square your amplitude and divide by 2.

 

Message 9 of 12
(3,654 Views)

Sorry for uploading the wrong one. Attached is the correct one. I have evrything setup the way you have indicated and I am still getting the exact same error message.

0 Kudos
Message 10 of 12
(3,637 Views)