2
$\begingroup$

I have never yet had the Create2's incremental encoder rollover but want to write my code to be prepared for this to happen and test it. When the encoder rolls past 32767 (14.5m), does it rollover to -32768 and count there or start at 0 again and count up from there?

One other odd thing but not a big deal. When I reset the Create2, the first value is 1 not 0.

$\endgroup$
2
  • $\begingroup$ I think I edited this to be cleared. I think you have have answered my question that this simply is a 16 bit signed counter. So a positive value rolls over to negative and vis versus. There square wave math happen internally. $\endgroup$ Commented Jun 28, 2016 at 18:21
  • $\begingroup$ OP, if @Mark answered your question, please accept it below with the check mark symbol between the up/down arrows to the left of the answer. (This is how questions get marked as resolved) $\endgroup$
    – Chuck
    Commented Jun 28, 2016 at 19:40

1 Answer 1

2
$\begingroup$

With a 16-bit two's-compliment counter, the highest positive number would be 32,767, while the lowest negative number is -32,768. So it would overflow from 32,767 to -32,768. When counting in the opposite direction, it would underflow from -32,768 to 32,767.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.