A servo motor is a closed-loop rotary actuator that uses positional feedback to achieve precise angular or linear control. Unlike open-loop steppers that rely on magnetic detents and step counting, servos continuously read a potentiometer or magnetic encoder and adjust their internal DC or AC motor to hit the exact target angle. For microcontroller builders, selecting the right servo dictates your power architecture, control library, and mechanical reliability.

The Core Types of Servos in Embedded Systems

When sourcing motors for robotic arms, pan-tilt cameras, or RC-style actuators, you will encounter four primary categories. Treating a continuous rotation servo as a positional one, or using an analog servo on a high-frequency serial bus, will result in immediate project failure.

Motor Type Comparison: Torque, Control, and Cost
Servo Type Torque Curve & Feedback Control Needs Typical Cost (USD)
Standard Analog (e.g., SG90, MG996R) High stall torque, deadband ~2°. Internal pot feedback. 50Hz PWM pulse (1000-2000µs). Simple GPIO timer. $2 - $12
Digital PWM (e.g., DS3218) Flatter torque curve at low speeds, tighter deadband (~0.5°). 50Hz PWM, but internal MCU drives motor at higher kHz frequency. $15 - $25
Serial Bus / Smart (e.g., Dynamixel XL430) Linear torque profile, PID tunable, magnetic encoder feedback. Half-duplex UART (TTL 3.3V/5V). Requires specific packet protocols. $45 - $250+
Continuous Rotation (e.g., FS90R) No positional feedback. Speed and direction mapped to pulse width. 50Hz PWM. 1500µs = stop, <1500 = reverse, >1500 = forward. $4 - $10

Wiring, Terminals, and Controller Demands

The physical interface of a standard hobby servo consists of a 3-pin JST or Dupont connector. The industry standard color code is strictly enforced across almost all analog and digital PWM models:

  • Brown or Black: Ground (GND). Must be tied to the microcontroller GND and the power supply GND.
  • Red: VCC. Typically 4.8V to 6.0V for standard servos, up to 7.4V for high-voltage (HV) digital servos.
  • Orange, Yellow, or White: Signal (PWM). Requires a 3.3V or 5V logic-level pulse.
Power Architecture Warning: Never power a servo larger than a micro SG90 (approx. 1.8 kg-cm) directly from an Arduino or ESP32 5V/3V3 pin. A standard MG996R can draw 2.5A at stall. This will instantly brownout your microcontroller, corrupt EEPROM/Flash, or melt the onboard USB trace. Use a dedicated 5V/6V BEC (Battery Eliminator Circuit) or a buck converter rated for at least 3A per servo, sharing only the GND reference with your logic board.

ESP32 vs. Arduino Control Nuances

On classic AVR Arduinos (Uno/Nano), the standard Servo.h library handles the 50Hz timer interrupts perfectly. However, the ESP32 architecture requires a different approach. The legacy Servo.h library is notoriously buggy on ESP32, often causing watchdog resets or severe PWM jitter due to conflicts with the Wi-Fi/BT RTOS tasks.

For ESP32 Arduino Core v3.x, you must use the native LEDC (LED Control) peripheral to generate the 50Hz signal:

// ESP32 Native LEDC Servo Control (Core v3.x)
const int servoPin = 13;
const int freq = 50;
const int resolution = 16; // 16-bit resolution (0-65535)

void setup() {
  ledcAttach(servoPin, freq, resolution);
}

void setServoAngle(float angle) {
  // Map 0-180 degrees to 1000-2000 microsecond pulse width
  float pulseWidth = 1000 + (angle * (1000.0 / 180.0));
  // Convert microseconds to 16-bit duty cycle (at 50Hz, period is 20,000us)
  uint32_t duty = (pulseWidth / 20000.0) * 65535;
  ledcWrite(servoPin, duty);
}

Sizing Rule of Thumb and Load Calculation

Servo torque is universally rated in kg-cm (kilogram-centimeters) or oz-in in hobbyist datasheets, representing the stall torque at the output shaft. To select the correct motor, you must calculate the dynamic load and apply a safety factor.

The Rule of Thumb: Calculate the peak static torque required to hold the load at the maximum horizontal extension, then multiply by 2 for slow, smooth movements, or by 3 for rapid, high-acceleration dynamic loads.

