# How do 1-axis of mice detect if it is going forward or back?

Status
Not open for further replies.

#### Hishamsaleh

##### Full Member level 1
Hi all,

in one of the last postes (not in this category) i found a similer guestion.. but with no right answer,,, I think that ppl didn't get the point of the question...
I know there is 2 axis in each mose to locate x-y motion... but for the singel axis.. i want to know how dop mice knew if the wheel is moving forward or backward...?

as you can see in the picture down, on each axis there is a transmitter and reciever... and wheel with about 36 hole that let transmitted beam to transmit to the resiever... so when the wheel moves, the beam recieved signal goes to be 1 0 1 0 1 0 1 0 1 like this... but what is the technique used to let the detector knows if it is moving clock wise or untic/w...

#### Hishamsaleh

##### Full Member level 1
bye the way:

1)in "how stuff works" i didn't find a technical answer.

2)in the pictures shown you find two sensors for each wheel... generally you will find only one for each.. but the resiever is 3-pins not 2 like shown... so they have the same function... but different shap or parts...

##### Member level 4
As you can see in the pictures, there are 2 sensors per axis
Lets call them A and B
each is positioned so to be in a 90 degree offset
So you may have something like this:
Forward
A 00001111000011110000
B 00111100001111000011
or Backward
A 00001111000011110000
B 11000011110000111100
Number of variations define pitch
Same stuff is also used on linear rules for machines
But they also have a home position for calibration, like
in printers, cnc etc...

#### Hishamsaleh

##### Full Member level 1
yes

As you can see in the pictures, there are 2 sensors per axis
Lets call them A and B
each is positioned so to be in a 90 degree offset
So you may have something like this:
Forward
A 00001111000011110000
B 00111100001111000011
or Backward
A 00001111000011110000
B 11000011110000111100
Number of variations define pitch
Same stuff is also used on linear rules for machines
But they also have a home position for calibration, like
in printers, cnc etc...
so you means:
if A reads 11 while B is 00 then B & A is 11, this means backward.
but:
if A reads 00 while B is 11 then A & B is 11, this means forward.

#### Nobel

##### Newbie level 2
that's ok.. and how about the optical mouse???? what is the operation used?

S

#### sick_man

##### Guest
it is the same principle for optical mouse

the optical light led shines with a certain flash rate used as a locking feature and 512 level depth in expensive pens tablets etc

just taking place of the led side of the optical coupler

a simple 3 btn mouse {normal one microsoft protocal}
uses two optical switch

an optical mouse has one {or more} light source for all pickups

similar rule of one one zero zero direction control just scalled as locked level scaller achived
described above

i made pic code reads a mouse position as two signed bytes -128 - +128 ans -128 - +128 for up dn left right

so... easy stuff

fifteen lines of picbasic code

on a 20 charicter 2 line lcd

didnt ever finish it off for the project i was using it for
but it works as described

same code as a terminal reader but instead of display ascii too lcd just too display the decoded packet bytes

a mouse protocol for 3 btn
uses a 5 bytes packet
each byte has 8 bits as said above

the first byte stores the button data the the movement for x,y
the next byte updated data since last packet sent
and so on for 5 byte long packet
first three bits are the buttons left middle

http://www.mousetrak.com/3byte.htm
http://www.mousetrak.com/5byte.htm

the code isnt included as i cant find it
one is for simulations
the other is the power circuit for a mouse using a max232 too provide the mouse with energy so isnt intended too simulate

*** updated versions

i found an error in the connections too the pim
but youll get the idea
very so simple

each start bit
@9600bps
till stop bit

S

#### sick_man

##### Guest
someone for a challange should write a picbasic inc files

for a mouse handler routines too employ a given port

or at least send a request it is made an integral part

Status
Not open for further replies.