mmm, can you tell more about what you want to do with the rotary encoder???
i'd never use this IC and i believe we can remove it and connect the encoder directly to the PIC.
I often use rotary encoder in my apps to navigate between menu and/or get user entry. So an extra IC should be motivated by something that i don't see/understand.
Bellow is one example to use rotary encode to increment/decrement a variable
Code:
' Procedure to get value change from rotary encoder
'
OldPos = (PORTB & %11000000)>>6 ' get only PORTB<7:6> bits
NewPos = OldPos
' see if encoder has move
'
while ((NewPos==0) or (NewPos==3))
NewPos = (PORTB & %11000000)>>6 ' get only PORTB<7:6> bits
wend
pause 20 ' debounce delay
' Get encoder movement
' --------------------
'
' Rotary encoder output table (clockWise rotation):
' -------------------------------------------------
' 00
' 01 between move (half detent)
' 11
' 10 between move (half detent)
'
' Using XOR
'
' OldPOS : 0 0 3 3
' NewPos : 1 2 1 2
' movement : CW CCW CCW CW
' XOR -------------------------------
' 1 2 2 1
'
' So, if NewPos XOR OldPos = 1 => increment
' Newpos XOR OldPos = 2 => Decrement
'
Newpos=newpos ^ oldpos
select case newpos
case 1
menuchoice=menuchoice+1
case 2
menuchoice=menuchoice-1
end select
Last edited by mister_e; - 9th July 2005 at 13:21.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Bookmarks