Skip to content

How to make a low-cost absolute position encoder

October 18, 2012

I love servos (especially the modern smart kind).  They wrap up a motor, a gearbox, a motor controller, a position encoder, and a microcontroller into one neat little package that you just drop into your project and use.  But what if, for one reason or another, you can’t use an off-the-shelf servo, but you still need to know how some joint or wheel in your robot is rotated?

There are lots of fairly low-cost quadrature encoders, that send a series of positions when a sensor disc is rotated.  This tells you when the thing is moving, but not where it actually is — for that, you need some sort of “homing” switch at one extreme of the motion, and you have to hit that on start-up, and then count rotation pulses from there.  Maybe this is OK for something like a CNC machine, but it’s not likely to work well for, say, a humanoid robot.

What you really want is an absolute position encoder.  This is a sensor that tells you exactly what position your disc (or linear mechanism) is in, right now, even when you’ve just powered it up.  Unfortunately, these are neither common nor cheap.  Industrial models tend to cost upwards of $200.  On the low end, pickings are slim; but one could try this through-shaft potentiometer, or this Hall Effect encoder.  Each has its pros and cons.

But here’s another approach: make your own encoder, using a couple of cheap analog IR sensors, and a simple grayscale disc or ring.  The gradient on the disc encodes the sine and cosine of the angle, and your two sensors are positioned 90 degrees apart.  This gives you everything you need to determine the absolute angle.

Ichiro Maruta, an engineer in Kyoto, prototyped this exact setup.  (See his blog post (Japanese), or translated.)  He also tried a variation with a black & white disc, where the border between the two moves back and forth in front of the sensors in sinusoidal fashion.  Personally, I prefer the idea of the grayscale disc, because I think it will be less sensitive to positioning errors with the sensors.

Maruta-san’s video showed only the black & white disc, so I asked him whether he ever tried the grayscale disc.  He reported that it did, and it worked well.  And note that a very similar set-up would work for a linear position sensor; in fact in that case, you could get by with just one IR sensor instead of two.

I think this is a great technique that deserves more attention.  Next time you need something like a servo, but no off-the-shelf servo will do, try making your own with this low-cost absolute position encoder!

From → Opinion, Tips

Leave a Comment

Leave a Reply

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

You are commenting using your 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 )

Connecting to %s

%d bloggers like this: