At its core, a servo motor is a closed-loop rotary actuator. While a standard DC motor spins continuously and a stepper motor moves in discrete open-loop increments, a servo contains an internal feedback mechanism—usually a potentiometer or magnetic encoder—that constantly monitors the output shaft's position. When you ask what does a servo do, the precise answer is: it compares its current physical position to a target position defined by an incoming PWM (Pulse Width Modulation) signal, and drives its internal DC motor to eliminate the error between the two.

This closed-loop architecture makes servos the default choice for robotic arms, camera gimbals, and RC steering, where holding a specific angle against a physical load is mandatory. However, treating a servo like a simple DC motor or assuming it is interchangeable with a stepper will lead to stripped gears, brownouts, and fried microcontrollers. Below is the bench-tested framework for selecting, sizing, and driving servos in embedded projects.

Servo vs. Stepper vs. DC: Choosing the Right Actuator

Before sizing a specific model, you must verify that a servo actually fits your load profile. Steppers excel at high-speed precision and holding torque without a gearbox, while brushed DC motors are ideal for continuous high-RPM rotation. Servos win when you need high torque at low speeds, built-in position feedback, and a compact form factor.

Motor Type Comparison for Embedded Actuation
Motor Type Torque Curve Control Needs Typical Cost (Hobby Grade) Best Load Profile
Standard Servo Peak torque at stall; drops as speed increases. 50Hz PWM signal (1000-2000µs). No H-bridge required. $3 - $18 Angular positioning (0-180°), robotic joints, RC steering.
Stepper Motor High holding torque; drops sharply at high RPM. Step/Dir pulses via dedicated driver (e.g., A4988, TMC2209). $12 - $35 (plus driver) 3D printer axes, CNC routers, continuous precise rotation.
Brushed DC Motor Linear torque-speed curve; max torque at stall. H-bridge for direction; PWM for speed. No position feedback. $2 - $10 Drive wheels, conveyor belts, high-speed fans.

Sizing Rule of Thumb: A Worked Load Example

The most common mistake in embedded robotics is undersizing the servo. Hobby servos are rated by stall torque, typically measured in kg-cm (kilogram-centimeters) or oz-in. Stall torque is the maximum force the servo can exert right before it stops moving. You should never design a system that operates at stall torque.

The 1.5x to 2x Sizing Rule: Your servo's rated stall torque must be at least 1.5 to 2 times the calculated maximum holding torque of your mechanical load. This accounts for dynamic forces, friction, and acceleration spikes.

Worked Example: Robotic Arm Elbow Joint

Imagine you are building a robotic arm. The forearm (lever arm) is 15 cm long from the elbow joint to the gripper. The forearm itself weighs 100g, and it needs to lift a 200g payload horizontally.

  1. Calculate the total mass: 100g (arm) + 200g (payload) = 300g (0.3 kg).
  2. Calculate the center of mass: For simplicity, assume the worst-case scenario where the entire mass is concentrated at the end of the 15 cm lever (the gripper).
  3. Calculate required holding torque: Torque = Force × Distance.
    0.3 kg × 15 cm = 4.5 kg-cm (approx. 0.44 Nm).
  4. Apply the safety factor: 4.5 kg-cm × 2.0 = 9.0 kg-cm.

You need a servo rated for at least 9.0 kg-cm. A standard micro servo like the SG90 (1.8 kg-cm) will instantly strip its plastic gears. Instead, you would select a TowerPro MG996R (rated ~10 kg-cm, ~$5) or step up to a DS3218 (rated 20 kg-cm, ~$14) for heavy-duty reliability. Always verify the datasheet torque values at the specific operating voltage (e.g., 5V vs 6V), as torque drops significantly if your BEC sags under load.

Wiring, Terminals, and ESP32 PWM Control

Standard hobby servos use a 3-pin JR-style connector. Identifying the terminals correctly is critical; reversing VCC and Signal will not damage most modern servos, but reversing VCC and GND will instantly fry the internal control IC.

  • Brown or Black Wire: Ground (GND). Must be shared with your microcontroller's GND.
  • Red Wire: Power (VCC). Typically 4.8V to 6.0V for standard servos, up to 7.4V for high-voltage (HV) models.
  • Orange, Yellow, or White Wire: Signal (PWM). Accepts a 3.3V or 5V logic-level 50Hz pulse.
