Last chance to enter The Hackaday Prize.

Linear optical encoder

dsc03989

Optical encoders are nothing new; they can be found in everything from mice to printers. They’re great for allowing DC motors to know their exact position and even current direction. If this is sounding like old hat, it’s because we’ve shown you rotational versions before.

[Chris] uses the same concept, but produced a linear optical encoder instead of rotational. His setup is much like whats used in non stepper-motor CNC and RepRap mills, allowing ordinary DC motors to know their position within a plane. It’s a quick tutorial, but we liked the detail and it reminded us we need to finish that DC motor based mill thats still a pile of parts in the closet. Check out a video of [Chris'] in action after the break.

Comments

  1. Fallen says:

    That encoder looks ghetto…but if it gets the job done that’s what matters.

  2. Shiftall says:

    It must be possible to do this with a measuring tape for greater accuracy.

  3. Karl says:

    Anyone who wants to do this should look at the guts of almost any inkjet printer – the fine mylar band is one of these encoder strips.

  4. urlax says:

    It’s a great hack, just to build something on top of this!

    i wonder if he could achieve greater accuracy. as he is using PWM, i think he could. those mylar strips Karl mentioned are insanely dense, he would need an prebuilt encoder, something like this:
    http://farm1.static.flickr.com/1/129350625_7ce76adffb.jpg
    and of course a translucent tape.

    Keep up the good hacks!

  5. OldVamp says:

    I have seen linear encoders quite a bit in printers that I have torn apart. They have a nice little clear plastic strip with lines on it a ‘pixel’ apart.

  6. Sheldon says:

    Something that they’ll have to be careful of (with only one sensor) is location accuracy.

    Having more lines closer together will increase it, to an extent, but by increasing resolution.
    Imagine the above system with very thin white stripes, same resolution but higher accuracy on hitting the same place irrespective of the approach direction.

    Another way (in the absence of being able to make infinitely fine white stripes) is by off-setting another (identical) sensor (it doesn’t even need to be very close to the original one, it can be n-stripes plus the fraction away, it’ll only limit the ultimate travel). When the combination of the two sensors says “white stripe” then you know your location is within a stripe and not just over the end (as the other sensor would report “black stripe”).
    One could use the analogue nature of the sensor to see if you are only slightly over into white from black but this assumes consistent behaviour on every white/black boundary and all operating environments.

    Sorry, I went on a bit (I’m wasted on my day job when I could be hacking away on real electronics)

  7. Oddler says:

    I’ve been toying with the idea of building a huge 2*2 metre x–y plotter, and a linear optical encoder would be perfect for this. But how can I get my hands on a 2 metre long transparent plastic strip with tiny lines? Any thoughts would be very welcome.

  8. mungewell says:

    Linear encoders have been around for a while, normally glass ones are used for real precision. You should encode two ‘lines’ with ‘grey code’ so that you can detect record changes in direction.

    Mungewell.

  9. urlax says:

    @Oddler

    Inktjet printer + overhead plastic? (not the sheets, a roll)

    most old inkjets can print on this stuff, and are able to process rolls as if it were chain-fed paper (or how do you call that old paper with holes on both sides)

  10. Oddler says:

    @urlax

    That is actually a very good idea. At first I thought about ordering some custom made tape, but that is just way to expensive. Thanks a lot for the input :)

  11. Jim says:

    I have often pondered the problem of linear position measurement. I thought the best way might be to use some resistance wire and a wiper on the carriage. With using a straight length of resistance wire the impedance for a short run might be very low and so the voltage supplied across it would have to be low (so as not to melt it). It would be very cheap and absolute though, the positioning accuracy would be limited to the resolustion of your ADC.

  12. rasz says:

    @Jim
    and temperature
    and humidity
    and dirt

  13. Jim says:

    I thought as long as the temperature of the wire was the same for the full length then it wouldnt matter because it was wired as a voltage divider.
    Just a thought.

  14. macpod says:

    The positioning setup is making me think of crystal radio tuners, hmm.

  15. mac says:

    @urlax and @Oddler

    So something interesting: So the smallest pixel you can print is 1/2 the width of the lines on your encoder strip (e.g. if you had a 10 line/inch strip you could print a 20 line/inch strip). So in theory you could start with something low resolution, and make progressively higher resolution strips until you reached the limits of your printer and encoder head.

  16. reboots says:

    While you’re salvaging the mylar codewheels and codestrips from HP inkjet printers, don’t forget to snag the optical sensors too. They’re dead simple to interface, with 4 pins for +5V, ground, and two-channel quadrature TTL output–and you’ll have a difficult time reading the encoders without them. Here’s the datasheet for the common HEDS-9700 series:

    http://www.datasheetcatalog.com/datasheets_pdf/H/E/D/S/HEDS-9700.shtml

    Bear in mind that a lot of DeskJet problems result from a dirty encoder strip. These may not be appropriate for dusty home CNC environments.

  17. robomonkey says:

    you could reuse the encoder strips even in a dusty environment as long as you protect the area that will determine your location with an enclosure and weatherstripping.

    I like this idea, but I’ve used precision encoders on satellite dishes (like 32K steps) and have not had failures for positioning that wasn’t due to outside influence. I’d like to take a optical encoder and have a precision encoder as a secondary on an XY table. Write the code to take slight variance into account an viola, XY with double checking.

  18. Edward says:

    Otis uses something like this on some of their elevators except using a bar code scanner and bar codes on stickers covering the entire height of the elevator shaft.

  19. tyco says:

    @Jim:

    “I thought the best way might be to use some resistance wire and a wiper on the carriage… It would be very cheap and absolute though”

    This is very similar to what was done back in the 60s and 70s for electronic console organs (and probably portable ones too). There was a long bus bar (with some voltage across it) that ran the length of the console, and each key was connected to a stiff wire that touched the bus bar, providing a voltage for a VCO. Tuning was accomplished by bending the wires.

  20. tantris says:

    how does a printer encoder compare to the optics chip from a mouse?

  21. simpleplan says:

    If you use two strips with N and N-1 divisions respectively, you also get an absolute position measurement. This is a kind of optical hetrodyne encoder.

  22. urlax says:

    @Jim

    you can better use resistive wire isolated with enamel and wind it on a wooden rod. or a pvc one. that way, your resistance will be much higher, reducing the error. (the wiper will oxydate, introducing uncertainty.)

    for instance, if you want to measure an axis of Oddlers device, you’d use 2 meters of wire. (1mm² nichrome would have an resistance of 2,1 Ohm.)

    if you wound the wire around an bar with an circumference of 1cm, you would need 2000 turns, using 20 meters of wire. the resistance would become 21 Ohms, which requires less current, and gives a better resolution.

    it would look like this, but longer:
    http://www.zsa-one.com/Upfiles/Prod_X/2007122474655.jpg

  23. reboots says:

    @tantris

    At 120-150 lines per inch, much lower resolution than even the cheapest optical mouse. But, assuming clean optics, they yield very precise measurement. Optical mice have relatively poor accuracy: losing track of their position, skipping pixels, etc. Great for rough motion tracking, terrible for quantifying it.

  24. jkopel says:

    I got this same sort of thing running using the mylar strip and encoder that comes with the ink jet. Simple PID control on an arduino give surprizingly accurate positioning! http://abigmagnet.blogspot.com/search/label/motor%20control

  25. hrpuffnstuff says:

    I remember pulling the encoders out on the XY table of an ESI Model 44 laser trimmer only to find the lines rubbed off from misalignment. So thats why the table kept slamming into the stops.

  26. Mac says:

    Why not dispel with the encoder strip altogether and use an optical mouse encoder instead. You’ll get both X and Y position encoding down to fractions of a millimeter with a single sensor. A laser mouse encoder should do even better. The surface the encoder works against can be any surface usually encountered on a desktop (even a plain sheet of white paper). The two links below should prove helpful for the interested. Cheers.

    http://home.roadrunner.com/~maccody/robotics/mouse_hack/mouse_hack.html

    http://home.roadrunner.com/~maccody/robotics/croms-1/croms-1.html

  27. Howie says:

    @Jim: Once upon a time I had an ‘analog mouse’ that worked this way. It plugged into the analog ins on a commodore 64 and pretended to be two paddle controllers. Worked well enough for the limited resolution on that computer. Where there would normally be an encoder disk on optical mice, there was a carbon track like the inside of a potentiometer.

  28. Jim says:

    Or how about using an old electric guitar!
    Mount the pickup and a slider on the carriage, tension the string along the direction of travel. Electronically ‘pluck’ the string with a solenoid or by using electromagnets. Frequency would be proportional to position, absolute position, dirt wouldnt be a problem, neither would humidity.
    For temperature you could actuate the slider and every once in a while vibrate it open to calibrate.
    Get a few stepper drives in and it should sound great.

  29. Roly says:

    Goal: “a way to know where the ‘stage’ is”

    @Sheldon
    Has fingered a potential problem.

    See, you don’t actually know where the stage is because this isn’t actually an “encoder”. It’s more like a rotopulser. Anyone with experience of a CP-80 type printer (or maybe FDD’s) will have seen a jammed carrage vibrating in place while the driving processor is blissfully unaware that the carrage is nowhere near where it thinks (until maybe it returns to zero prematurely and causes an error).

    @mungewell
    said the magic word “Gray code”.

    One way to know exactly where the carrage is at all times is to fully encode the traverse with as many bits of Grey code as required.

    @Jim
    just reinvented slide-wire feedback, used in early plotters.

    @simpleplan
    now THAT I really like. Hat tip.

    Which reminds me of a metrology setup that used a fine inter-digital ladder and a matching short reader strip. In the macro this would count off the phase reversals for each ladder step (~1mm) but for the fine did a phase resolution between the ladder steps to better than 1 thou overall (retrofit gear for old mills, lathes, &c; Nixie readouts, all TTL btw).

    I’d suggest the world of PCB photography would be a good starting point for large, very fine and regular structures.

    @urlax
    Slidewires worked, honestly. And they were far from the most troublesome part of the recorder. Wound slides were also used, but for home construction the evenness of the winding would be critical for positioning, and the wire thickness would limit fine resolution.

    @reboots
    Yer. But say we combine mouse opticals with a fine printed Grey code strip, then read the mouse video directly, and in software interpolate based on the position of the code in the scan. Give all that processing power something useful to do for once. :)

    @Jim
    “Twang-wire” rebalance? That has to be either brilliant or crazy. You might consider what happens if you measure the twang frequency on *both* sides of the head.

  30. mungewell says:

    @roly
    or use a long line of 2D barcodes encoding positional steps. Use the contents of barcode for rough position and location of barcode for find position.

  31. tantris says:

    @reboots
    but what if one would run the mouse on an optimal mousing surface (like an encoder strip)?
    or one could use the encoder only. some mice have the optical reader separate from the chip, that does the “micing”stuff. one can read image data directly from the chip. of course, calibration would have to be done in software, but one would also get feedback on possible errors.

    some older link to someone using the mouse as a scanner (he however relies on the mouse telling him positions): http://hackaday.com/2006/01/07/optical-mouse-based-scanner/
    (link to original is broken, but project is still here: http://spritesmods.com/?art=mouseeye )

  32. andrew says:

    if you look up moire fringes if you need more accuracy. tanks now use them to blow really far away stuff up!

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

Follow

Get every new post delivered to your Inbox.

Join 91,149 other followers