LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to measure a low frequency in DaqMX.

I am looking for a easy way to monitor frequency output from a speed sensor. It seems all the examples offered do not work for my application. I get errors stating data overwrite or time out constantly. My goal is to monitor the pulses being out put by my speed sensor. When ever my speed sensor is not spinning I seem to get an error. Any help would be much appreciated. My frequencies rang from 0-10000 HZ.
0 Kudos
Message 1 of 10
(6,920 Views)
How do you measure a frequency of zero? How long are you willing to wait? If your equipment stops for a day and then restarts, the frequency is < 1E-5 Hz, but it is not zero. You have to define what the lowest meaningful frequency is and then set your measurement time and counter size accordingly.

Lynn
0 Kudos
Message 2 of 10
(6,915 Views)

Lynn,

Thanks for the quick response,

So if I set my lowest frequency to 1 hz and I am currently receiving a signal at .1 hz does my loop iterate at 1 hz and return a frequency of 0 hz until a frequency greater than1 hz is detected?

Also if I set my frequency range between 1-1000 hz what should I set the measurement time and counter size to.

Thanks for the help
Dennis

0 Kudos
Message 3 of 10
(6,912 Views)
Dennis,

If you count for 1 second and have a 0.1 Hz input signal, you will get one reading of 1 for every nine readings of 0 on average. For a frequency of 1000 Hz and a counting time of 1 second you will get 1000+/-1 counts. Total counts = Frequency (in Hz) * counting time (seconds). The variation is due to the timebase and the sensor outputs not being synchronized. So, your counter will need to be able to count to 1000 without overflow.

Lynn
0 Kudos
Message 4 of 10
(6,903 Views)
In addition to the good tips johnsold has been giving, here's a different angle on your question:  there are a variety of ways to configure the counting operation on your DAQ board and there are also different ways of interacting with the count via the DAQmx driver.  For example, I almost never do unbuffered counter measurements -- not that there's anything wrong with that, just that I've gotten comfortable using the flexibility of the buffered operations.
 
Now, while I would recommend the DAQmx driver, I still tend to use a traditional NI-DAQ mindset, i.e., I tend to configure in a more "raw" mode rather than letting DAQmx do my thinking for me.   Your app might be an example -- as I recall the DAQmx paradigm for frequency measurement is that you tell it the range of frequencies you think you might need to accomodate.  Then behind the scenes, it'll decide things like what timebase to use, whether to use a single counter or a combination of two, etc.  I'm not sure because I never use frequency measurement.  I use period measurement because it's so ingrained from years of setting up counter operations under traditional NI-DAQ.
 
Anyway, I don't know the exact needs of your app, but here's an example of an approach that may at least give you some insight into solving your actual app.  I'm supposing that you don't need to capture and measure every single interval.  You just want to monitor the frequency pretty regularly to keep track of what's going on "right now."  I would setup and start a buffered period measurement task outside the main query loop.  Inside the loop, I would query for # of available samples.  When that # is 0, you know that your speed sensor produced no new pulses and your speed of 0.  When the # does change, you could read those samples and calculate the average frequency.
 
There's another variation if your frequency tends to be pretty high and you don't need to process every single interval.  In such a case, there's a way to retrieve only the most recent 10 or so samples.  The hardware is free to keep overwriting the circular buffer when you don't retrieve data, and by retrieving it in just the right way you won't get a "buffer overwritten" error.  Post back if you need more details.
 
-Kevin P.
ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 5 of 10
(6,899 Views)
And yet a different way ---
 
Due to issues with earlier counters, I don't use them -- I use an analog input, gather a waveform, pass that to one of the existing waveform analysis vi's (off the top, I can't tell you specifically which one), and get the frequency domain of the waveform.  Depending on the accuracy required for your application, I have verified this approach with various DAQ cards and frequency range from 4Hz to 7500 Hz.  For my use, I don't have a need beyond that.
 
Something to ponder.
 
RS
0 Kudos
Message 6 of 10
(6,875 Views)

I hope it's OK if I inquire further on Kevin's excellent description in this thread. I have a similiar application to Dennis H. such that I have various speed sensors on a test vehicle where the frequency range is low: 0-1K Hz. I have programmed the DaqMX single channel, low frequency method, but I still have issues with errors when the signal drops below 2 Hz. I also get strange spikes in the data where the frequency count goes unrealistically high, yet the pulse signal when viewed with a scope is a clean TTL.

Various city driving scenerios include coming to a complete stop (speed = 0). Kevin's description from his last post (copied below) is, I believe, exactly what I need to implement.

I was wondering if Kevin or anyone wouldn't mind expanding a little more on the details of how to do this?

"Anyway, I don't know the exact needs of your app, but here's an example of an approach that may at least give you some insight into solving your actual app.  I'm supposing that you don't need to capture and measure every single interval.  You just want to monitor the frequency pretty regularly to keep track of what's going on "right now."  I would setup and start a buffered period measurement task outside the main query loop.  Inside the loop, I would query for # of available samples.  When that # is 0, you know that your speed sensor produced no new pulses and your speed of 0.  When the # does change, you could read those samples and calculate the average frequency."
 
 
0 Kudos
Message 7 of 10
(6,810 Views)
Only time to give a very brief reply for now.
 
1. "Query for # of available samples" -- check options under the DAQmx Read Property node
2. Reading only the most recent samples -- also under the DAQmx Read Property node.  Look for names like 'Relative To' and 'Offset'.  Set 'RelativeTo' = Most Recent Sample and 'Offset' = (-)(# samples I want).  Also set '# to Read' property.
 
3. Errors below 2 Hz -- dunno.  Maybe related to DAQmx choosing defaults "under the hood".  Or possibly the (default) timeout value on calls to DAQmx Read?
4. Strange spikes -- if not due to signal noise, possibly related to counter rollover.  I commonly encounted this problem with E-series counters which are only 24-bit.  When using the 20 MHz onboard timebase for maximum measurement precision, the count register wraps around 0 in less than a second.  A typical solution is to sacrifice timing resolution and explicitly use the 100 kHz onboard timebase instead, which takes a few minutes before wrap around / rollover. 
Alternately, under DAQmx one can query for the self-resetting property "TC reached" which becomes True when a rollover occurs, then resets to F when queried.  If monitored frequently enough, one could increment a numeric value with each True state and then combine that with the 24-bit count to get a true 32-bit int.
 
Sorry if too short or cryptic, but gotta go now.
 
-Kevin P.
ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 8 of 10
(6,794 Views)
Russ (or anyone else out there)
 
I have a situation similar to what you described.  I need to read an analoge waveform from a load cell and determine its frequency.  The range is currently 40-250Hz but the low end may be going as low as 10Hz.  My coworker has spent a fair amount of time writing and devloping his own vi to measure this, but it is still very coarse in resolution, unstable at varying frequencies, and is have problems with signal noise.  The noise levels seam to be normal and resonable noise levels in my experience.
 
What were the specific vi's I can use to get frequency from an analog input.  I haven't found any that directly output this.  This doesn't seem to such a unigue situation that we are the first people to every try this.  It seems that there is something in the vi library that I can use (even though I haven't had a lot of time to look for it).  I have the full development version of labview 8. 
0 Kudos
Message 9 of 10
(6,731 Views)
Hi, Clampy.

To determine the frequency of a waveform, you can use the Tone Measurements Express VI. It's located in Functions>>Express>>Signal Analysis>>Tone Measurements.

Good luck!
Sarah K.
Search PME
National Instruments
0 Kudos
Message 10 of 10
(6,711 Views)