Warning: Never Power High-Torque Servos from the ESP32 VIN Pin.
A DS3218 can draw over 2.5 Amps at stall. The ESP32-WROOM-32 dev board's onboard 5V regulator or USB trace will overheat and fail. Always use a dedicated 5V/3A BEC (Battery Eliminator Circuit) or a buck converter (like the LM2596) wired directly to your main battery pack, and tie the BEC GND to the ESP32 GND.

Driving the Servo with ESP32 LEDC

The ESP32 does not use the traditional Arduino `Servo.h` library natively; it relies on the LEDC (LED Control) peripheral to generate hardware PWM. According to the Espressif LEDC documentation, you must configure a 50Hz frequency and map the 1000-2000 microsecond pulse width to the ESP32's 16-bit resolution.

For a 16-bit resolution (0-65535) at 50Hz (20,000µs period):
1000µs maps to roughly 3276.
2000µs maps to roughly 6553.
Use the `map()` function in your code to translate your desired angle (0-180) into this 3276-6553 range before calling `ledcWrite()`.

Failure Signatures: Hum, Overheat, and Stall

Servos communicate their distress physically before they fail electrically. Recognizing these signatures on the bench will save you from burning out drivers and stripping gears.

  • The 'Hum' or Jitter: If the servo vibrates or hums while holding still, you have a noisy PWM signal or a ground loop. This is incredibly common when sharing a 5V rail between an ESP32 and a servo. The servo's current draw causes millivolt sags on the ground plane, which the servo's internal pot reads as a position change. Fix: Add a 100µF electrolytic capacitor across the servo's VCC and GND wires, and ensure a star-ground topology.
  • Overheat (Thermal Shutdown): If the servo casing becomes too hot to touch, it is likely stalling against a mechanical hard stop while still receiving a PWM signal commanding it to move. The internal motor is drawing maximum stall current continuously. Fix: Implement software limits in your code to prevent commanding angles beyond your mechanical bounds, or use a servo with a built-in current-limiting protection IC.
  • Audible Clicking / Stripping: A rhythmic clicking under load means the internal potentiometer is worn, or the plastic gears are skipping teeth. Fix: Upgrade to a metal-gear servo (like the MG996R) and ensure your mechanical linkage isn't binding.

Frequently Asked Questions

What does a continuous rotation servo do compared to a standard one?

A continuous rotation servo has had its internal potentiometer disconnected and its physical hard stops removed. Instead of moving to a specific angle, the PWM signal dictates its speed and direction. A 1500µs pulse means 'stop', 1000µs means 'full speed counter-clockwise', and 2000µs means 'full speed clockwise'. Because it lacks position feedback, it functions essentially as a geared DC motor with an integrated ESC (Electronic Speed Controller), making it ideal for differential drive robot wheels but useless for robotic arms.

What does a servo do when it loses its PWM control signal?

When the PWM signal drops out entirely, a standard analog servo will 'go limp' and enter a freewheeling state; it will no longer hold its position and can be back-driven by external forces. However, many modern digital servos feature a 'hold last position' or 'fail-safe' mode programmed into their internal MCU. Always test your specific servo's fail-safe behavior by physically disconnecting the signal wire while the servo is under load, especially in safety-critical applications like drone gimbals or heavy lifting mechanisms.

What does a digital servo do differently than an analog servo?

Analog servos use a simple analog comparator circuit to process the PWM signal and drive the motor, typically sending voltage pulses to the motor at the same 50Hz rate as the control signal. Digital servos use an internal microcontroller to process the signal and can drive the motor with high-frequency PWM (often >300Hz). This results in much tighter deadband, faster acceleration, and significantly higher holding torque. The trade-off is higher current draw and increased power consumption, which must be factored into your battery and BEC sizing. For a deep dive into the electromechanical differences, the Adafruit Motor Selection Guide provides excellent teardown comparisons of analog vs. digital internal circuitry.