Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

NI-6602 - Encoder capture - resetting the counter to 0 through software - DAQmx

Hello. A simple one. I'm using DAQmx to set up a task to set channel 0 on an NI-6602 as an angular encoder capture port. This is working fine and I can grab the position in degrees. The simple question is - How do I reset the counter to 0 through software. I can set up ZIndex to do it but how do I either reset the counter or set it with an arbritrary number? I can see a method to set it on startup but not during capture.
Thanks.
Will
0 Kudos
Message 1 of 5
(4,262 Views)

If working in LabVIEW, there are DAQmx property nodes that will allow you to set the "initial count" value, but ONLY while the task is stopped.

If you can't count on a hardware z-index reset, another software technique I've used to avoid stopping the DAQmx task.  I make a wrapper function for all my encoder task access (see the Action Engine nugget for ideas...).   Inside this "Action Engine" wrapper, I use an uninitialized shift register to store my encoder's "virtual 0".  I add a simple function to the action engine for setting the "virtual 0" to be the current encoder position value.  Every time I read from the encoder, I first subtract off the virtual zero before returning the data.  As far ast the rest of the app is concerned, the encoder data it gets is just as if I were able to make a software call to DAQmx to set the raw count to zero.

-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 5
(4,260 Views)
Hi Kevin. Thanks for the reply. It looks like this is the way to go. I had a similar thing with another card I used that the 6602 is replacing - I just thought I could get rid of some code and simplify matters. Thanks again.
0 Kudos
Message 3 of 5
(4,258 Views)

Yeah, it'd be really nice if NI supported a count reset (or "reload" for non-zero values) based on a hardware edge coming in, regardless of A,B phase, and regardless of whether we are in position measurement mode, or edge counting, or (perhaps) other modes.  If you agree, add your voice to mine at the Product Suggestion Center.

-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 4 of 5
(4,252 Views)

Done.

Will

0 Kudos
Message 5 of 5
(4,249 Views)