Handy Board Servo Routines

Run Two Servo Motors at Once!

Routines are now available to drive two simultaneous, independently controlled servo motors from the Handy Board!

The routines generate output signals on Port A bit 7 and Port A bit 5. The former of these is the place that the old servo routine generated its output. The latter is a pin that is open and available on the HB Expansion Bus.

The routines provide a primitive but functional interface for controlling the position of the servo. For each servo, a global variable is set, generating a specific pulse train which acts as a desired position input to the servo. In order to make the servo "sweep," one must write C code to iterate values over the position global.

For maximum flexibility, the routines do not provide a "sanity check" to validate the value of the global being in a usable portion of the servo's range. For a typical servo, valid values range from 400 to 4800 (yielding pulse times of 0.2 to 2.4 milliseconds). Value outside of this range will cause the servo to overtax itself as it tries to reach a position that is not mechanically possible. You may wish to write your own wrapper functions for setting the control globals and rejecting out-of-bounds values.

Electrical

Servo motors require a 5 to 6 volt DC power supply (the red servo wire). This can be taken from the regulated +5v of the Handy Board if the servo's aren't doing too much work. Otherwise, a separate power supply is recommended.

Another alternative is to use the Handy Board's own 9.6v battery with a string of several 1N4001 diodes to drop the voltage down to around 6 volts. The 9.6v output is either of the two left-most pins of the four-pin connector header directly above the BATT/PWR LED's.

The ground for the servo leads (black wire) should connect to the Handy Board's motor ground, not its logic ground. The motor ground is either of the two right-most pins of the four-pin connector header directly above the BATT/PWR LED's.

The servo signal lead (white wire) connects to specific Handy Board digital outputs as described later.

Download

Usage

The two drivers (servo_a7.icb and servo_a5.icb) must be loaded into IC, either at the command line or via a .lis file. The drivers may be loaded individually or together.

Each driver declares a global variable for setting the servo position and an initialization routine for turning the servo on and off.

servo_a7.icb

This driver replaces the servo.* drivers from the standard IC library distribution. Do not load servo.icb and servo_a7.icb at the same time.

The servo control signal is generated on Port A bit 7, which is brought out as digital "input" 9 on the HB connector bank (this input line is converted to an output when driving the servo).

int servo_a7_pulse
Integer global variable determining value of servo control signal. Units are 0.5 microsecond counts; e.g., a value of 3040 yields a pulse length of 1.52 milliseconds, which is just in the middle of a typical servo's range.

The default value of this global is 2560, which is re-established on board reset.

int servo_a7_init(int enable)
Function to enable and disable the servo output. Call with argument equal to one to enable, and zero to disable.

servo_a5.icb

The servo control signal is generated on Port A bit 5 (aka Timer Output 3), which is brought out on the HB expansion bus (labeled "TO3").
int servo_a5_pulse
Integer global variable determining value of servo control signal. Units are 0.5 microsecond counts; e.g., a value of 3040 yields a pulse length of 1.52 milliseconds, which is just in the middle of a typical servo's range.

The default value of this global is 2560, which is re-established on board reset.

int servo_a5_init(int enable)
Function to enable and disable the servo output. Call with argument equal to one to enable, and zero to disable.


Back to Handy Board Home
Fred Martin / MIT Media Laboratory
fredm@media.mit.edu
Last updated: Wed Nov 13 18:27:30 1996