Embedded Eye

Give your gizmo the gift of sight

Why an optical mouse does not work when you hold it up

I get this question a lot: Why is it that an optical mouse works fine on a desk, but when you lift it up and move it around it does not pick up anything. This question typically gets asked by experimenters trying to make a visual odometer using an optical mouse. A related question is about our smaller sensors- "How far can they see?" The answer is pretty simple to explain using image formation principles in elementary optics. There is a good Wikipedia page on lenses that goes into detail, but I'll touch on the very basics here, which can be explained with one equation.

Referring to the figure above, the focal length "f" of a lens is essentially how far from a lens rays of light converge when incoming light is parallel, e.g. from an infinitely distant object. The convergent point is essentially where an image of the infinitely distant object is formed. If you hold a sheet of white paper at that location, an image of the object will form on the paper. If the object is bright enough, or if you prevent stray light from reaching the paper, you should be able to see the image. An image sensor (or a piece of photographic film for that matter) will detect the image. If you move the image sensor to the left or to the right, the image will get blurry.

Now suppose the object brought a finite distance r1 from the lens. An image of the object will still form, but at a new distance r2 from the lens on the other side. The relationship between r1 and r2 is defined by the equation:

For example, suppose the lens has a focal length of f=10mm. If you are imaging something r1=20mm away, then the equation yields r2=20mm- You'd have to put the image sensor 20mm away from the lens to grab an image of the object. If you are imaging something r1=100mm away, then the equation yields r2=11.1mm. If you are imaging something r1=10m=10,000mm away, then the equation yields r2=10.01mm. Essentially as the distance r1 to the object increases, the value of r2 drops to approach f. The "infinite distance" case first discussed is simply the case when r1=infinity, which yields r2=f.

So how does this relate to the optical mouse? The lens that typically comes with an optical mouse is designed to image the desk, which is just a few millimeters away. This short distance is r1. The lens is similarly placed r2 = just a few millimeters away from the optical mouse chip. So the focal length f of the lens was designed to work with these values of r1 and r2. (Notice how the data sheets that come with an optical mouse chip and lens pair specify how far the lens must be from the desk.) In order for the optical mouse chip to see objects further away, you need to either change f (get a new lens) or move the lens closer to the chip. (For those of you who are trying to make a visual odometer using an off-the-shelf optical mouse sensor, I recommend getting some lenses and lens mounts from Sunex and experimenting with those.)

As for whether our smaller sensors can see objects "far away"- Most of these sensors use a focal length on the order of f = a millimeter or two. So from the perspective of the above equation, this makes 1/f very large. Any object r1 = a few centimeters to infinitely far away will have little impact on the optimal value of r2. Thus objects at all of these distances are for all practical purposes in focus.

Views: 4609

Comment by Randy Mackay on August 16, 2011 at 12:11am

Wow, this is very relevant for me.  I've experimented a lot with putting various different lenses on a mouse sensor (the ADNS3080) and I've had good luck with some lenses but not others.  Even two different lenses but both with the same focal length will have different results (i.e. one can't focus properly or it's low light performance is not good).  I should give more details but I don't have them immediately at hand.


I wonder if there's an issue re the little cover with a pinhole in it that is above the imaging chip.  I wonder if that pinhole might be too narrow for some lenses.  Maybe for some lenses the image enters the chip at a wider angle and hits the edges of the pinhole?

Comment by Geoffrey L. Barrows on August 16, 2011 at 8:15am

Without having played with a mouse sensor chip myself, I can think of several possibilities why different lenses with the same focal length behave differently. It may be that although the focal lengths are the same, the "back focal length BFL" is different for each lens. The BFL is basically the distance between the bottom of the lens and the focal plane, and itself can vary from lens to lens. It may be that one of those lenses is simply out of focus, or the mount you are using doesn't support the proper distance.

Another possibility is that the lens may have a small F-stop, e.g. have a large aperture. Then some light might strike the sides of the pinhole opening causing a bit of washout. This is just a guess though.

If the sensor works but not in lower light levels, then maybe try a lens with a smaller F-stop. This will allow more light to enter. Halving the F-stop (say from 6 to 3) allows in four times as much light and makes the sensor four times as sensitive.

Another option for increasing sensitivity is to remove the IR filter that many lens assemblies have. This is the slightly pink slab of glass or plastic, usually at the bottom of the lens. This filter is meant to block IR light that can affect the color response of color imagers, but is not really useful in your case. If you remove that then more light will reach the sensor.

