Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

NI-9421 strategy to employ for period measurements in parallel of DAQ

Hi

 

I have a project acquiring data (voltage, pressure and temperature) from a few NI devices (9201, 9213, 9219) which is working fine on its own.

 

I am trying to measure the time between 2 digital pulses using a 9421. The pulses are generated by an NPN proximity/hall effect sensor. I have created various test tasks in my project which I am able to test in the test panel, so I know I am getting those pulses in.

 

So far I have tried using either counters, period and frequency, all of which are working fine in the test panel.

 

The issue I am facing is that my DAQ while loop is already reading the 3 analog input devices (listed above) and I can't find a way not to miss pulses.

 

- for example when using the counter input, and reading a single sample, I have extremely poor resolution due to the fact I am not polling the 9421 often enough. My polling rate is defined by the thermocouple input which I can't poll faster than 10 Hz. Which means on very slow rotations of the flywheel I may get 1 pulses between 2 polls. Using counter could actually work well enough if I could significantly increase the number of pulses per revolution which is not something I can easily do with the current setup.

 

- frequency or period would seem like the ideal way forward however, I can't find the right way to set this up. If I am reading the 9421 for a single sample I may not get any data if the flywheel is spinning slow.

 

I think the right way to do this would be run "continuously" but there again I haven't been able to do this.

 

Is there a good strategy to do this? I started thinking maybe I should try to run 2 while loops fully independent?

 

oh and I am running Labview/DAQmx.

 

that's what my last block diagram trying to read single samples of the period looked like:

swiftmoun_0-1702945869024.png

 

 

if you guys know of a good labview example please let me know. Everything that I found are basic examples which are fine if my VI only reads periods/frequencies or counts.

 

0 Kudos
Message 1 of 2
(1,035 Views)

Only have time at the moment to outline some breadcrumbs, but yes there are ways to do this well.

 

1. Good period / frequency measurements should be done natively with a counter task, not by software polling a digital task.

 

2. Coordinating multiple tasks at different rates requires some care in planning out your software architecture.  Distinct parallel loops for such tasks can be a helpful strategy.

 

3. A different strategy is to set all tasks for continuous sampling with a buffer, pace your loop with the # samples you read from 1 of the tasks, then have the tasks give you whatever # new samples happen to be available right then without waiting.  This is actually a default behavior for DAQmx Read when you set the # samples to read = -1.

 

4. Period/Freq measurement with counters depends on receiving incoming pulses.  If the flywheel is slow or stopped, you may not have any new data when it's time to read.  By knowing this ahead of time you can be prepared, check for that condition, and code to work around it.

 

5. Bring up one of the shipping examples for Counter Input that does continuous period or frequency measurement.  Save a copy off to a working area (so you don't modify the original).  Experiment.  Note: if you wire up the special -1 value to retrieve whatever # samples are available, you should probably add a msec wait timer to the loop to pace it.  But if you wire up a positive value, you should then get rid of the wait timer to leave DAQmx Read in control of loop timing.

 

 

-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 2 of 2
(1,010 Views)