02-12-2017 07:29 PM
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.
Solved! Go to Solution.
02-13-2017 12:53 AM
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).
02-13-2017 08:53 AM
Thank you for taking the time to help me. I'll try out your suggestions and reply with the results
02-13-2017 01:55 PM
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
02-13-2017 02:53 PM
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.
02-13-2017 03:27 PM
My sampling rate seems to be 6000. 3000 is still well above the cutoff frequency which is where my confusion is
02-13-2017 03:33 PM
Can you post your VI with all front panel parameters saved as default?
02-13-2017 03:38 PM
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.
02-14-2017 01:27 AM
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.
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.
02-14-2017 12:06 PM
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.