Hello

I was looking for a rotary encoder and I found this 733-726, you can download its datasheets from here

www.farnell.com/datasheets/48122.pdf

I thought I can post the code I wrote for this encoder here before ordering...

Please if any body got this kind of rotary encoders, then try this code and tell me if it works or not, also if any one has a suggestion to improve the code, don't hesitate to share....

@ DEVICE PIC16F84A, HS_OSC, WDT_ON, PWRT_ON, PROTECT_OFF

DATA $C0,$F9,$A4,$B0,$99,$92,$82,$F8,$80,$90

Define Osc 4

TRISA = %00011
TRISB = 0
PORTA = 0
PORTB = 0
INTCON = 0

Index Var Byte : Index = 0

A var PortA.0
B vAR PortA.1


ATemp var bit
BTemp var bit


Main:

atemp = a : btemp = b

if atemp == btemp then
while a == b : wend
else
goto main
ENDIF


PAUSE 1
if atemp <> a AND BteMP == B then VOL_UP ' CW Rotation Checking
IF ATEMP == A AND BTEMP <> B THEN VOL_DOWN ' CCW Rotation Checking


' Indicate the incoming pulses and rotation direction
' with a 7-segment display.... Very Nice indeed....
VOL_UP:
read Index, PortB
If index == 10 then
index = 0
else
Index = Index + 1
endif
GOTO MAIN

VOL_DOWN:
read index, PortB
If Index == 0 then
Index = 9
else
index = index - 1
endif
Goto main

END

A seven segmet display is used to allow visual indication of response, I tested this code with a wheel from an old mouse, it has three wires, black, red, and yellow, but results were annoying because of the bad wheel signals, but in essense the code is working fine...as I tried to pulse the inputs with a wire and three fingers...when I squeeze the wheel a little bit, it works very nice