Worked Load Example: 2-DOF Robotic Arm

Imagine a wrist servo lifting a 500g payload. The forearm is 15cm long and weighs 200g. We need to size the elbow servo.

  1. Payload Torque: 0.5 kg × 9.81 m/s² × 0.15 m (full length) = 0.735 Nm.
  2. Arm Weight Torque: The arm's center of mass is at 7.5cm (0.075m). 0.2 kg × 9.81 m/s² × 0.075 m = 0.147 Nm.
  3. Total Static Torque: 0.735 + 0.147 = 0.882 Nm.
  4. Convert to kg-cm: 0.882 Nm ÷ 0.0980665 = 9.0 kg-cm.
  5. Apply Safety Factor (x2): 9.0 × 2 = 18.0 kg-cm minimum required.

Selection: A standard MG996R is rated for ~13 kg-cm. It will stall and overheat under this load. You must step up to a digital DS3218 (20 kg-cm) or a serial bus Dynamixel XL430-W250 (rated dynamically for similar loads with PID tuning) to ensure reliable operation without gear stripping.

Failure Signatures: Hum, Overheat, and Stall

Servos fail in highly specific ways that differ fundamentally from stepper motors. A stepper motor holds position via magnetic detent; if blocked, it simply skips steps or holds statically (though it will overheat if holding current remains high). A servo, however, is a closed-loop system that will actively fight to reach its commanded position, drawing maximum stall current until it physically breaks or burns out.

  • The "Hum" or Jitter: If the servo vibrates at the target position, you have a ground loop, inadequate current delivery (causing micro-brownouts that reset the internal potentiometer reading), or a noisy PWM signal. On ESP32s, jitter almost always points to Wi-Fi interrupts disrupting software-based PWM timers; switching to hardware LEDC pins resolves this.
  • Overheat and Potentiometer Burnout: If a servo is mechanically blocked (stalled) while commanded to move, the internal H-bridge drives full voltage into the DC motor. In analog servos, this burns out the carbon track on the internal potentiometer within seconds. Digital servos handle this slightly better but will still melt the windings if stalled for more than a few seconds.
  • Gear Stripping (Stall): Plastic (nylon) gears will strip their teeth under sudden shock loads. Metal (brass/steel) gears will survive the shock, but the resulting torque spike will transfer directly to the output shaft, bending it or snapping the internal motor mounts. Always use metal gears for loads exceeding 10 kg-cm.

Frequently Asked Questions

What are the different types of servos used in robotics?

Robotics primarily relies on three types: standard positional PWM servos (like the MG996R) for simple joints and grippers; digital high-torque servos (like the DS3218) for heavy-lift arms requiring tight deadbands; and serial bus smart servos (like the Dynamixel XL series) for complex, multi-axis humanoid or quadruped robots where daisy-chaining, PID tuning, and real-time temperature/load feedback are required.

Can I use a continuous rotation servo for precise positioning?

No. Continuous rotation servos have had their internal potentiometer mechanically disconnected or removed. They operate strictly as speed-controlled DC motors with an integrated gearbox and H-bridge. Sending a 1500µs pulse stops the motor, but there is no positional feedback to verify or hold an exact angle. For precise positioning, you must use a standard positional servo or a stepper motor with a limit switch homing routine.

Why does my ESP32 make my analog servo jitter?

ESP32 jitter is usually caused by the default Servo.h library using software interrupts, which are frequently delayed by the ESP32's background Wi-Fi and Bluetooth RTOS tasks. This stretches or compresses the 50Hz PWM pulse width, causing the servo's internal comparator to constantly hunt for the target position. The fix is to abandon Servo.h and use the ESP32's dedicated hardware LEDC peripheral, which generates the 50Hz signal entirely in hardware, immune to CPU task switching.

How do serial bus servos differ from standard PWM servos?

Standard PWM servos require one dedicated GPIO pin per motor and offer no feedback to the microcontroller. Serial bus servos use a half-duplex UART protocol (often TTL 3.3V/5V), allowing you to daisy-chain dozens of servos on a single TX/RX pair. Furthermore, serial servos allow you to read back real-time data: present position, internal temperature, input voltage, and mechanical load. This allows your code to detect a stall condition and cut power before the motor burns out, a critical feature in advanced embedded robotics.