DIY Optical Sensor Breakout Board makes DIY Optical Mouse

Wanting to experiment with using optical mouse sensors but a bit frustrated with the lack of options, [Tom Wiggins] rolled his own breakout board for the ADNS 3050 optical mouse sensor and in the process of developing it used it to make his own 3D-printed optical mouse. Optical mouse sensors are essentially self-contained cameras that track movement and make it available to a host. To work properly, the sensor needs a lens assembly and appropriate illumination, both of which mate to a specialized bracket along with the sensor. [Tom] found a replacement for the original ADNS LED but still couldn’t find the sensor bracket anywhere, so he designed his own.

optical-mouse-sensor-breakout-squareThe github repository contains all the design files as well as Arduino libraries. Thinking others might share his interest in an easy to use breakout board for the ADNS 3050 that doubles as the mounting bracket, [Tom] started a Kickstarter campaign for a small production run.

Optical mouse sensors have often shown up as experimental movement trackers in hobby robotics, and even as low-res cameras. There’s a lot going on in these little packages and [Tom]’s fully documented open-source design tries to make it more accessible.

36 thoughts on “DIY Optical Sensor Breakout Board makes DIY Optical Mouse

    1. Ever since Pixart took over Avagos mouse sensor division parts have been scarce if you weren’t a manufacturer. The new PMW3325 sensor looks interesting but I can’t find it anywhere as of right now. Pixart have mostly ignored my contact requests too. I found a company in china that still stocks the ADNS 3050 and that’s where I’ve been sourcing my sensors right now.

        1. I’ve been hunting sensors for a long time, and either the documentation was unavailable, or the parts were in quantities less than 200. My specific requirements are available documentation and pixel-matrix readout capabilities. Other than that any sensor assembly (w. LED and lens) would suffice, high end ones would be more than what I need, but I’d take what I can.

  1. These are extremely interesting devices, and some of them have very high resolutions. I’ve made a few dev boards with these for various purposes, you don’t need to make specifically a mouse. You can point them at the filament on your printer, or cut an acrylic wheel and sandpaper the edge and mount one to watch the edge of the wheel as it rotates.

    Lots and lots of resolution this way. Some of the chips have thousands of points per inch. They’re very easy to program/interface to.

      1. Yes.

        Depending on the surface finish of your rods, it could read distance directly from one of the support rods. If the rod is too “uniform” in appearance it won’t work as well, but you can do things like add bluing or go over it with a sharpie to make a more specular surface.

        This would reduce the travel distance by the width of the sensor, so you could mount an extra rod parallel to the support rods that isn’t used for support, you can make it out of something more specular and have the sensor look at that.

        Take an acrylic rod and sand the outsides until it looks frosty, or similar.

        I also found that an optical mouse makes a good prototyping board outright. Take a pair of side-cutters and cut out the DIP micro controlling the optical sensor, and replace the pins with headers. Power, ground, and SPI lines going to the sensor have to also go to the micro, so just find these by looking up the sensor datasheet online.

        See here for images.

        https://hackaday.io/project/5283-potpourri/log/49337-optical-flow-sensor-from-an-led-mouse

        I could even give you the arduino code, but you probably couldn’t use it. It’s not a sketch, it runs on the bare micro :-). (I have a ton of shelved projects like this.)

        Also, using an optical mouse directly isn’t terribly difficult. On Windows you grab a copy of LibUSB and make a driver specific to the PID/VID of the mouse that doesn’t attach as a regular mouse. Then you can open the raw device from a program and get the X/Y displacement directly.

        I haven’t done this yet on linux, but there it’s probably even easier.

        1. I fount the rubber page grabbers from gutted inkjet printers work great for pickup services. I would use reflective tape and stripe it for DIY shitty reflective encoders. Now that I can get a mouse on Amazon for $3 why not do it this way all the time!

      2. Take a look at the PMT9123. It’s made for that purpose: “compact tracking system that does not require code wheel, code strip many any special marking on the tracking surfaces for motion control or tracking purposes”. The non-NDA datasheet available on the Pixart site has a datasheet that’s sufficiently complete to figure everything out that would be needed for an Arduino library. 25ips at accelerations of up to 8g also seems like enough for most 3d printers.

        If there is enough interest in this sensor, let me know and I will talk to my contact at Pixart and my distributor about pricing and start a group get. So please leave a comment here or on my hackaday.io project: https://hackaday.io/project/18467-optical-tracking-sensor

      3. yes IF you talk directly to the sensor AND have full documentation.
        Those sensors have tons of customizable parameters like smoothing, negative acceleration and interpolation. they are NOT linear in 99% of mouse usage scenarios.

  2. How well do you think an optical mouse sensor like this would track as a rotary encoder on a telescope’s azimuth bearing? High CPS rotary encoders are damn expensive but a hacked up mouse with 2000dpi on an 8″ bearing is like 16,000CPR.

    1. Obviously I wasn’t the first person to have this idea… :)

      I’ve heard that the repeatability on these sensors isn’t great. However, most sensors of this type can also output raw “camera” data. My thought was that you could print a strip of paper with a non-repeating pattern and wrap it around the azimuth bearing, then use the raw camera data with a simple computer vision algorithm to detect absolute position on the strip. (Similar to the way those fancy Livescribe pens work.) Since camera data readout is slow on these sensors you could use the sensor’s less accurate relative positioning to get a rough estimate of where you were on the strip, then read the camera data when the position was no longer changing to get an absolute fix.

      While these sensors go up to “2000 cpi”, I believe the imaging array is actually a fixed size, and the cpi setting just multiplies the counts it gets from the array, so you’re not actually getting any more accurate readings… But still, at the sensor’s native 1000cpi, if you ran this sensor around the outside of an 8″ disc, you’d be getting around 25,000CPR, which is up there with the best rotary encoders. That would give you about a 50 arcsecond step, which would be overkill for most wide field scopes.

      I’ve been trying to figure out how to make this work with my GSO SkyView.

      (On a side note, as [uminded] mentioned, if you think these sensors are hard to get, try finding the high-resolution 30k CPR rotary optical encoders they use on telescope mounts. They seem to be only manufactured for and sold to telescope mount manufacturers, who mark them up to around $100 apiece. The market is ripe for disruption.)

      1. Saw in the datasheet that the 3050 also has register values for the minimum and maximum and average. That’s sort of handy in regards to the issue of reading out all pixels and the evaluating since you have a quicker alternative way of getting some essentials.

        PIX_MAX
        Data Type: Eight-bit number.
        USAGE: Store the highest pixel value in current frame. Minimum value = 0, maximum value = 254.
        The highest pixel value may vary with different frame.

        PIX_ACCUM
        Data Type: High 8-bits of an unsigned 17-bit integer.
        USAGE: This register stores the accumulated pixel value of the last image taken. This register can be used to find the average pixel value, where Average Pixel = (register value AP[7:0])* 1.058
        The maximum accumulated value is 122936 but only bits [16:9] are reported, therefore the maximum register
        value is 240. The minimum is 0. The PIX_ACCUM value may vary with different frame.

        PIX_MIN
        Data Type: Eight-bit number.
        USAGE: Store the lowest pixel value in current frame. Minimum value = 0, maximum value = 254.
        The minimum pixel value may vary with different frame

  3. Could a CD/DVD and drive be used as a high resolution rotary sensor? Of course they could, but I haven’t the slightest idea how to do it.
    Or maybe even as a super high res optical mouse! LaserDisc mousepad maybe!?

    If anyone has any great links on how to do this, probably in software…
    …or standalone firmware-hacked USB input device.

    1. That seems entirely impractical when you have these mouse sensors available. A laser assembly of a CD/DVD drive seems a bit cumbersome and fiddly in comparison, and would require a complex own solution for evaluation whereas a mouse sensor has it all in a simple small and intelligent package.
      Although it’s true that there are people who are hellbent on doing things the hardest way possible.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s