View Single Post
Old August 4th, 2022, 05:54 PM   #6
drbitboy
Lifetime Supporting Member
United States

drbitboy is offline
 
drbitboy's Avatar
 
Join Date: Dec 2019
Location: Rochester, NY
Posts: 5,608
Quote:
Originally Posted by Lare View Post
Thinking that four compares or rungs should also work for setpoint comparing but code isn't so clear. ...

If all one wants is the direction and offset from current encoder value to the setpoint (or vice versa), then it's even simpler than that.

But this raises a question: why does it matter to OP whether the encoder is either in the range [0:65536) or in the range [-32768:+32768)? Both ranges are continuous, except at the rollover, if this is a rotary encoder.
__________________
_
Brian T. Carcich
i) Take care of the bits, and the bytes will take care of themselves.
ii) There is no software problem that cannot be solved with another layer of indirection.
iii) Measurement is hard.
iv) I solemnly swear that I am up to no good
  Reply With Quote