12-03-2007 09:25 PM
12-04-2007 08:47 AM
You'll need to do a little software workaround on the values you read from your counter. But first a little tutorial to explain *why*.
The E-series boards use 24-bit counters. When LabVIEW requests an integer count value, the count is returned in a 32-bit unsigned integer datatype, where the 24 lowest bits represent the value in the board's count register. The upper 8 bits are *always* 0's.
The count register can increment from 0 to 16 million plus (2^24 - 1), then it must "roll over" back to 0 again just like an odometer. Similarly, when it decrements past 0, it next goes to the max value of 2^24 -1 as you observed.
So we need a little software workaround that'll convert (2^24 -1) to (-1) and (2^24 -2) to (-2), etc. The way to do it is to first detect whether the highest bit is a 1. One way is to compare whether the count value is >= 2^23, making sure to use integers to do the comparison. Whenever the value is >= 2^23, subtract 2^24 from it to create your new count value which will then decrement 3,2,1,0,-1,-2,-3, etc. as desired.
Here's a link to a similar explanation. Couple more notes too. First, if this is a continuously rotating encoder, you may still encounter a discontinuity when the revised count value crosses the +/- 2^23 boundary. Second, direct connection of a quadrature encoder to an E-series board isn't recommended because of unrepeatability when measureing direction changes.
-Kevin P.
12-04-2007 10:09 PM