hi everyone,

My question is about getting info from a maxon dc motor. I'm using HEDL 5540, and pic18f4550. So I started to search the forum for an interface code. Many thanks to mister e, I found the code (which was posted 3 years ago... The first thing in the morning, I will try the code.)
Also can u pls help me about the definitions, what should I include for such a code to work, and why?

Actually my main concern is about the HEDL 5540 datasheet. In the datasheet they are showing SN75175 as data receiver. But, when I was reading some of the posts in the forum, I got the feeling that it is somehow possible to connect encoders directly to pic, without any data receiver. I'm new at designing such things and it really confused me...

Thanks...
'
' ////////////////////////////////|\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
'
GetEncoder:
' ===========
'
' Procedure to get value change from rotary encoder
' 1. Read variant of rotary encoder (move, enter pushbutton)
' 2. Store result in 'MenuChoice' & 'MenuPointer' variables
'
' Resume conditions:
' ------------------
' 1. Encoder Move
' 2. PBEnter button is pressed
' 3. User move to previous menu
'
' ////////////////////////////////|\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
'
OldPos = (PORTB & %11000000)>>6 ' get only PORTB<7:6> bits
NewPos = OldPos
'
' -----------------------------------------------------
' see if encoder has move or if ENTER button is pressed
' -----------------------------------------------------
while ((NewPos==0) or (NewPos==3)) and PBEnter
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
Menupointer=menupointer+1
'
case 2
menuchoice=menuchoice-1
Menupointer=menupointer-1
'
end select
'
' ---------------------------
' test the actual menu choice
' ---------------------------
' if higher than the maximum menu item... stay there
'
If menuchoice > Item then
menuchoice = Item
menupointer = thisSCREENLINES
endif
return