next up previous contents
Next: void servo_on() Up: 9.1 Output Control Previous: void motor(int m

9.1.2 Servo Motor

A library routine allows control of a single servo motor, using digital input 9, which is actually the 6811's Port A bit 7 (PA7), a bidirectional control pin. Loading the servo library files causes this pin to be employed as a digital output suitable for driving the control wire of the servo motor.

The servo motor has a three-wire connection: power, ground, and control. These wires are often color-coded red, black, and white, respectively. The control wire is connected to PA7; the ground wire, to board ground; the power wire, to a +5 volt source. The Handy Board's regulated +5v supply may be used, though this is not an ideal solution because it will tax the regulator. A better solution is a separate battery with a common ground to the Handy Board or a tap at the +6v position of the Handy Board's battery back.

The position of the servo motor shaft is controlled by a rectangular waveform that is generated on the PA7 pin. The duration of the positive pulse of the waveform determines the position of the shaft. This pulse repeats every 20 milliseconds.

The length of the pulse is set by the library function

servo, or by functions calibrated to set the position of the servo by angle.

Fred G. Martin
Fri Mar 29 17:44:15 EST 1996