Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to reset a counter?

I have two options as I see it for my application.  I need to either reset the counter value at some point or figure out how many bits the counters on a 9401 are and then have some calculation to calculate the correct number of counts even when the timer rolls over.

Is there a way to reset the counter?
How many bits are the counters on a 9401?

Thanks.
Programming Data Acquisition and Control in Measurement Studio and Labwindows/CVI
0 Kudos
Message 1 of 5
(4,150 Views)
Hello Michael,
 
A common misconception with C Series modules such as the 9401 is that there is a counter on board.  This is actually not the case.  The NI-9401 is a digital module which can access the counter(s) in the chassis in which the module is placed.  Assuming you have placed your NI-9401 in a cDAQ-9172 chassis, you can access the counters with this module by placing it in slot 5 or 6.
 
The counters on board the cDAQ chassis are 32-bit.  This information, and how to perform various counter tasks is contained within the User Guide & Specifications for the cDAQ-9172.
 
You cannot reset an event counter in the middle of a task.  The only option to reset it is to stop the task and to start the task again.  On the other hand if you are using a quadrature encoder and have an A, B and Z signals (typical with quadrature encoders), the counter will reset with the Z or zeroing signal.
 
Hope this helps,
 
Jennifer O.
Applications Engineer
National Instruments
0 Kudos
Message 2 of 5
(4,137 Views)
So in the event that the counter value I measure this second is less than the value read during the last second
(counter overflowed), I should say that the number of pulses in that second was ThisCount + 4294967296 - LastCount?

Thanks!
Programming Data Acquisition and Control in Measurement Studio and Labwindows/CVI
0 Kudos
Message 3 of 5
(4,133 Views)
Hi Michael,

You are absolutely correct.  The counter will go from 0 to 2^32-1 and then back to 0.  Right at roll-over, the count will increment by one from 2^32-1 to 0.  So following your reasoning the difference between old count (2^32-1) and new count (0) should be one.

Testing this you get 0-(2^32-1)+2^32=1

Also, there is a property node in DAQmx that will tell you if the count has rolled over (you can use this as an alternative to comparing your two counts).  The channel property is: "Counter Input:General Properties:More:Terminal Count Reached".  If the counter has rolled over this will return true, and it will automatically reset to false after you read this property.

Regards,

Jennifer O.
0 Kudos
Message 4 of 5
(4,126 Views)
Thanks!
Programming Data Acquisition and Control in Measurement Studio and Labwindows/CVI
0 Kudos
Message 5 of 5
(4,119 Views)