Rotary Encoders for your Bots

Rotary Encoders for your Bots

All your bots are belong to rotary motion. How to sense this? Rotary encoders. There’s a very good article over at DigiKey right now on rotary encoders. Of course they’re trying to sell encoders to engineers to solve customer problems, and here we’re talking hacking and making, so I’ll throw out some ideas of how to implement encoders on the cheap.

What are rotary encoders? Rotary encoders are electromechanical devices that give an indication of rotary motion or position. You could RTFA, but I’ll repeat some of the basics here. If you are a “lumper”, there are two basic kinds: absolute encoders, and incremental encoders.

Absolute encoders use some method to tell you where the shaft is located. Some are optical encoders, that use a transparent disc with grey code (and you thought that was something you only learned in intro to digital systems) printed on it and optical systems to output a binary value that indicates the angular position of the shaft. Wow. What? So if you have something with an articulating joint, and you want to know exactly where the joint is, this is what you use. 501 connection: did you know that the absolute optical shaft encoders used on the space shuttle robotic arm as well as the robotic arms on the international space station were made in Maumelle, Arkansas? Yup. Also encoders in tanks, mars probes, and stuff nopony is supposed to know about. Shhh! Don’t tell, or the bad guys might figure out we have satellites. In space. That can take pictures of, get this, the earth! Amazing, but true.

Another method of absolute encoding of shaft position is to do pot. There are special 360 degree rotation potentiometers that are made for position sensing. Basically you get a voltage out that indicates position. Feed that in to an a/d convertor on your microcontroller, or Arduino, if you must, and viola, you know where the shaft is located in its rotation.

Incremental encoders give you an indication that the shaft is rotating, but you don’t know where. Just that it’s turning. You can figure out how much and how fast, just not where. Well, unless you use a switch to indicate “home” and you know how far you’ve turned from home. Again, RTFA for some cool info on quadrature encoding and such. And again, DigiKey is trying to sell you stuff (and they do have some cool stuff!) but what if you are building a bot on the cheap?

You haxor, you have tons of incremental encoders in your junk drawer. Mouses. <deadmouse>. No, not that one, the old dead ones that used the ball. Take it apart. You’ll see two wheels with slots cut in them. These wheels will be mounted so they turn through a slot in a four leaded device. That’s the optical part — it’s an infrared LED and a phototransistor or photodiode all in one. Some use a separate LED and detector pair. There you go, a dirt cheap optical encoder that you can hack in to your bot. Actually two of ’em per <deadmouse>. While not “rotary” encoders, in some printers you can find a similar system to encode linear position…but that’s for another day.

What if you want an absolute encoder? I’ve seen folks homebrew their own. Start with a shot of Vodka, print out a circular grey code pattern, and go to town with LEDs and photodetctors. Want really good stuff on the cheap? How about searching e-bay for “BEI encoder”?

The first device I ever programmed, way back in prehistory, was a “BigTrak“. It used a simple encoder made of an IR LED, a photodetctor, and holes in a gear in the gearbox. The on board microcontroller counted pulses to determine how far the BigTrak traveled, or at least how many times the wheels spun. No, I didn’t write code for the BigTrak, I mean when I was like 9 it was the first thing I ever wrote a program on.

So there you go, info you can actually use, here at Have fun hacking!

« | »


  1. mulberry bags asshat spammer

    Excellent beat ! I wish to apprentice even as you amend your site, how could i subscribe for a weblog web site? The account helped me a acceptable deal. I were tiny bit familiar of this your broadcast offered shiny clear concept

Leave a Reply