Continue to Site

Welcome to

Welcome to our site! is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How does the mouse know if its going forward or backwards?

Not open for further replies.


Member level 5
May 14, 2001
Reaction score
Trophy points
Activity points
hello friends,

I'm working with an encoder for a DC motor that works just like a mouse wheel. My question is, if the wheel seems to be mechanically symetrical, how does the mouse controller know if the ball is going forward or backward? the same question for the left or right sides...



In mouse You can find for left and right direction and position sensing a dual opto-gate with phase shifting.The controller IC convert these signals
for PC.You can build a same circuit with flip-flops and up-down counter.

There're 2 photo-led-sensor pairs put alone X and Y axis of wheel .
So u can detect the X and Y movment to decode the direction.
U had better open ur mouse to take a look .

mouse wheel


actually, the mouse have 2 axes (x and y)

if u remove the ball, u'll see 2 axes and 1 or 2 wheels to close
up the ball.

the encoder is a quadrature encoder type like used un
feedback motors like servo...(only dubble made)

for further encoder info (details ) see link below.




Hello folks !

I understand that mouse have two axes (x, y), but lets take only one axe in consideration y (up or down). The wheel in the mouse for up and down rotates and blocks/unbloks the light beam of photo-led-sensor. How do we know from only that information if the mouse is going up or down? So far this only tells me that the mouse is moving (up or down).

Thanx for all your answers.




if u go to the link i gave before, u'll understand....

u have 2 sqware waves,
the 2 waves are shifted 90° (mechanicly, by moving the 1st fotocel
1/4 wave further than the 2nd fotocel)

if u see this picture (imaginary) in front of you....
than u can say...
if upgoing edge 1st fotocel is there , and followed by upgoing edge from
2nd fotocel....then direction is ">"
if edge 2nd fotocel is first and then edge 1st cel...
the direction would be "<"

u can also calculate speed from this....
if quadrature encoder is a 500ppr type (500 pulses pro revolution)
no need to explain further ?....

hope this is clearing a little bit.

greetz, Gelly



quite simple:
--plastic--| breaktrough into wheel |---plastic-
O led1 led2 O

now shift breakthrough in left direction, what happens ? Beam break first at led1. The same in the other direction, led2 signals puls rising at first. Really quite simple. This Principle is call -> Direction Discrimination.


Sorry, draw with ascii is not easy, imagin please led1 & led2 underneath breaktrough!

What ball, what optocouplers? My mouse is optical. No moving parts. It consists of a twodimentional CMOS image sensor, a bright LED to act as a "shutter" to define the timebase and a DSP to do something about the acquired images. Actually mine mouse contains two such systems installed on a 45 deg angle reative to each other for better resolution.

What some could expect is, that in order to determine the direction, the DSP should try to correlate two consecutive images and derive the disposition, hence the direction and the speed of the mouse scan for the given timebase. This presumably means that the mouse pad have to have some optical features. The damned thing however is quite happy on a "featureless" surface like say a white paper. Any idea what could be the principle of operation of this thing?

Even if a white paper seems featureless, I has grain, which can be easily used as a reference. As you've said, the DSP just correlates low res images (32x32 if I remember well) at high speed, it's all the magic within.

Try to do the same experiment with a polished black surface (a black book cover will do), and the mouse won't move.

I understood what you guys say, when using 2 leds it makes sense, but in this mouse there is only one led/receiver per wheel... so... is it all about the pulsed signal and the skipped pulses? how to define direction with only one "optical barrier"?



I understood what you guys say, when using 2 leds it makes sense, but in this mouse there is only one led/ receiver per wheel... so... is it all about the pulsed signal and the skipped pulses? how to define direction with only one "optical barrier"?

Hmm, may be they got two-pixel sensor in the same package? I don't see how else could some get a direction info, except if the reticle have very specific coding (even then though the light source have to move relative to the sensor, what is not the case of a LED/Photodetector pair), yet so far there is nothing specific into the mice weel. It is anisotropic about the both rotational directions.

Sorry to waste the bandwidth, but if the LED part of a single LED/photodiode pair consists of two elements chopped at high frequency, then a lock-in of the photodetector at the chop frequency could produce phase sensitive info when the mouse weel rotates, this way providing dirrection info.


hey guys, stick to the point

when the man wants some info,
just try to help and dont explain him the optical mouse technology.

the question was about an dc motor and encoder.

well, about the fotocells, they are fitted in one housing
and 'looks' like 1 thing that supposed to be the led.

there is one barrier but.....
diffucult to draw here...
yesterday i prepared a hand drawing , but could not
put it in the message.



yes gelly

yes gelly,

It seems to be so:

Someboby got a question like how is the temperature today, and suddently a lot of people starts a discussion about the klima changes on earth.
But the fact is, the pur man never get a simple answer for a simple question.

strange! :roll:



I am an Industrial Motion control engineer by trade so I'll explain the process as simply as possible.

All incremental encoder devices work on the principle of delivering 2 output waveforms (minimum), 90 degrees out of phase from each other.
By reading which pulse train rises (or falls) first, directional information can be obtained. Thus such a device is able to give both directional and positional (by counting the pulses) data. Quite simple really. :D



Not open for further replies.

Part and Inventory Search

Welcome to