Robotic Arm Position Control

R/C servo motors are closed-loop systems, and they are inherently useful in arm systems where precise position control of the joints is necessary. But what about when using other types of motors, including DC gear motors and stepper motors? What problems do these open-loop systems cause?

At the very least, you should supplement any open-loop servo system with limit switches. These switches provide an indication when the arm joints have moved to their extreme positions. These can be simple momentary push-button or leaf switches.

You can also construct optical switches using photointerrupters. A small patch of plastic or metal interrupts the flow of light between an LED and a phototransistor, thus signaling the limit of movement. You can build these interrupters by mounting an infrared LED and phototransistor on a small perforated board. Chapter 43, “Proximity and Distance Sensing,” discusses the concepts of using infrared light to detect objects.

Best yet is to provide some type of feedback to report the position of the arm. Otherwise, the control electronics will never know where the arm is or how far it has moved. There are several ways you can provide this feedback. The most popular methods are (in order of difficulty and expense) a potentiometer, an incremental shaft encoder, and an absolute shaft encoder.

Using a Potentiometer

A straightforward method of providing position feedback is to attach the shaft of a potentiometer to the shoulder or elbow joint or motor. As the joint turns, it moves the pot, which in turn changes its resistance. This resistance change indicates the precise position of the joint.

Just about any potentiometer will do, as long as it has a travel rotation the same as or greater than the travel rotation of the joints in the arm. Otherwise, the arm will go past the internal stops of the potentiometer, and the pot will be damaged. Travel rotation is usually not a problem in most arm systems, where joints seldom move more than 40° or 50°. If your arm design moves more than about 270°, use a multiturn pot. A three-turn pot should suffice.

Rotary potentiometers are the most common type, but another style is the slide pot. You operate a slider pot by moving the wiper up and down, rather than by turning a shaft. Slide pots are ideal when you want to measure linear distance, such as the amount of travel (distance) of a chain or belt.

Selecting the Potentiometer Value and Type

The exact value of the potentiometer is not important, but it should be in the 50 kΩ to 250 kΩ range, just for ease in interfacing with your electronics. Be sure the pot is linear taper, and not audio taper. The difference has to do with the resistance scale of the pot.

Connection to Electronics

The potentiometer may provide a relative measurement of the position of the arm, but the information is in analog form, as a resistance or voltage, neither of which can be directly interpreted by a computer. The most common—and generally most useful—way to connect the pot to a control circuit is to use the component as a voltage divider. As the pot turns (or slides), its output is a continuously variable voltage from 0 to the positive supply voltage (usually 5 volts).

The wiper of the pot is connected to the input of an analog-to-digital converter (ADC), which translates voltage levels into bytes. Many modern microcontrollers have built-in ADCs, saving you the trouble of wiring up a separate analog-to-digital converter chip.

Using an Incremental Encoder

An incremental encoder is an optical or mechanical device that counts pulses generated by a disc as it turns. They are frequently used with the drive motors on robots to determine distance of travel.

They’re often called shaft encoders because they’re typically connected to the shaft of the motor they are measuring, though in actual practice the encoder may be coupled with the motor in any number of ways. And they’re known as incremental encoders because they record movement incrementally—one step, click, or pulse at a time. (They’re like a walking pedometer, where every time you take a step it increments a counter.) Figure 1 shows an example incremental encoder disc (also called a codewheel).

[Figure 1]

These kinds of encoders are covered in more detail in Chapter 45, “Navigating Your Robot,” specifically for the task of measuring travel distance and position.

Incremental encoders can be used to measure all kinds of motion, including the rotary or linear motion of arm movement. Internally, the encoder counts the number of pulses; by knowing how many pulses occur in one revolution, you can calculate how far the encoder has turned.

Say, for example, the encoder produces 360 pulses per revolution (for low-cost encoders it’s usually much less than this, but 360 makes the math easier). This equates to one degree of rotation per pulse.

If your control circuit counts 35 pulses, you know the joint has rotated 35°. If your circuit counts 120 pulses, then the joint has moved 120°. Capturing these pulses can be done using a microcontroller like the Arduino, which has an input pin directly connected to a hardware counter.

Using an Absolute Encoder

An incremental encoder simply informs you when there’s motion, and how much, but doesn’t really tell you exact position. You have to infer that through calculation. At the least, every time you power up your robot arm you need to have all the joints return to a “home” or neutral position. From there, you can begin counting pulses and calculating position based on the number of pulses.

An absolute encoder tells you absolutely where something is. Rather than just provide pulses or clicks, an absolute encoder provides a binary output whose number indicates position. An 8-bit absolute encoder provides 256 positions, usually enough for the average homebrew robot arm.

Figure 2 shows a 3-bit encoder disc using a form of binary counting known as Gray code. With three bits, the encoder has a resolution of just seven positions; it’s shown here for the sake of simplicity. In traditional absolute encoder disc designs, bits are added with more tracks. Each track requires its own sensor.

[Figure 2]

While you can make an absolute encoder, the sensing electronics are tricky. You’re best off purchasing one ready-made. Price depends on the technology used in the encoder. There are three basic kinds, in descending order of cost: