Since the early 1990’s the servo motor has been finding its way into robotics projects more and more often.
But what is a servo motor?
How do servo motors work?
This introductory tutorial on servo motors will answer these questions.
If you’re into electronics, you may have heard the word servo or servo motor thrown around.
If you’re a robot builder or into model planes, boats, and cars, there’s a chance you know something about servo motors.
The benefits of using servos for robotics and other things are many. They’re small, light, relatively cheap, and easy to use. And most of them sport a design that makes mounting a snap.
Let’s dive into some detail on how servo motors work.
What is a Servo Motor and How Do They Work?
What is a Servo Motor?
First, let’s get some nomenclature out of the way: what does the word servo mean to begin with?
Servo is short for servomechanism, so you can say that a servo motor is actually a servomechanism motor.
A servomechanism is a special type of automatic control system which controls the motion or position of an object.
Servomechanisms have four important characteristics:
- an input command
- power amplification
- an output that turns or positions an object
The device controlled could be the rudder of a cruise ship, a missile, or your robot.
How Servo Motors Work
So, now we have a basic idea of what the word servo means.
The thing is, most of us won’t be building missiles (hopefully) and large boats. However, some of us will build robots.
Because of this — though there are different types of servomechanisms or servos — we’re going to focus on the type that electronics and robot enthusiasts will be using.
These are the hobby or R/C servos. Figure 1 depicts a variety of R/C servos.
Figure 1: various hobby or R/C servo motors.
Servo Motor vs Continuous DC Motor
A servo motor is a special subset of a continuous DC motor.
But hobby servos come in a neat rectangular box with other goodies inside while a DC motor is just, well, a DC motor.
A typical DC motor has two leads and if we apply power the motor will simply spin in one direction. If we want to reverse the motor, we need to swap the two leads. If we need to see how far the shaft has turned or how many rotations the motor’s shaft has completed, we’ll need to find some way to measure that.
A servo motor, however, has three leads. One is for power, the other for ground, and the third is a control lead. Since a servo is a closed feedback system (unlike the regular DC motor which is open loop), the control lead is needed to sense the position of the servo’s shaft and adjust it if necessary. We’ll see how this works in a minute.
How a Servo Motor Works – the Guts
Inside a typical R/C servo dwells the DC motor from the previous section plus some other components. Not all servos are exactly the same, but they all have at least three main parts:
- A DC motor
- Reduction gears
- Control circuitry
Feast your eyes upon figure 2. Here, we can see the inside of a typical servo.
Figure 2: the guts of a typical hobby servo motor.
Let’s discuss the three main parts in more detail.
This is simply a DC motor that can change directions. It’s the silver thing in figure 2. Not much more to say.
The gears reduce the high speed of the DC motor to something usable for fine control. We’ll talk more about the materials used to make the gears a bit later. Because of the gears, many revolutions of the motor equal one revolution of the servo’s shaft. The black thing with holes in it on the outside of the case is the servo’s horn. Horns are used to connect rods and other things to the servo. They come in many different shapes and sizes.
The output gear of the servo connects to a potentiometer (the brown object in figure 2), which is a variable resistor. The pot’s position indicates the position of the servo motor’s shaft. There is also a small board with some circuitry on it that reads the potentiometer and controls the servo. We’ll talk more about the circuit in a bit.
Figure 3 boasts a schematic representation (sort of) of the inside of a typical servo.
Figure 3: diagram of the inner workings of a servo. The electronics is the control board from figure 2 and the spline on the outside of the case is what the horns attach to.
How to Control a Servo Motor
You can’t just connect a battery to an R/C servo motor and watch it go. This is because servos need special control signals to operate correctly. The good thing is there are plenty of ways to easily do this with microcontrollers, boards like Arduino, or even simple electronic circuits.
Servos are usually powered by 4.8 to 7.2 V, though 4.8 to 6 V is more common.
Let’s talk about the connector for a minute.
Luckily, there are standards which govern the design of servos and the connector is one of the parts subject to the standards.
Servo Connector Types
Servo motors sport three primary connector types. They are:
- “J” (a.k.a. Futuba style)
- “S” (a.k.a. Hitec/JR style)
- “A” (a.k.a. Airtronics style)
Figure 4 shows the different styles and maps the wire’s color to its function.
Figure 4: different servo connector types.
As we can see from figure 4, different manufacturers use different colors for different functions. Consequently, it is very important that you observe these different signals from different manufacturers as connecting them wrong will damage the motor.
Finally, servo connectors mate with standard 0.025” square pins on 0.1” centers.
Servo Motor Control Signaling
The signal that makes a servo motor move is in the form of a stream of electrical pulses. Although this scheme is similar to pulse width modulation (PWM) it is a bit different, but many people refer to it as PWM. For more on pulse width modulation, see the Pulse Width Modulation Tutorial.
The exact length or duration of the pulses is what determines the position of the servo. It’s not the number of pulses per second that controls the servo, but the duration of the pulses that control it.
Pulse width modulation depends on duty cycle (on time vs off time) of the digital pulses. However, servos don’t care about duty cycle; they care about the duration of the pulses. This is what makes servo control slightly different from PWM. Because of this, it may be more accurate to call servo control pulse duration modulation.
The duration of the pulses are usually 1 – 2 milliseconds.
A 1.5 ms will make the servo return to its midpoint.
A 1 ms pulse will make it turn all the way in one direction while a 2 ms pulse will make it turn all the way in the other direction.
The range of motion of a typical servo is from 0 to 180 degrees, or close to it. It is possible to modify a servo motor for continuous rotation, but since this is an introductory post, we’ll have to talk about that in the future.
For clarification, see figure 5 below.
Figure 5: servo pulse duration vs position.
Usually, a servo motor needs about 50 of these pulses per second, though the number can vary. This is known as the servo’s refresh rate or frame rate.
If this rate is too low, the accuracy and holding torque reduces. If it’s too high the servo might jitter or not work properly.
The actual length of the pulses to position the servo full right or full left varies by manufacturer, and even varies by different models among the same manufacturer. Use caution when trying shorter or longer pulses than 1 – 2 milliseconds. When pushed beyond its mechanical limits, the shaft hits an internal stop or nub. As a result, this can damage the gears or the potentiometer. If the servo starts clicking, this is a sign that the gears are binding.
Servo Control Electronics: More Detail
Earlier we touched on the control board inside the servo. Let’s talk a bit more about how the servo control board works.
Figure 6: servo control block diagram.
The figure above shows a block diagram of the servo control electronics.
First, the local pulse generator generates a pulse proportional in width to the current position of the shaft. The local pulse and input pulse then go to a comparator which subtracts one from the other generating an error pulse. That error signal goes to the stretcher, which is like an amplifier. The reason for this is so a small difference from the comparator can generate a larger drive to the H-bridge. The H-bridge controls which way the motor turns. It’s drive decreases as the position of the shaft approaches the desired position.
Referring back to figure 2, the H-bridge and other components reside on the back of the small PCB.
More on Servo Motor Controls
You can control a servo with a simple circuit like the one shown in figure 7 which uses a 555 timer to generate pulses. However, most of us will opt for a microcontroller or a board such as the Arduino.
Figure 7: a simple 555 servo control circuit.
Although you can hook some servos up directly to an Arduino beware of current draw. Excessive current draw can ruin your Arduino. This tutorial shows you why.
Regardless, you may consider using separate power sources for your Arduino and servo. However, when using different power sources, make sure you connect the grounds from the sources together or the servo will not work right. And remember, underpowered servos may behave poorly and will move slower than a properly powered servo.
Finally, you can use a dedicated serial servo controller. These act like a pulse-producing coprocessor. This frees up your micro or Arduino for other tasks.
Analog vs Digital Servo Motors
The more common and more affordable servos are analog, which use analog circuitry (like in figure 7) to control the motor.
However, digital servos use onboard microcontrollers to enhance operation and offer some advantages. Because they contain a microcontroller, you can program them to control various parameters like speed, direction of rotation, range of rotation, starting point and more. Or, you can skip the programming and use it like an analog servo if you wish.
Since digital servos receive input commands faster, they can update the shaft position faster. This results in more torque and a faster response. However, more torque means the motor draws more current which can shorten battery life.
On the outside, analog and digital servos look the same.
Servo Mechanics: Bushings, and Bearings, and Gears — Oh My!
Although this blog focuses on electronics, the mechanical traits of electronic devices, such as servo motors are important. Any robot builder will tell you this and also tell you that robotics is a mixture of electronics, mechanics, and programming.
Output Shaft Bushings and Bearings
It’s obvious that the output shaft of a servo is its business end. Because of this, it receives a fair amount of wear and tear.
The shafts on cheaper servo motors are supported by a plastic bushing. A bushing is a one piece collar which supports the shaft against the casing.
Better servos sport metal bushings. These are usually made from lubricant-impregnated brass. Of course, servos with this feature cost more but last longer.
The best servos have ball bearings which provide the longest life.
Last but not least, to use a servo, you will probably need to attach a horn to the spline. Horns come in many different shapes and sizes and are often not interchangeable between different manufacturers. Figure 8 depicts different servo horns with mounting hardware.
Figure 8: various servo horns and mounting hardware.
The continuous DC motor inside the servo spins way too fast to be useful for fine position control.
Hence the gear train to slow it down which also increases output torque.
There are basically three types of gear materials:
- Proprietary material (like Karbonite)
First of all, nylon gears are cheaper but weaker and strip or break the easiest. They’re fine for general purpose servos though, and replacement gear sets are available for many makes and models.
Metal gears are much stronger but are heavier and cost more. They’re good for walking robots and large robotic arms. One caveat about metal gears: due to wear on the teeth, they can develop slop or looseness in the gear train. This causes loss of precision. To combat this, opt for titanium gears if you can afford it.
And last on our list, proprietary (i.e. Karbonite) gears are stronger than nylon but just as light weight. While they wear a bit better than metal gears, metal is still the strongest.
Servo Motor Specs
Servo motors follow some standards, and size is one of them. Of course, exceptions exist, but you’ll often find servos in a few size categories. Note that the following dimensions are the case dimensions of the servo.
Standard size servos measure about 1.5” x ¾” x 1 3/8” and have a mounting flange with four holes.
Quarter (or large scale) servos are about twice as large as the standard servos and more powerful. Because of this, they’re good for robot locomotion (if you modify them for continuous rotation). They typically measure about 2” x 1 1/8” x 2 3/8”.
Mini and micro servos are half the size or less of standard ones. Use these in tight spaces. A typical size for a mini servo is 1 1/8” x 5/8” x 1”. A typical size for a micro servo is 7/8” x 3/8” x 5/8”.
Figure 9 gives some idea of the relative sizes.
Figure 9: on the far right are the mini and micro servos while the standard servos are toward the left.
Other Important Servo Specs
Finally, size isn’t the only thing that matters.
Torque is another important spec. It’s often given in inch-ounces at either 4.8 V or both 4.8 and 6 V.
Speed or transit time is the time the motor takes to rotate through a given angle, often 60 degrees.
Current consumption is unfortunately not always given. The amount of current the motor consumes depends on whether the servo is idling, under a load, in transit, or stalling. One way to get this info is to use your multimeter to measure the current under various conditions. Note that any motor will draw the most current when stalled. Due to this fact, be careful how you power your servo.
Now You Know What a Servo Motor is and How it Works
Originally, I wanted to give some specific ways (including some code) to control servo motors, but this has grown to almost 2500 words so far. There’s more to say about servo motors and servo control, so these topics will likely show up in a future post.
Until then, leave a comment and tell me if you’re into robotics. If so, what’s your latest project like?
FREE Guide: 10 Mistakes ALL Electronic Enthusiasts Make
Learn the mistakes made by newbies and veterans alike...
... and HOW to avoid them