Login - Register -

Building a Robot

Servo Motors

Sensor mount

  1. two pieces surround the servo, close with supplied screws
  2. screw servo horn to base piece
  3. screw servo horn to servo

Assembly

  1. Locate the smaller rectangle plate
  2. bolt the sensor base to the plate using the M2 screws and nuts
  3. Bolt 4x M3 5mm nylon standoffs to the chassis plate using nuts
  4. Screw the base of the sensor mounting to the plate using
  5. Screw the plate to the standoffs using 4x M3 4mm pan head screws
  6. Plug the servo into 'Servo 1' pins of motor controller

Theory

A servo is a combination of a dc motor and a position sensor, usually a potentiometer. The movement of the motor is constrained so that the output arm can only turn through a 180 degree arc. The servo takes a constant dc power supply and a PWM signal. The ratio of high to low in the PWM signal tells it what angle is required on the output. The control system within the servo takes care of monitoring and adjusting the motor to maintain this position.

These devices are used heavily in radio control (rc) models, for steering, moving throttles, adjusting flaps and ailerons etc.

Wiring

The three pins of the servo connector should plug directly into one of the two 'servo' connectors on the motor control board. With the wires from the servo being red (5v), brown/black (gnd), and orange (signal).

On our control board the two servo control pins correspond to Arduino pins D9 and D10

Arduino reference docs for the Servo Library

Usage

We will use the servo to rotate the direction that the Ultrasonic Sensor points in, enabling the robot to look from side to side for obstructions.

Test the servo is wired correctly using Examples -> Servo -> Sweep

This example should move the servo arm through its full sweep.

Next try an interactive example:

 #include <Servo.h>

 Servo myservo; 
 void setup() {
   myservo.attach(9);
   Serial.begin(9600);
 }

 void loop() {
   if (Serial.available()) {
     int angle = Serial.parseInt();

     if (angle < 0) angle=0;
     if (angle > 180) angle=180;

     myservo.write(angle);
   } 
   delay(500);
 }
- Last change March 30, 2016, at 07:46 PM
- Registered in England and Wales 08777436