I am working on a home-built CNC machine that uses stepper motors and MXL timing belt for the machine movement. Because I'm using steppers, there is no feedback to the controller about the actual position of the machine (ie, open-loop). Sometimes when I am making cuts, shards of material fly into the path of the gantry and gum up the track, causing the motor to skip steps. To solve this, I am installing a dust shoe and vacuum to keep the area clean, but this still doesn't address the problem of skipping steps due to any number of various reasons.

Of course, there are solutions that already exist that "close the loop" for the industrial market, but I think they would be out of budget for the homebrew hobbyist. If something as ubiquitous as an optical mouse sensor could be used, it would be a great boon for improving DIY machine robustness, if even marginally. It could also be used for self-calibration if the measurements are accurate enough.

The footprint of my machine is 750x1000mm, so I need something that can measure accurately over that distance. Obviously, the optical mouse can be used to measure distance (that's what it is designed to do!), but what parameters should I be looking for to meet my goal (DPI, CPI, camera resolution, etc) of measuring to a precision of 1-10μm and would these measurements be repeatably accurate?

(Each step of the motor moves the machine about .01143mm, so I guess 1μm precision would be preferred but that might be asking too much.)

Unfortunately, it seems that my best lead and the most discussed family of sensors from Avago (ADNS) are discontinued. For example, the ADNS-9800. Have they sold the technology to another company? Does an alternative exist that is easy to source and has proper datasheets? I'm guessing they have been discontinued because other companies have integrated the USB aspect into the die of the sensor module, making the entire thing cheaper to produce (rather than needing another micro to do the SPI/I2C->USB conversion).

Is there a better way to do this while keeping costs in check? Up to $30 per sensor would be a target for this kind of market, I think.

  • \$\begingroup\$ adafruit.com/blog/2010/11/08/digital-calipers-tear-down \$\endgroup\$ Nov 5, 2013 at 18:27
  • \$\begingroup\$ Given an optical mouse which does 1000dpi. An inch is 0.0254m, so divided by 1000 would come to 25μm. I didn't give it much more thought than that, don't know if a regular mouse sensor would work reliably on the material you are trying to work with. Dpi's are commonly in the user manual of the mouse or even on the box. \$\endgroup\$
    – jippie
    Nov 5, 2013 at 18:28
  • \$\begingroup\$ @IgnacioVazquez-Abrams I did see that link from another Q here on EE.SE. I still don't fully understand how they work, even after reading through some stuff. That seems like it might be the best way to go, but then I have to build 700-1000mm of track for the sensor to go over, which might be challenging. \$\endgroup\$
    – dext0rb
    Nov 5, 2013 at 18:35
  • \$\begingroup\$ You could build it in pieces with 2 or more PWM drivers and then have each handle a specific set of spaces, so that there's always one available for measurement when the other(s) is(are) over a gap. And making it wider might increase the resolution. \$\endgroup\$ Nov 5, 2013 at 18:38
  • \$\begingroup\$ DPI figures often owe more to the marketing department than anything (see also printers, scanners, etc.) - I'd also be concerned that with debris / dust flying around plus vibration, an optical sensor of that sort (reading a surface) might have trouble. I would think closely about the failure mode - is the slip mechanical (belt slipping against gear) or electrical (motor being jogged a step), is there a commonly used sensing/encoding/measuring device that would not suffer this same error? The cheapo DRO's from eBay china might be worth a look. \$\endgroup\$
    – John U
    Nov 5, 2013 at 19:43

3 Answers 3


I have tried this before, using an Avago sensor harvested from an optical mouse.

It doesn't work.

The resolution is excellent but the accuracy is terrible. And the calibration varies with distance from material to the sensor.

I arranged a test with a 3" diameter wheel and the sensor reading the outside "tread" of the wheel. I also put a flag on the wheel, passing through an optical interrupter sensor. The number of counts read per revolution varied by a few tenths of a percent, nowhere near good enough repeatability for machining.

I guess you could use the optical mouse sensor in combination with an accurate but low-resolution sensor to fill in the in-between points. But really, I think other sensor technologies are more appropriate for this.

  • 1
    \$\begingroup\$ The resolution is excellent but the accuracy is terrible. That's what I was afraid of hearing. \$\endgroup\$
    – dext0rb
    Nov 5, 2013 at 19:41
  • 3
    \$\begingroup\$ +1 just for properly delineating between resolution and accuracy. \$\endgroup\$ Nov 6, 2013 at 9:06

Neat idea. I considered using a hacked Livescribe pen with special dot rails for the same purpose, then an absolute location would be provided, rather than the relative location a basic optical mouse would provide. I know the pen claims to have precision to 1µm, but it's hard to say the accuracy. I still think this is a good idea; I just haven't got around to trying it. If you do try it, please update us.

As for optical mouse parameters, you'll want to look for high DPI. In your case for 1µm resolution you want more than 25,400 DPI. Needless to say that is rather high. A basic optical gaming mouse might have a DPI of 2,500. Again, that's precision, not accuracy. Optical mice are probably not the way to go.

  • \$\begingroup\$ Interesting comment about the Livescribe! I have one sitting on my desk that I never use. Might be interesting to read up on it some more. \$\endgroup\$
    – dext0rb
    Nov 5, 2013 at 18:35
  • \$\begingroup\$ Precision and accuracy is the same. Maybe you are talking about resolution vs accuracy? \$\endgroup\$
    – johnfound
    Nov 5, 2013 at 18:45
  • 6
    \$\begingroup\$ @johnfound No, they're not the same. Resolution and precision may be the same. Resolution and precision refer to how many significant figures a value has, accuracy refers to how correct those values are. This is a very important distinction. \$\endgroup\$
    – Samuel
    Nov 5, 2013 at 18:49
  • \$\begingroup\$ This might be a dumb question, but can I use magnifying optics to increase the DPI? ie would a 10x magnifier on a 2,500 DPI sensor get me 25,000 DPI? \$\endgroup\$
    – dext0rb
    Nov 5, 2013 at 19:24
  • \$\begingroup\$ If you use the mouse sensor on a large encoder wheel you might get an effective increase in DPI. That is, dots counted on the wheel would be higher (depending on gearing/wheel diameter) compared to linear travel of the axis in question. \$\endgroup\$
    – Samuel
    Nov 5, 2013 at 20:12

If you're using a leadscrew-based system, you can put optical encoders on the ends of the screws. Harvesting the guts from a ball mouse would give you some high resolution encoders and most of the control circuitry as well. I can't find the resolution of a common encoder wheel, but the ball acts as a significant gear-train internally, so perhaps a similar mechanism can be applied.

  • \$\begingroup\$ My system is MXL belt driven right now. \$\endgroup\$
    – dext0rb
    Nov 5, 2013 at 19:33
  • \$\begingroup\$ Can you pass the belt over (well, under) said ballmouse roller then? \$\endgroup\$ Nov 5, 2013 at 21:42
  • \$\begingroup\$ Bad plan, as it won't account for any nonlinearities like backlash. Measure at the table, and nowhere else \$\endgroup\$ Dec 7, 2013 at 13:38
  • \$\begingroup\$ Ball mouse encoders are LOW resolution. They have tens of pulses per revolution (some use conductive graticules) and no gearing is taking place. The ball is used to couple the linear movement from the desk to encoder wheel 1:1 in the two orthogonal axes. The electronics could thoretically use sine-cosine subsampling of the quadrature signals if they are read (and genrated) in an analogue fashion to gain some more resolution. Commercial optical encoders may have thousands of lines per revolution. \$\endgroup\$
    – KalleMP
    Nov 28, 2014 at 17:29

Not the answer you're looking for? Browse other questions tagged or ask your own question.