From Friday, January 17th 11 PM CDT (January 18th 5 AM UTC) through Saturday, January 18th 11:30 AM CDT (January 18th 5:30 PM UTC), ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

Measuring 4 counter inputs through NI 9401

Kudos for giving back!

 

I only had a pretty brief look on a system that could open your LV2021 code, and have one small nitpick.

 

Your example overconstrains the execution timing.  The DAQmx Read functions will already pace the iteration rate, only returning when a sample is available.  With your default rate of 1 S/sec, the loop will iterate at 1 Hz.  But then you have an *additional* timer  function that waits for a msec multiple of 1000 which is *also* trying to make the loop iterate at 1 Hz.

 

The tiny nitpick of a problem is that the DAQ device and the system clock won't agree on exactly how long 1 second is, there will be some microseconds of discrepancy which could potentially accumulate.  It's probably not a *real* problem in your posted example unless you run for a very long time.  But if someone starts making mods so that the 2 timing constraints no longer nearly agree, they could get into some trouble. 

 

I just wanted to warn anyone who finds your solution that they generally shouldn't have both DAQmx and the msec timer trying to constrain the loop rate at the same time.  I'd recommend putting DAQmx in charge and removing the msec wait function.

 

 

-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 11 of 12
(490 Views)

Kevin,

Thank you for your reply. You're right. The additional timer had better be avoided, though I just don't know how to implement that. Without it the loop goes much faster that 1 second. It took us a long time to  figure out how to start all 4 counters without any errors. Today I did fix some other impurities and added the vi again as labview 2017 version.

 

0 Kudos
Message 12 of 12
(471 Views)