02-22-2011 09:23 AM
Hello, I am trying to measure the frequency of a square wave from my paddlewheel flowmeter. I am also recording temperature readings in the same program.
I am using the DAQ assistant to bring my data into my program. The program is run inside a while loop. I have a case structure setup inside the while loop which allows me to set how often data points are recorded.
I am using a NI cDAQ-9172 tray for my modules. My square wave signal from my flow meter is plugged into a NI 9201. The square wave is a 0-5V signal.
I am currently using NI_MAPro.lvlib:Extract Single Tone Information.vi to obtain my frequency. This works good from frequencies of around 300Hz(max output from flowmeter) down to about 10Hz. At frequencies below 10Hz, the frequency found by my program is inaccurate. It never goes below 10Hz and jumps around. I have an oscilloscope and multimeter hooked up to the signal as well so I know the actual frequency when I'm lower than 10Hz. My DAQ assistant is set up in Continuous Samples mode with the samples to read at 200 and the rate at 1k. Does anyone have any ideas to get accurate readings at the lower frequencies? Such as changing my rate or samples to read? The square wave is very clean on my oscilliscope. Ideally, I'd like to be able to read frequencies down to 2Hz.
Thanks for any help!
02-22-2011 11:20 AM
Just thought I'd let you guys know that I just figured out my problem. I increased my sampes to read to 1000 and now it works correctly.
02-23-2011 07:31 AM
A few details for those of you who might be reading this later. The tone extraction VIs work by taking an FFT of the incoming signal, using a windowing function on it, and doing a search for peaks in the amplitude spectrum. The VIs give subsample accuracy since they essentially do a data fit on the top three points of the peak to the known peak shape (different windowing functions produce different peak shapes). However, to work well, you need at least one full cycle and preferably ten or more of the signal of interest. The number will depend on the accuracy you need. For tuning a musical instrument, I found that ten or twenty cycles is enough, but this does mean that I needed to take more data as the frequency of interest got lower, just like antig24 did.
If you need to find the frequency of a wave and do not have a full cycle, you will need to depend on knowledge of what the wave looks like. For the square wave in this case, finding two zero crossings and knowing the duty cycle would have been sufficient. The pulse parameter VIs can be used for this type of analysis. They will also give frequency directly, so may have been a better choice, in this case.