Hackaday Dictionary: Servo Motors

How do you make things move? You add in a motor that converts electrical energy into motion. That’s a simple idea, but how do you know where the motor is? That’s where the servo motor comes in. By adding a sensor and a controller to the mechanism, these motors can figure out how far they have rotated and maintain that setting without any need for external control.

A disassembled servo motor showing the controller, motor, rotary encoder and gears. By oomlout - SERV-05-ST_TEARDOWN_03, CC BY-SA 2.0
A disassembled servo motor showing the controller, motor, rotary encoder and gears. By oomlout, CC BY-SA 2.0

What is a Servo Motor?

These neat devices can be large or small, but they all share the same basic characteristics: a motor connected to a gearing mechanism and an encoder that detects the movement and speed of the motor. This combination means that the controlling device doesn’t need to know anything about the motor itself: the controller on the servo motor handles the process of feeding the appropriate power to the motor until it reaches the requested position. This makes it much easier to build things with servomotors, as the designer has already done all the hard work for you.

The first place that most people encounter a servo motor is in the small hobby servos that are used in remote control vehicles. Manufactured by companies like Hitec and Futaba, these drive a gear or arm that transfers the rotation of the motor to perform tasks like turning a wheel to steer a car, moving a control surface on an RC plane, or any task that requires a small range of motion at high precision. The gearing in the servomotor offers more torque than connecting the shaft directly to the motor. Most hobby servos of this type are restricted to a certain range of motion (usually 180 degrees) because the position encoder is a simple potentiometer connected to the output shaft.

A selection of different sized servo motors. By Osamu Iwasaki
A selection of different sized servo motors. By Osamu Iwasaki

Servomotors usually have three connection wires: a power line, a ground line and a signal line. The signal line is fed a pulse width modulation (PWM) signal that determines the angle that the servomotor moves to. As the name suggests, the length of the pulse (or the width, if you look at it on an oscilloscope) is the thing that controls the angle that the servo moves to: a short pulse (1 millisecond) sets it to the zero angle, while a long pulse of 2 milliseconds sets it to the maximum angle. A pulse length between these two limits signals the servomotor to move to the corresponding angle: 1.5 ms would set it to 90 degrees.

It is important to note that servomotors and stepper motors are not the same thing. Both are used for positioning, but steppers usually run without feedback. Instead, steppers turn (as the name suggest) in discrete steps. To figure out where a stepper motor is requires a limit switch, then driving the stepper until this is triggered. Then if you keep count out the number of steps that it’s traveled, you know where it is. That’s why devices like inkjet or 3D printers will move to their limits when they start up, so the controller can detect the far limit of the mechanism being driven, and calculate the current position from that.

How Do You Use A Servomotor?

Because the designers of servomotors have done most of the hard work for you, servomotors are very easy to use. To drive them, you just need to feed them power (usually 5V) and feed the PWM signal to the servomotor. You can drive them directly from an Arduino or similar microcontroller using a library that converts an angle into a PWM signal on one of the output pins.

Each servomotor requires a dedicated output pin if they are being driven this way, though, so if you are driving a lot of servomotors, a dedicated controller makes more sense. Devices such as the Adafruit Servo Shield and the Pololu Maestro allow you to control multiple servos from a single output pin on the microcontroller: the microcontroller sends a signal to the device addressing each servo in turn, and the device converts this into the PWM signals for each. If you need to drive a lot of servos, the SD84 can control up to 84 servos at once from a single USB port.

(Headline image bots: µBob and Hexapod4.)

