Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

How to deal with counter wrapping on negative (below zero)

I am using the DaqMX Angular position VI's to read quadrature encoders.  I find thatthe encoders do not wrap "correctly" when going through zero, even when I use the Double rather than U32 data type option.  In other words, the counter counts down like this     3, 2, 1, 0, +4billion & change.

 

How have people dealt with this?  Should I set the starting count to + 2billion&change and then subtract that off of all my readings?  I suppose it can be made to work, but is ugly.

 

Is there a better way?

 

Thanks.

 

Mark Holm

0 Kudos
Message 1 of 2
(5,410 Views)

If you convert the U32 reading to an I32 you should get the correct negative number:

 

U32toI32.png

 

If you use the double read (rather than U32) and you configure your channel to measure in "radians" or "degrees" (rather than "ticks") then I believe DAQmx will return negative values for position as well.

 

 

Best Regards,

John Passiak
0 Kudos
Message 2 of 2
(5,407 Views)