Your right, Big mistake on my part it is per Second.
The program that i have for the encoder:
Gets state, gets new state makes old one oldstate
then it looks to see what direction it went.
Is there some better way of doing this?
-----------------------------------------------------
CurVal = (PortB & %00110000) >> 4 ;get current reading
OldVal = CurVal ;initialize for future change
Main
;-------------------
CurVal = (PortB & %00110000) >> 4 ;returns 0..3
If CurVal <> Oldval Then
Branch CurVal, [S0,S1,S2,S3] ;if changed look at old
EndIf
AfterBranch
S0 ;reading is 0, check if came from 1 or 2
;--------------------
If OldVal = 2 Then
GoSub ClockWise
Else
Gosub CounterClockWise
EndIf
Goto AfterBranch
S1 ;reading is 1, check if came from 0 or 3
;--------------------
If OldVal = 0 Then
GoSub ClockWise
Else
Gosub CounterClockWise
EndIf
Goto AfterBranch
S2 ;reading is 2, check if came from 3 or 0
;--------------------
If OldVal = 3 Then
GoSub ClockWise
Else
Gosub CounterClockWise
EndIf
Goto AfterBranch
S3 ;reading is 3, check if came from 1 or 2
;--------------------
If OldVal = 1 Then
GoSub ClockWise
Else
Gosub CounterClockWise
EndIf
Goto AfterBranch
ClockWise
;-------------------
OldVal = CurVal ;ready to check next input
Counter = Counter + 1 ;add one to counter value
Return
CounterClockWise
;-------------------
OldVal = CurVal ;ready to check next input
Counter = Counter - 1 ;subtract one to counter value
Return