Hi,
Great job! The problem with the display routine is, again, that PBP doesn't handle math with negative numbers properly so the result of the Counter / 10 operation gets messed up when Counter is negative.
You can probably make that snippet a bit more efficient, somelike like this perhaps:
Code:
if enc_counter <> enc_counter_old then 'see if value has changed
enc_counter_old = enc_counter 'move new value to old
Counter = enc_counter
Sign = Counter.15 ' Save sign
Counter = ((ABS Counter) * 5) ' Degrees is now 0 to 900
LCDOUT $FE, 1 ' Clear screen
IF Sign THEN
LCDOUT "-" ' Print a minus sign if the value is negative
ENDIF
LCDOUT SDEC Counter / 10, ".", SDEC Counter // 10 ' now print the value
I must admit that I can't really follow the ASM code for the interrupt but since it's using Interrupt on change I think it "should" do x4 decoding so you "should" get 1440 counts per revoultion on a 360CPR encoder. I don't know why that's not happening. Hopefully someone else is able to help with that part.
/Henrik.
Bookmarks