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

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 11 of 12
(194 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
(175 Views)