Servo Actuator
The servo actuator is a standard part used in radio-controlled
model cars, aircraft, etc. We have modified it to make it
compatible with the Lego parts used in your robot, as shown below.
The rotating output shaft has a gear wheel, which can
mesh with other Lego gears. Alternatively, you can fit an axle to
the gear wheel and drive something with that. The mounting pins on
both sides of the servo body allow it to be installed with the
output shaft vertical or horizontal, to suit different
applications.
With the Lego motors, you can control the speed and direction of rotation.
With the servo actuator, you can control the position, or angle, of the output shaft.
The shaft can only rotate
through about 200°, but you can control its angle very
precisely.
The servo moves relatively slowly - it takes about 1
second to turn through its full range of movement. However, the torque available
is relatively high, at about 0.3Nm. This means, for example, that
it could lift a mass of 300g at the end of a 10cm arm. Using this
much torque is probably not practical - it would require very strong
arm construction and connection to the servo, and very strong
mounting of the servo on the robot.
Connecting to the Handy-Board
The Handy-Board expansion board (upper board) has connectors for 6
servo actuators, numbered 0 to 5, just below the left edge of the
display. You should use the servo 0 pins, as shown in the
picture below.

Warning: The servo
cable must be connected correctly - black wire on the left, white
wire on the right, as shown. We have glued a red plate on one
side of the connector to help you to get it right, but you can still
destroy your servo actuator if you are not careful.
Always switch off the Handyboard before connecting the servo
actuator, and double-check that it is connected correctly before
switching on again.
Using the Servo
To enable and disable servos, use the
init_expbd_servos() function:
init_expbd_servos(1) enables all servos
init_expbd_servos(0) disables all servos
When the Handy-Board is switched on, servos are disabled. You must
enable them before you use them. Enabling servos places a small
extra load on the Handy-Board processor - probably not noticeable
unless you are trying to do some hard calculations in a hurry!
To control the position of a servo, assign a value to the
global variable servo0.
Valid values are in the range from a few hundred to a few thousand
- the exact limits will depend on your particular servo actuator.
It is important not to assign a value which tries to push the servo
actuator beyond its range of movement - it may damage itself trying
to do the impossible! Values in the range 600 to 4000 should be
safe. The sample program below will allow you to find the limits of
movement of your servo.
Connect your servo to connector 0. Pressing
the STOP button will increase the value assigned to servo0
in
steps of 20. Pressing the START button will reduce the value.
Note the values corresponding to the limits of movement of your servo.
void main()
{
init_expbd_servos(1);
//enable servos
servo0 = 1500;
//set servo 0 to a safe position
printf("Servo at %d\n", servo0);
while(1)
{
if(start_button())
{
servo0 = servo0 - 20;
//decrease servo value
}
if(stop_button())
{
servo0 = servo0 + 20;
//increase servo value
}
printf("Servo at %d\n",servo0);
sleep(0.1);
} // end
of while - repeat forever
}
|