I need to find a cheap optical solution to measure the position of an object in relation to a surface.

The object glides in a linear motion along an axis, around 30mm away from the surface. The maximum distance the object can travel along the surface is about 3m. The accuracy of the system can be +/- 5mm.

What I'm really looking for is a hobbyist-level solution, such as printing a 3m long tape with reference markings to cover the surface, and attaching a laser scanner to the object that can interpret the markings and relay the coordinate to a computer.

I'm happy to create the reference tape myself and program the encoder, though I don't know where to begin looking for the hardware. Any ideas / alternatives?

  • 1
    \$\begingroup\$ Maybe it would help if you have found an "expensive" optical solution that would suit in all you need other than price. Then someone might be able to see how this could be made or found at a cheaper cost. \$\endgroup\$
    – Andy aka
    Sep 19, 2013 at 14:31
  • 1
    \$\begingroup\$ Sounds like a possible job for an optical mouse hack. \$\endgroup\$ Sep 19, 2013 at 18:18
  • 1
    \$\begingroup\$ Check with USdigital.com They have some inexpensive linear encoders. You can purchase both the active elements and the strips that can be purchased separately \$\endgroup\$
    – user29331
    Sep 19, 2013 at 20:49
  • \$\begingroup\$ The usdigital encoders are great, but won't work from 30mm distances \$\endgroup\$ Sep 20, 2013 at 0:51

1 Answer 1


Your asking for an accuracy of 0.16% full scale! This shouldn't be too much trouble, actually, for a long enough QUADRATURE ENCODER strip, but thats a relative encoder (i.e., needs to be zeroed to some point, and then you count how many ticks away from that point you've moved).

Two offset strips of 10mm spaced on-off patterns would certainly do your job. The problem is that you'll be 30mm away from the strip. I think it might take some iterative fooling around w/ optical components, maybe an IR led and matching phototransistor would be able to sense if its pointed at a black section of strip or a white section of strip.

HERE is an IR photoreflector with a 1" (25mm) working distance. It's analog, so you can push the output to a comparator, and dork around to find your light/dark borders. Be sure to add a smidge of hysteresis to your comparator so your transitions are clean. You'll want two sensors, as you'll be dealing w/ two parts of the encoder strip.

The quadrature pattern would look something like this. linear quadrature pattern

For your case, the black bars would be 10mm long (or you can go finer). The width would be a function of the focus of the ir pair. HOPEFULLY that ir pair can give you your resolution, but by all means, read the sheets!

Depending on how fast your sled is moving, a standard microcontroller might be able to keep your count. If its moving very fast, I recommend a microcontroller with a built in peripheral to deal with quadrature encoders, like the PIC 18F4331. If you do that, you won't even need to implement a quadrature encoder counting algorithm, just set up the peripheral and read from the correct register at constant intervals. If you need an algorithm, post the question and I'll work one up.

Since its a RELATIVE encoder, you will need to have some sort of sensor to zero to.

  • \$\begingroup\$ This sounds like the cheapest option. An IR LED and a IR sensor, some slit covers and timing tape. \$\endgroup\$
    – rom
    Sep 19, 2013 at 16:23
  • \$\begingroup\$ and a comparator w/ a tiny bit of hysteresis. \$\endgroup\$ Sep 19, 2013 at 16:23
  • 2
    \$\begingroup\$ Typically this is done with a single-channel strip, and a pair of readers offset by a multiple of 1/4 pitch, typically molded into the same read head. Cheap mylar tape versions were common in inkjet printers, though a coarser resolution made from discrete components might be better if trying to fabricate the scale oneself. \$\endgroup\$ Sep 19, 2013 at 22:18
  • \$\begingroup\$ Thanks @ChrisStratton! I was trying to remember that. Knew I was missing something. \$\endgroup\$ Sep 19, 2013 at 22:24
  • \$\begingroup\$ I was going to say "look at what they do in printers" too, an optical reference can be stuck, painted, hung, etc. from various bits of the machine. An extra optical sensor or limit switch can tell you when you're at zero. \$\endgroup\$
    – John U
    Sep 20, 2013 at 9:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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