# IR signal interruption: rotation / direction counter

I'm currently working on the design for my very first non-lego robot (yay!) and I'm considering using an IR LED and receptor to measure the
rotational speed of my turning wheels. I've got an example I'd like to duplicate, but I must be missing something in the mechanics or logic.
I've got a broken computer mouse here that I'm examining and I'm confused. An IR transmitter and sensor are facing each other across a disk which is connected (concentrically) to a rod driven by the mouse ball. The disk has teeth around the edge that interrupt the light at regular intervals as the mouse is moved along the desk, so the controller knows how fast the disk is turning (and hence how fast the mouse is being pushed across the desk). But the disk seems to be perfectly symmetrical about its center, and the teeth seem to be evenly spaced, and so I can't figure out how the controller knows _which direction_ the disk is turning. Obviously it does, or the computer wouldn't know whether to push the cursor up or down (for example). There are two rod-disk contraptions perpendicular to each other, so the computer can see movement in two directions, but there seem to be no other mechanisms that could detect which direction the disk is rotating.
I considered that perhaps the width of the teeth or the spaces between them might be variable, so the controller sees the variation in light-dark times, but that doesn't seem to be the case (and it would only be reliable if the actual rotation speed were constant, which it isn't guaranteed to be.) All the teeth also seem to be identical, and I can see no difference between the clockwise-ward and counter-clockwise-ward sides (so the light dropoff and return rates would be the same in either direction, and thus there would be no variation in the signal waveform to show the difference in direction).
I would like to implement a similar rotational speed sensor in my robot, and it certainly would be nice to have directional information without having to incorporate some other mechanism. Especially since it seems to have been implemented in this mouse without highly-precise and/or difficult-to-machine hardware. Does anyone have any idea how this might be working?
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
(I tried this once before...but my news provider is bugging out a bit. If there are double posts, I apologize in advance!)
The IR recievers actually contain 2 photodiodes, and (should) have 2 outputs. The ones I have used (from Microsoft mice) have 3 pins - 1 and 3 are the outputs, and pin 2 is VCC. When properly placed (As they are inside of a mouse) when a tooth passes in front of the detector, the detector will generate 2 pulses, 1 on each output. The 2 outputs will be 90 degrees or so out of phase. To determine the direction the teeth are moving, you just need to detect which output is leading (I have heard of designs which use a flip-flop for this purpose...but haven't done it myself, as I ignore the second output, and use them as simple run-of-the-mill IR photodiodes).
Pins 1 and 3 may need pulldown resistors.
If you don't position the detector properly, the 2 photodiodes inside will see the teeth pass at exactly the same time. Thus you'll get both outputs going low at the same time, and won't be able to determine direction.
Good luck on the 'bot!
-Alex

<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
In a mouse, the sensors have two seperate elements side by side. So close you probably didn't notice. The pulses from the sensors are 90 degrees out of phase with each other. This allows the processor to determine both the speed *and* direction of the motion.
HTH
Keith