Servos

From RoboWiki
Jump to: navigation, search
A sample servo device.

Servos are a specialized type of motor. Normal DC motors, such as those in an electric drill or remote controlled car, will rotate continuously (forever). Varying the applied voltage to a DC motor will vary the speed of the motor. Standard servos are different in two ways:

  • Standard servos do not rotate continuously. They have a limited range of motion, typically from 180 to 270 degrees depending on the servo. Special servos, or hacked servos, do have the ability to rotate continuously.
  • Servos need to be told which position to go to: this is accomplished with a special type of PWM (Pulse Width Modulated) signal. Once they reach the desired position, they will stay there and resist any forces that try to rotate them out of position.

Jual locker - Toko bunga jakarta - Sewa mobil jakarta

Contents

Anatomy of a Servo

Servos have a small DC motor inside, attached to a potentiometer that monitors the servo's current position. They also have a small control board inside, that reads the PWM signal being sent to it, and applies voltage to the motor. As the motor rotates, the reading from the potentiometer changes, until it matches the desired position being sent over PWM. Once the servo reaches the desired position, the motor will stop. Any attempt to move the servo will change the potentiometer's reading, and the board will again apply voltage to the motor to attempt to return the servo to the desired position. This happens very quickly however, which is why it seems like a servo is "stuck" in it's current position when one tries to move it.

Almost all servos have a set of 3 wires coming out of them. Although the colors may differ between manufacturers, the functions of each wire are usually the same:

  • Ground: Black, Brown
  • Power: Red
  • PWM Signal: White, Yellow, Orange

Most servos operate between 4.8 and 6 volts DC. Be sure to check the specifications of your particular servo so you do not overload it.

PWM Signal

A pulse width modulated signal is the standard way to control a servo position. The signal pulse is typically between .5 and 1.5 milliseconds. The length of this pulse corresponds to the desired servo position. For a servo that rotates 180 degrees, .5ms corresponds to 0 degrees, 1.0ms corresponds to 90 degrees (middle), and 1.5ms corresponds to 180 degrees. These pulse times may vary slightly between different brands and models of servo.

This pulse must be repeated every 20 milliseconds to maintain the servo's position.

Servo Controllers

In the club, we typically use Microcontrollers to provide the necessary PWM pulses to control a servo. However, not all microcontrollers are up to this task, especially the simpler ones. Since the microcontroller must provide a pulse every 20 milliseconds to control a servo, it leaves little time for the microcontroller to do other tasks. Some of the microcontrollers do have special timers that run alongside the main process, but they are usually limited to controlling 2-4 servos at most. A more reliable and scalable solution is to use a dedicated Servo Controller board.

Dedicated servo controller boards generally accept input signals from a microcontroller or some other source, and provide the necessary pulses to keep the servo in a desired position. Offloading this task to a specialized board allows the microcontroller to do other things like read sensors and make decisions. Many servo controllers work over Serial, where the contoller will receive serial characters that correspond to the desired servo position.

Another less obvious example of a servo controller is the radio receiver in a remote controlled car. The receiver generates a pulse based on the position of the joysticks on the radio transmitter. Any variation in the position of the joystick will directly correspond to a rotation in the servo, allowing for precise and accurate position control.

The Robot Locomotion article goes into the depth of on-board or dedicated hardware solutions.

Servos in the Arduino

There are several libraries available to use servos with the Arduino microcontroller. However, the recommended library is ServoTimer1. To add the library, unzip the file to /hardware/libraries/ . It appears that this library is only functional in the Arduino 0011 software. Do not use the 0012 version.

"As of Arduino 0017, the Servo library supports up to 12 motors on most Arduino boards and 48 on the Arduino Mega. On boards other than the Mega, use of the library disables analogWrite() (PWM) functionality on pins 9 and 10, whether or not there is a Servo on those pins. On the Mega, up to 12 servos can be used without interfering with PWM functionality; use of 12 to 23 motors will disable PWM on pins 11 and 12."[1]

Finding the stalling position

It is sometimes hard to find the center, or stalling, positions of continuous servos. The following code will print, to the Arduino IDE terminal, the value that is sent to the servo. Keep running this code until the servo stops, then save that value and treat it as the center position of your servo.

// Includes
#include <Servo.h>
 
// Define global constants
#define lServoPin 9   // Left motor pin; This is a special PWN pin
 
// Define global servos
Servo LeftServo;
 
// Initialization function
void setup()
{
  // Initialize server connections
  LeftServo.attach(lServoPin);
 
  // Initialize serial communications
  Serial.begin(9600);
}
 
// Main loop
void loop()
{
  // Set both servo at same speeds (Go straight)
  for(int i = 0; i <= 180; i++)
  {
    LeftServo.write(i);
    Serial.print("Value: ");
    Serial.print(i, DEC);
    Serial.print("\n");
    delay(500);
  }
}

Advantages and uses

Because the servo is designed to go to one place and stay there, it finds use in applications where pointing things certain ways is important. For example, mounting a camera to the top of a servo will allow you to control exactly where the camera is pointing at all times. If the camera is on a robot, this allows you to move the camera around without moving the robot.

Another common use of the servo is in steering in remote controlled cars. The position control capabilities allow you to point the wheels in exactly the direction you want.


Cite error: <ref> tags exist, but no <references/> tag was found
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox