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.

  • $\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$ – Kirk Lennard Jun 28 '16 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 Jun 28 '16 at 19:40

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.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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