28 thoughts on “Hackaday Dictionary: Servo Motors

  1. >”To drive them, you just need to feed them power (usually 5V) and feed the PWM signal to the servomotor. ”

    When I was learning to use servos, I was warned that some motors won’t tolerate the full operating voltage on the signal input, and instead you should use 3.3 volts.

    And it’s not exactly a PWM signal, because the duty cycle doesn’t determine the position. You can pulse an analog servo at different rates, because the internal circuit turns the absolute width of the pulse into the control voltage. Increasing or decreasing the pulse rate has and effect on how agressively the servo holds and seeks position.

    1. Exactly. Old analog RC transmitter transmit the individually pulse width for the servo sequentially over the radio channel, so each of the serve might not see the next pulse until all the servos are done. The position is determined by the pulse width. How many “channels” of servos that the transmitter has to cycle through determines the the duty cycle/update rate.

      1. The typical servo pulse repeats about every 20 ms and the maximum pulse durations is 2 ms, so you can technically drive up to 10 servos on the same channel at the same time without delaying any one servo. Each is simply given its own 2 ms timeslot that repeats every 20 ms.

        If the update frequency goes too long, the servo goes soft and won’t hold position very well. If it goes too fast though, it gets jittery and eventually glitches out.

      2. Note that the entire frame (the space of time in which a pulse of between 1-2ms width is sent) is typically only 20ms per channel. That’s certainly the case on older tech, like you suggest. But the number of channels doesn’t change that frame size of 20ms. The time it takes to cycle through all channels does (which I think is what you’re getting at).

        Modern transmitters don’t have this problem. They multiplex channels into a single 50ms frame, each channel’s value sent sequentially. So channel one starts low, goes on for 1.5ms (or whatever), goes low. Each channel follows a similar pattern. The receiver then demuxes those, using the lows to sort which channel is which.

        Then there’s stuff like PPM, where a receiver can send all those frames to, say, a quadcopter flight controller over a single signal wire. The flight controller then demuxes and sends RC-style PWM to individual speed controllers.

        1. It’s relatively easy to de/multiplex multiple analog servos on the same channel by utilizing a pulse counter in the reciever that switches the signal to different servos in sequence and resets after a longer pause. Same thing in the transmitter – a counter sets off a bunch of one-shots that generate the required signals in the correct order.

          That’s the entire point why the pulse duration is so short, so you could easily multiplex a sequence of pulses in the same frame.

    2. If I remember correctly, the internal circuit of the servo has a one-shot pulse generator that is adjusted by the potentiometer connected to the servo output shaft. The idea is that when the control pulse arrives, the two pulses are compared. Suppose both signals are connected directly to the wires of a DC motor: when both are high or low, the motor won’t turn. When one is high and the other is low, the motor turns one way or the other.

      When the two pulses are equal in length, the motor doesn’t do anything because they’re always high or low simultaneously. When the two pulses are un-equal in length the motor gets a pulse to turn, and the more they are unequal the longer the pulse will be, and the more power the motor will apply to turn in that direction.

      In the real circuit, there’s also a pulse stretcher because the duty cycle would otherwise be between 5-15% and that wouldn’t turn the motor very strongly. That’s also why the servo becomes stronger when you pulse it faster – the duty cycle goes up; and also why it glitches out at higher pulse rates – the pulses start to overlap.

      1. Of course digital servos are different. They simply observe the pulse duration and generate their own PWM signal to the motor. That’s why they can be pulsed at some high frequency like 400 Hz.

  2. There’s also continuously rotating servos, which attempt to turn continuously by applying power proportionally to the difference between signal and the mid-point pulse width, plus or minus some dead zone.

    A regular servo can be hacked into a continuously rotating one by pulling out the potentiometer, setting it to middle, and removing the stop in the final gear. That way you get a bi-directional DC motor with an integrated speed controller.

    1. Back in the days, I designed an ESC using discrete 45xx CMOS chips and what I could get my hands on back then. The difference pulses are stretched with RC circuit and basically becomes the PWM signal for driving the motor with a H bridge to provide forward/brake. A full bridge would have been nice, but at 2X parts and 2X drops. I had a 555 circuit that turns on the relay that bypasses the transistor when the pulse width is at 100% duty cycle after a small delay.

      1. It’s possible to make a kind of full bridge by using PNP transistors or P-channel FETs with their bases crossed over similiar to an astable multivibrator. That way you don’t need the high side drivers and only need to switch the low side transistors.

        There’s just no dead-time control in switching unless you construct some sort of RC delay in there.

  3. I’m curious: why no mention of other kinds of servo motors? At the very least it’s worth pointing out that servo motors aren’t limited to the 3.3v to 5v “toys” described here. There was a time when I assumed a servo was what this entry describes. When I started getting into building CNC machines I’d run across debates about whether servos or steppers were better and it took a while to realize that there are some monster servo motors out there, ones that are far removed from the toys described here.

        1. I would say “was used” – in the time when power semiconductors and (electronic) variable frequency drives were not available. I can not imagine any new design using this.

          1. They’re still cheaper for very high power operation, in the hundreds of kilowatts range where the power loss in a rotary converter won’t matter as much. Think locomotives and large earth movers.

      1. I don’t disagree at all. But given that the title here starts with “Hackaday Dictionary”, you’d think covering the various types of servo techs wouldn’t hurt.

        Also, in another comment of yours you provide Wikipedia links to servo control amps. Here’s what Wikipedia has for Servomotor:

        https://en.wikipedia.org/wiki/Servomotor

        Most hobbyists use the term Servo for the kind of things described in this HaD article. Here’s Wikipedia’s entry for those:

        https://en.wikipedia.org/wiki/Servo_(radio_control)

    1. Servos that are as big as large induction motors that could rip you to pieces are pretty common in industrial automation! What is really astounding is how precise these huge pieces of machinery can be…

  4. There’s many subtypes of these hobby servos. The internal motor can be “cored” having an iron armature, “coreless” where the armature is a cleverly wound cup of wire, and brushless where the motor is basically a three or more phase AC motor driven by a micro. Iron cored motors are slow, have lower torque, and less precision – they cog a lot, but are cheapest. Coreless have good torque and precision, and brushless are extremely high torque. Brushless motors are the most immune to burning out from extended operation stalled. Stalling a servo occurs when the servo is trying to get to your commanded position but can’t quite make it due to torque limitations. This causes the servo to continuously drive the stalled/stopped motor at full power, and can burn up a cored or coreless servo in under a minute. Think of using a servo to lock a jammed door bolt or operate a robot arm lifting a heavy object.

    Additionally the internal electronics can either be “analog” or “digital”. The analog electronics are cheaper but less precise and usually lower torque (because they only drive the motor for a short time following the command pulse). Digital servos are usually more precise and will drive the motor continuously giving more torque. They usually have some degree of burnout protection. Analog servos will emit noise at the control pulse frequency – usually 50Hz, digital servos at 300Hz up. Look for a digital servo that operates above 20Khz if you need quiet, otherwise that 300Hz buzz is surprisingly loud and grating to the ears. Brushless servos can be pretty quiet depending on the electronics – but are very expensive. As far as power consumption – servos consume little power when lightly loaded. When stalled or moving quickly they consume from 1A-4A at 4.8v depending on the torque rating. This can add up when using multiple servos. If you don’t supply enough current the controller electronics will behave erratically causing erratic mechanical behavior.

    Look for an all metal gear train for heavy lifting or if you need the servo to survive a lot of cycling (10,000 cycles or more).

  5. There was one thing missing from the article that I find useful:

    Usually, sensors and servos are wired from light-to-dark, the wire of the lightest colour carries the signal, the darkest wire is the ground wire, and the middle wire carries the power.

    ground (black, brown,…)
    signal (white, yellow,…)
    +5V (red, red,…)

  6. To hell with it. I’m done with swiping past walls of text on my phone. From here on out I’ll be visiting HaD from my desktop where I have PgUp\PgDn keys. And Adblock.

    There is a reason they invented summaries and full-article links and this is pretty much it.

  7. I sometimes work with RC servos at work. A couple things have become apparent.
    1) They are good for course positioning, not so much for fine positioning. There is a range where the servo reduces power when it drives to within a deadband (i.e. very close to the target position.)
    2) If they are moved between two positions frequently, those positions become less accurate over time (the position feedback potentiometer wears out).
    3) If you stop sending pulses, they go to a low power “inactive” state where they can be pushed around. Good to know if you know when you’re trying to drive past a physical limit. Drive to the new position for a couple seconds, then stop sending pulses. Reduces wear on the gears (which are replacable), and tends to prevent burning out the motor driver H-bridge (I think the motor can take the abuse all day long).
    4) Futaba S3010 respond to pulses in the range of 0.5ms to 2.5ms by moving through a 270 degree range. Linearity suffers a bit outside the 1.0-2.0ms range (90-120 degree range), but if you’re going to defined positions, you don’t really care about linearity. This doesn’t harm the servo – it just operates outside its traditional range, and likely doesn’t meet specs for linearity, torque, speed, or deadband. YMMV
    5) Servos can accept input pulses at whatever voltage the servo is powered from. I haven’t been able to tell if the input buffer is CMOS/Schmitt (Vthreshhold=Vdd/2), TTL (=2.0V), or something else. Reasonably sharp pulse edges and rail-to-rail pulses prevent me from having to find out.
    6) Servos seem insensitive to pulse timing variation less than 5-10 uSec. Again, YMMV
    7) If you need accurate positioning over time, every time, you’d be better served by a stepper.

  8. Hobby servos are very convenient, but are a little lacking for some applications. Robotic hobby servos like the dynamixels add some nice features for increased price and different control wiring.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s