So you're getting ~360 counts for 180 degrees movement. Then the interrupt code must be doing 2x decoding instead of 4x - provided the encoder is actually 360cpr.
You loose the negative value because PBP doesn't handle the multiplication properly and you're of course better off copying the enc_counter variable to a second one for scaling and display purposes, sorry about all that.
Try this (untested):
/Henrik.Code:Degrees VAR WORD Sign VAR BIT Degrees = enc_counter ' Degrees is now -180 to 180 Sign = Degrees.15 ' Save sign Degrees = (ABS Degrees) * 5 ' Degrees is now 0 to 900 If Sign THEN Degrees = -Degrees ' Restore sign, value is now -900 to 900




Bookmarks