These powerful little motors come standard with the handyboard kit. They plug directly into the board and are controlled by a library prepackaged with IC; commands as simple as "motor(motor_number, power_rating);" and "ao();" control them. When the program calls one of the motor functions, current is feed to the motor to turn it. You can specify power lever and direction. You can also change direction by reversing the polarity of the wires (plugging them in in the opposite direction).
They can be wired without soldiering- use two lengths of the stiff purple wire included with the kit, strip the ends and insert one end into the motor ports on the board and the other into the motor. This is a quick solution. We opted for the more robust and flexible soldered connectors using the colored ribbon wire and connector pins. We made about ten wire pairs as shown on the right. Start with a connector of length 3. Pull out the middle pin (grip the plastic with pliers, grip the pin with needle nose pliers and wiggle the pin to ease it out). Take a two-wire length of ribbon wire, strip the wire and solder a strand to each end(as shown).
As with the purple wire, you can just insert the stripped end of the wire into the copper motor ports. However, we soldered a pin to each end of the wire to make it more robust.
We've found the Lego Mindstorms kit to be a very good way to build the robot. The sizes are uniform, the gears mesh perfectly, the pieces are sturdy, and, with a little rubber cement, they piece bond strongly (but the bonds break before the legos or the more delicate equipment). Interfacing the motors with these precise little parts was a challenge overcome by our resident mechanical wizard, Greg Young. This requires access to a metal lathe, an array of bits and chucks, some precision tools, a drill press, a screw-threader, some small screws and a small Allen wrench. More appropriately, it requires access to Greg and the Smith machine shop. Non-smith people reading this, hopefully, you can improvise and extrapolate upon our idea. I've omitted some specifics because so much depends upon the machines and material you have available. The basic premise: a lego axle with a hole for the motor shaft and a brass collar to prevent the axle from slipping.
Begin with a short length of brass rod (about half the length of the current motor shaft). The rod should be uniform and even. File the edges smooth. With the lathe, drill a hole in the center the diameter of the motor shaft all the way through. Since this piece will rotate, balance and centering are essential (a lathe may be the only way to insure this). Bore a hole of this same diameter into the axle. Into the brass collar, drill a hole the width of the axle half-way in. Take some small screws (ours are tighten with an Allen wrench so they can be inserted all the way.) Drill a hole slightly smaller then the screws into each half of the collar. Thread the holes. Assemble collar, axle and motor. Tighten screws. These will hold the axles in place and rotate them without slipping under all circumstances we've encountered.
We purchased a High Speed BB Micro Servo from acroname.com. According to online documentation, servos will run on the HB's 5 volts. HOWEVER, I found the servo to be too taxing on the boards power supply. When issued a "servo_on();" command, I could feel the motor trying to turn, but the power put out by the board was not enough to drive the gears. Future users will want an additional power source for the servo.
Servos allow a user a high degree of positioning control. The power supply emits a series of pulses that turn the motor. They are can be set to specific angles or can sweep until a condition or a time is met. The user can then get the position from the servo. (Example: an IR sensor can be controlled by a servo. When the sensor detects the flame, the bot can get the angular position from the servo.) This sets them apart from stepper motors. However unlike stepper and DC motors, servo motors cannot rotate a full 360 degrees. (They CAN be hacked up and modified to do so. Or you can purchase them already modified. )
In order to operate a servo, you must first load the servo library routines and include them in the lib_hb.lis file. The lis file names all of the libraries that load up automatically when you run IC. You can find the library routines here (servo.c and servo.icb). Note, I modified these; the original ones were not compiling. Save these files into the /ic/libs directory. Now, you need to include these library routines into your code. I did this by modifying the "lib_hb.lis" file. This file specifies which libraries are automatically included when you run Interactive C. You can find my hacked .lis file here (lib_hb.lis). Overwrite the preexisting lib_hb.lis file in the libs directory. [Also note: this file is not only includes the servo libraries, but it also excludes the libraries for IR communication (between boards). I've saved the unmodified version here(OLD_lib_hb.lis).]
The functions to control the servo are similar to the the DC motors and can be found in the IC documentation.
This library will drive one servo plugged in to the analog port 9. (It is possible to drive 2 at once with some documentation and some special libraries on the official Handy Board page). Notice that the servo connects to a sensor port. It is wired like a sensor: with power, control(signal) and ground wires connecting to appropriate pins. In general, the red wire is usually connected to the power supply, the black wire is usually connected to the ground and the white/yellow wire is usually connected to the controlling signal. Check the documentation of your servo if the wire colors are different.
More servo links:
"the difference between a servo and a DC-motor" (from the Handy Board FAQ)
"the difference between a servo and a stepper motor" (from acroname.com)
(also available: Stepper motors: http://www.cctc.demon.co.uk/stepper.htm)