Shop OBEX P1 Docs P2 Docs Learn Events
Mouse Shaft Encoders — Parallax Forums

Mouse Shaft Encoders

ArchiverArchiver Posts: 46,084
edited 2001-02-06 21:38 in General Discussion
Since many Stampers have asked about the circuit I am posting it here.
I have reduced at maximum the graphics file.

'Program to read a rotary encoder
'Writed by ACJacques - January 2001
'direction could be reversed by simply changing A B inputs

new var nib
old var nib
direction var bit
n var word

new.bit0 = in7 'input A on pin 7
new.bit1 = in5 'input B on pin 5

start:
old = new
loop:
new.bit0 = in7
new.bit1 = in5
if new = old then loop:
direction = new.bit0 ^ old.bit1 'XOR to determine direction
if direction = 1 then left:
if direction = 0 then right:
goto start:

left:
n=n+1
goto printa:

right:
n=n-1
goto printa:

printa:
debug home
debug sdec5 n," ", cr
goto start:

'================end of program=========================


> AC Jacques wrote:
>
> > I have recently dismantled an old mouse and cutted the two shaft optical
> > encoders, rewired the photodiodes thru a buffer transistor, and
> > now I have 160 conts/revolution encoders for less $10. BS2 Software is
> > very simple. Let me know if you want a copy.
> > ACJacques
> >
> > P.S. Sorry for re-posting this, but date was very incorrect first time.
Sign In or Register to comment.