Servo Motor (Continuous Rotation) + Arduino

From ESE205 Wiki
Jump to: navigation, search

Overview

A servo motor is a rotary actuator that allows for precise control of angular position. It consists of a motor and a sensor for feedback position. A drive is used to collect the feedback from the sensor to precisely control the position of the motor. There are two kinds of servo motor, standard and continuous. The former is a geared down motor that has limited range of rotation. It uses internal electronics to identify the current angle of the motor and Arduino and the servo.h library can be utilizied to turn the motor to a given angle within the range of rotation. Continuous servo motor does not have a limit on its range of motion, so instead of the having the input signal determine which position the servo should rotate to, it relates the input to the rotary speed and direction.

We used a continuous rotation in our project Cheers as we need a high torque motor that can operate at near zero speed without releasing much heat. The motor we chose can be found here. Most servo motors come with a set of accessories.


Figure 1

Arduino

There is a library in Arduino called servo.h that includes some useful function for controlling the servo motor and can support up to 12 motors on most Arduino boards. On board other than the Arduino Mega, using the library disables the PWM functionality on pin 9 and 10 regardless of whether the servo is connected to those pins or not.

One of the most important functions is the servo.write(speed). It sets the speed of the servo with 0 being full-speed in one direction, 180 being full speed in the other direction and 90 being no movement.

Example Code

#include <Servo.h>
Servo myservo;

void setup() {
  myservo.attach(9); //attaches the servo on pin 9 
}

void loop() {
  myservo.write(85); //rotate counterclockwise at slow speed
}


It is suggested that you test the servo to see whether no movement of the servo is 90 or not as it might differ by a little between servo motors. The delay(ms) function might be very useful in which it pauses the program for the amount of time (in ms), but the servo motor will still continue to rotate.

Circuit

There are three typical wires coming out of the servo motor:

  • Black: Ground.
  • Red: Power.
  • Yellow or White: Signal.

Example Circuit

ServoSketch.png

Reference

http://education.rec.ri.cmu.edu/content/electronics/boe/robot_motion/1.html