A standard RC servo reads its target position via a Pulse Width Modulation (PWM) signal, expecting a 50 Hz pulse train (a 20 ms period) where the high-time width—typically between 1.0 ms and 2.0 ms—dictates the exact shaft angle from 0° to 180°. Inside the servo housing, a dedicated comparator ASIC reads this incoming PWM pulse and measures it against the voltage drop from an internal potentiometer physically linked to the output gear. The resulting error voltage drives an internal H-bridge and DC motor until the potentiometer's physical position matches the commanded PWM width, at which point the motor halts. If you are building a robotic arm or pan-tilt mount, understanding this closed-loop servo read mechanism is the difference between a rigid joint and a jittering, overheating mess.
Motor Type Comparison: Servo vs. Stepper vs. Brushed DC
Before wiring up your microcontroller, you must verify that a servo is actually the right actuator for your mechanical load. Hobbyists frequently swap steppers and servos interchangeably, which leads to catastrophic failure in high-load applications. Here is how the torque curves and control architectures stack up.
| Criteria | RC Servo (Closed-Loop) | Stepper Motor (Open-Loop) | Brushed DC Motor |
|---|---|---|---|
| Torque Curve | Maximum torque at zero speed (stall); drops if forced past limit. | High holding torque at zero speed; drops sharply as RPM increases. | Peak torque at stall; linear drop-off as speed increases. |
| Control Needs | 50Hz PWM signal (1-2ms pulse); internal feedback handles the rest. | High-frequency step/direction pulses; requires constant coil energization to hold. | Simple voltage polarity and magnitude via H-bridge; no positional awareness. |
| Positional Accuracy | ±1° to ±3° (potentiometer tolerance and gear backlash). | Exact (e.g., 1.8° per full step), assuming no missed steps under load. | None (requires external encoder for positioning). |
| Typical Cost (Hobby) | $4 (SG90) to $25 (DS3218 20kg-cm). | $15 to $45 (NEMA 17 + A4988 driver). | $2 to $10 (plus $5 for motor driver IC). |
| Best Application | Robotic arm joints, RC steering, camera gimbals. | 3D printer axes, CNC routers, conveyor indexing. | Drive wheels, continuous conveyors, cooling fans. |
Inside the Black Box: Wiring and the Potentiometer Feedback
To command a servo, your microcontroller only needs to interface with three external terminals. The standard 3-pin JR/Futaba connector color code is:
- Brown or Black (GND): Common ground. Must be shared with your microcontroller and power supply.
- Red (VCC): Power input. Nominally 4.8V to 6.0V for standard servos, up to 8.4V for high-voltage (HV) variants.
- Orange, Yellow, or White (Signal): The PWM logic input. Tolerates 3.3V logic from an ESP32, though 5V is native.
When the ESP32 sends a 1.5 ms pulse, the internal servo ASIC (often an AA5188 or equivalent clone) measures the pulse width. It then reads the wiper pin of the internal potentiometer. If the pot reads 1.2V (indicating the shaft is at 45°) but the 1.5ms pulse commands the center position (which corresponds to 1.65V), the internal error amplifier outputs a voltage to the H-bridge. The DC motor spins the gear train until the pot wiper reaches 1.65V, at which point the error drops to zero and the motor brakes.
Sizing Rule of Thumb and Worked Load Example
Hobby servos are rated in kg-cm (kilogram-centimeters), which is the force of one kilogram suspended at the end of a one-centimeter lever arm. To size a servo correctly, you must calculate the worst-case static torque at the furthest mechanical extension, then apply a dynamic safety margin.
The Sizing Rule of Thumb:
Calculate the static stall torque required to hold the load horizontally, add the torque required to hold the weight of the arm itself, and multiply the total by 2.5. This 2.5x multiplier accounts for acceleration forces, mechanical binding, and the fact that a servo's continuous working torque is roughly 40% of its advertised stall torque.
Worked Load Example: ESP32 Robotic Forearm
Imagine you are building a robotic arm. The forearm is 15 cm long and weighs 100g (center of mass at 7.5 cm). It needs to lift a 200g payload at the very tip (15 cm).
- Payload Torque: 200g (0.2 kg) × 15 cm = 3.0 kg-cm
- Arm Weight Torque: 100g (0.1 kg) × 7.5 cm = 0.75 kg-cm
- Total Static Torque: 3.0 + 0.75 = 3.75 kg-cm
- Dynamic Safety Margin (× 2.5): 3.75 × 2.5 = 9.375 kg-cm
You need a servo rated for at least 9.4 kg-cm. The ubiquitous TowerPro MG996R is rated for 13 kg-cm at 6.0V (costing around $8), making it a perfect fit with enough headroom to prevent continuous stalling. If your calculation yielded 18 kg-cm, you would step up to a DS3218 20kg-cm waterproof servo (approx. $14).
Failure Signatures: Diagnosing Hum, Overheat, and Stall
Servos fail in highly predictable ways. If your assembly line or robotic arm is acting up, diagnose the symptom using this matrix before swapping hardware.
| Symptom | Root Cause | The Fix |
|---|---|---|
| Constant Humming / Jittering | Software PWM jitter on the microcontroller, or power supply noise causing the internal comparator to misread the pulse width. | Use hardware PWM (the LEDC peripheral on ESP32). Add a 470µF electrolytic decoupling capacitor across the servo's VCC and GND wires at the connector. |
| Overheating / Melting Plug | The servo is physically blocked from reaching its target angle, causing it to draw maximum stall current (often 2A+) indefinitely. | Implement a software timeout: cut the PWM signal (detach the servo in code) 500ms after sending the target position. Ensure mechanical limits aren't binding the gear train. |
| Audible Clicking / Stripped Gears | Dynamic shock load exceeded the shear strength of the internal gears (common with plastic or nylon gear sets under sudden impact). | Upgrade to metal-gear variants (e.g., MG996R instead of SG90). Implement software acceleration ramping so the servo doesn't snap to 180° instantly. |
| Drifting Position Over Time | Wear on the internal carbon-track potentiometer, causing the wiper voltage to fluctuate even when the shaft is stationary. | Replace the servo. Potentiometer wear is terminal. For high-reliability applications, switch to a magnetic encoder servo or a brushless gimbal motor. |
Decision Tree: Picking the Right Servo and Driver
Do not guess your BOM (Bill of Materials). Follow this decision path based on your calculated load and system complexity to arrive at the exact hardware you need.
- IF your calculated dynamic load is < 2.0 kg-cm AND you are driving 1 or 2 joints on a simple pan-tilt camera mount:
- Pick: SG90 Micro Servo ($4).
- Driver: Direct ESP32 GPIO via the hardware LEDC peripheral.
- IF your load is between 2.0 and 15.0 kg-cm AND you are building a multi-axis robotic arm (3 to 6 joints):
- Pick: MG996R Metal Gear Servo ($8 each).
- Driver: PCA9685 16-Channel I2C PWM Breakout. The ESP32's native PWM pins are limited and can suffer from timer conflicts; offloading to the PCA9685 guarantees jitter-free signals across all 16 channels (Adafruit PCA9685 Guide).
- IF your load is > 15.0 kg-cm OR you require absolute positional feedback (reading the angle back to the ESP32):
- Pick: LewanSoul LX-16A Bus Servo ($22). These use a serial TTL protocol instead of PWM, allowing you to read the internal temperature, voltage, and exact position back to the microcontroller.
- Driver: Dedicated serial bus controller board or a simple UART-to-TTL logic level shifter.






