From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Maximum Count Value

I have a NI-6220 with a 32-bit counter.  For my application, I only want a counter to count from 0 to 999999 and then rollover.  Is there a way to set this either in MAX, or any DAQmx property nodes, or do I just have to make my own logic within Labview. 
0 Kudos
Message 1 of 4
(2,852 Views)
You can't make the hardware do exactly that, but there are some other options that may be acceptable:
 
1.  You can use the "quotient & remainder" math function and only display the remainder when you divide the actual count by 1 million.  However, if the actual 32-bit count might also roll over, you'd get a discontinuity when it happens.
 
2.  A hardware-based method may work depending on characteristics of the signal you're counting.  It's a little bit involved if you're new to counters.  A basic outline is that the counter is configured as a two pulse encoder.  You give it an initial count of 999999.  You enable z-index reload with a z-index reload value of 999999.  You configure a counter property that causes it to "pulse on terminal count."  You wire that output signal back in as the z-index pulse.  You wire your external signal as the B input so the counter will count down from 999999 to 0.  Finally, your software will return the value 999999-actual count in order to look like it counts up from 0 to 999999.
 
-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 2 of 4
(2,839 Views)
I actually thought of the Quotient/Remainder solution right after posting that question.  It works quite well as I count up, but as you mentioned, I have a discontinuity if I count down and it rolls over.

I'll try to do some of the hardware tricks you mentioned to see if that fixes the problem.  For now I am just starting the counter at 1000000, which shows up as 0 for me and then I can count down atleast that many pulses before the actual roll over.

Thanks for the help. 
0 Kudos
Message 3 of 4
(2,834 Views)

Hold on!  I just remembered an easier way!

Take the unorthodox approach that instead of setting up a counter input task, create a continuous pulsetrain output task with units = Ticks.  Configure your external signal as the "Tick Source".  Specify that initial delay = low time = high time = 1 million.

The internal behavior of a counter in pulsetrain generation mode is to count down from # low ticks to 0.  When it reaches terminal count, the output state toggles and the count reverts to # high ticks.  It counts down to 0, the output state toggles, and the count reverts to # low ticks.   Etc.

I am not 100% sure a DAQmx Read vi will be allowed, but you definitely can query the count value using one of the DAQmx property nodes.  Probably a channel property.  Then you'd just do the previously-described software trick of reporting 999999-actual count so the reported value counts up from 0 to 999999.

To make a continuous pulsetrain, put a DAQmx Timing vi in the config chain and specify "continuous sampling" -- or just adapt a shipping example.

-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).
Message 4 of 4
(2,832 Views)