Comment by Geoffrey L. Barrows on August 16, 2011 at 8:17am
By the way, I just saw a small error in the above drawing. The equations and the discussion are correct. But the "image of object" on the right should be upside down! Oops.
Comment by Randy Mackay on August 16, 2011 at 8:08pm

Thanks a lot for your help.


I think you might be right on both (all three?) counts.  Certainly the standard M12 lens mount I can find are too long because they're designed for applications where the image chip is placed inside the bottom of the mount but with a mouse sensor, the image chip is 1mm or so back inside the sensor itself and the lens is on top of the sensor..so basically the lens ends up too far away.


This f-stop thing sounds key as well.  So I guess I would need a really low f-stop because the mouse sensor's need a lot of light..but not too low that the light hits the side of the pinhole...or maybe i'll try drilling out the pinhole a bit!


thanks again.

Comment by Geoffrey L. Barrows on August 17, 2011 at 8:09pm
M12x0.5 is a pretty standard thread. You can probably buy a tap for that size and machine your own lens mount using soft plastic. Alternatively you could just cut away the top part of the lens mount so that the lens screws further in and gets closer to the chip. Although not elegant, that would help you determine if focusing is the issue. Then you can draw up and print out your own lens mounts using a 3D printer.
Comment by Randy Mackay on August 17, 2011 at 8:42pm

thanks.  Yes, I'm going to cut away the top of the lens mount as a first step to get the right length.  I find it hard to make a the threads with a 3d printer but you're right it should be possible.


Actually I've also found a supplier on alibaba who will make custom mounts for 12 cents a pop although minimum order is 10,000. 


Thanks for your help!

Comment by Arthur Retana on January 3, 2012 at 3:19pm

I used the thin lens eqaution to get a rough estimate as to what size lens I needed to get an optical mouse sensor to operate at a distance of about 3 inches off the floor. I ordered an 18mm diameter with a 72mm focal length. The back FL is 70.05. I noticed that you guys were mentioning various mounts and I was wondering where I can find information on selecting the correct mount.


Also, for Randy, you said that you have tried some lenses I was wondering which lenses have you tried and what image distance are you trying to get out of them?

Comment by Geoffrey L. Barrows on January 5, 2012 at 10:08pm


Most of the lenses we use of that scale are lens assemblies made by the likes of Sunex (www.optics-online.com) The lens assembly comes in a threaded barrel, and you can also get lens mounts that have the same thread thus allowing you to screw in the lens and focus it.

It sounds like you have a singlet lens e.g. a single piece of glass with a 72mm focal length. You will probably need to design your own lens mount to hold that lens the correct distance from the chip (and of course prevent stray light from entering from the sides). You could probably machine one, or draw one up using a CAD tool and get it 3D printed.


Comment by Randy Mackay on January 6, 2012 at 2:45am


     I bought my original lens and lensmount from peauproductions.  I used a standard M12x0.5 lens mount which is super common and easy to find lenses for BUT the issue that I had was that for a mouse sensor you need to put the lens very close to the sensor so i ended up having a custom lens mount (it's only 11mm long) manufactured by a chinese company.  They were cheap (12cents each) but I now have a closet with about 9000 lens mounts more than I think I will ever need.  want some?

     I bought my lenses from senview but again, you need to order at least 1000 at a time.

     Similar to what you're doing, I need to figure out what lens to use for very short distances so it can be attached to a car (up until now it's always been a heli or quadcopter).  A very short focus length should work (like a 2.5mm lens).

     I actually tried to 3D print a lens mount using shapeways.com but I couldn't get it to work..I think I messed up the thread spacing and then the custom mounts arrived so I didn't pursue it further.

Comment by Geoffrey L. Barrows on January 6, 2012 at 9:48am

Randy, Arthur,

I didn't know about senview- thanks for the link. Actually we found a supplier of lenses as well-Wintop- they sell an M6x0.35 lens for around a dollar a piece (minimum quantity 1000). They don't have lens mounts and so we are trying to make our own. We've 3D printed them in the past. It can be a bit tricky to get the threads just right and the material choice does seem to matter, especially with threads that small. Mostly we use other "more expensive" 3D printing services but I just sent a design to Shapeways so we'll see how that turns out.

I'm impressed though you got lens mounts for 12 cents apiece. Which company did you use to make them?

I remember a long time ago we would actually make our own lens mounts by drilling plastic and then tapping it- that worked as long as you could find the tap size!



You need to be a member of Embedded Eye to add comments!

Join Embedded Eye

© 2022   Created by Geoffrey L. Barrows.   Powered by

Badges  |  Report an Issue  |  Terms of Service