That worked! At least as recognizing the IOC, but I think my logic is wrong - turning the knob one way makes the motor go faster and then slower. The idea is that a CW rotation would make it go faster but turning it CCW would slow it down:
Code:
' ***************************************************************
' [RBC - interrupt handler]
' ***************************************************************
Rot_Encoder:
RotEncDir = (A ^ B) ^ IOCAF.0
IF RotEncDir = 1 Then
; CW rotation - increase speed but only to a max of 255
IF MotorRPM < 255 then MotorRPM = MotorRPM + 1
Else
' CCW rotation - decrease speed to a min of 0
IF MotorRPM > 0 Then MotorRPM = MotorRPM - 1
EndIF
IOCAF.0 = 0 ' Clear interrupt flags
IOCAF.1 = 0
@ INT_RETURN
Bookmarks