PDA

View Full Version : encoder HEDL 5540



kutsi
- 25th May 2007, 02:49
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

HenrikOlsson
- 25th May 2007, 06:15
Hi kutsi,


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...
Yes, the HEDL series encoders has linedrivers in them, thats where the L in the part-number comes from. It's a good idea to use a line reciever chip with them but you dont HAVE to. Just use the two non inverted signal lines (seems to be pin 5 and 7 on my data-sheet) from the encoder and connect them to the PIC - you should be fine with that.

/H.O

kutsi
- 27th May 2007, 07:15
it works...

MMUKPEKI
- 11th June 2007, 14:00
Hey all!

I got bored one day and was flicking through random forums and I came across this one. If you ever get stuck with the encoder and a PIC (cos I'm a PIC programmer too), e-mail me on [email protected] and I should be able to help you out.

Have fun!

Pete.