Servo motor torque control relies on closed-loop current feedback to maintain a specific rotational force, dynamically adjusting phase current to match the exact load demand. Unlike open-loop steppers that push a fixed current regardless of resistance, a servo drive reads the rotor position via a high-resolution encoder and modulates the U/V/W phase currents in real-time. To achieve this with a microcontroller like an ESP32 or Teensy, you must interface with a dedicated servo drive that accepts either analog voltage (±10V), pulse-width modulation (PWM), or digital fieldbus (RS485/EtherCAT) commands. The direct answer for most DIY robotics and CNC builds: use an ESP32's MCPWM peripheral to generate high-speed pulse/direction signals, or use its UART hardware to send Modbus RTU torque commands directly to the drive.
Motor Selection: Servo vs. Stepper vs. BLDC
Choosing the right motor for a torque-sensitive application requires understanding how each topology behaves under load. Stepper motors and servos are not interchangeable; a stepper will stall abruptly and lose position if peak torque is exceeded, while a servo will temporarily draw peak current to overcome the obstacle and report a following error if it fails. Here is how the three primary brushless options compare for embedded control projects.
| Motor Type | Torque Curve Profile | Embedded Control Needs | Approx. Cost (NEMA 23 / 750W equiv) |
|---|---|---|---|
| AC Servo | Flat continuous torque up to rated speed (e.g., 3000 RPM); peak torque (300%) available for acceleration. | Dedicated drive required. Accepts Step/Dir, ±10V analog, or RS485/EtherCAT. Needs high-speed MCU (ESP32/Teensy). | $250 - $450 (Motor + Drive) |
| Stepper | Massive holding torque at zero speed; torque drops off sharply above 600 RPM due to back-EMF and inductance. | Step/Dir pulse generator (MCU) + chopper driver (e.g., DM542). Open-loop; no position feedback unless closed-loop variant used. | $40 - $90 (Motor + Driver) |
| BLDC (Gimbal/Outrunner) | Linear torque-to-current ratio; requires continuous commutation to hold position; poor static holding without high current. | 3-phase ESC or FOC driver (e.g., ODrive, SimpleFOC). Requires Hall sensors or sensorless back-EMF zero-crossing detection. | $80 - $200 (Motor + FOC Board) |
Which motor fits your load profile? If your application requires holding a heavy static load (like a vertical Z-axis) without overheating, or requires rapid, high-inertia acceleration with exact position retention, the AC Servo is the only correct choice. If the load is primarily friction-based and moves at low speeds (like a conveyor belt), a stepper is more cost-effective.
Sizing for Torque: Rules of Thumb and Load Math
Sizing a servo motor is not about matching peak horsepower to a load; it is about matching the RMS (Root Mean Square) torque of your specific motion profile to the motor's continuous torque rating, while ensuring the inertia ratio remains stable. The golden rule of thumb for servo sizing is the 2x to 3x safety margin on continuous torque for high-acceleration moves, and an inertia ratio (J_load / J_motor) of less than 10:1, ideally under 5:1 for high-bandwidth torque control.
Imagine an ESP32-controlled robotic arm lifting a 4 kg payload at a radius of 0.25 meters.
1. Calculate Static Torque: Force = mass × gravity = 4 kg × 9.81 m/s² = 39.24 N. Torque = Force × radius = 39.24 N × 0.25 m = 9.81 Nm.
2. Add Acceleration Margin: If the arm must accelerate at 2 rad/s², and the arm's own inertia adds 0.5 kg·m², acceleration torque = Inertia × Acceleration = 0.5 × 2 = 1.0 Nm.
3. Total Peak Torque Required: 9.81 + 1.0 = 10.81 Nm.
4. Select the Motor: You need a servo with a continuous torque rating of at least 11 Nm (to handle the static hold without overheating) and a peak torque rating of at least 15 Nm. A standard 1.5 kW (approx. 2 HP) AC servo with a 1.5:1 planetary gearbox would perfectly match this profile, bringing the required motor shaft torque down to a manageable 7.5 Nm while multiplying the output torque.
For a deeper understanding of how load inertia affects tuning stability, refer to the engineering guidelines on inertia ratio matching in servo systems. If the load inertia exceeds 10 times the rotor inertia, the servo drive's PID loop will struggle to tune, resulting in oscillation and delayed torque response.
Wiring and Terminal Identification for AC Servos
When wiring an industrial AC servo (such as the ubiquitous Delta ASDA-B2 or Leadshine iSV series) to an ESP32 or Raspberry Pi, you are interfacing with the drive's control terminal block, typically labeled CN1. The ESP32 operates at 3.3V logic, while most industrial servo drives expect 5V or 24V opto-isolated inputs. You must use a logic level shifter or wire the opto-isolator common (COM) to 3.3V and the signal pins to ground to sink the current.
| Terminal / Pin | Function | ESP32 / MCU Connection Notes |
|---|---|---|
| PULSE+ / PULSE- | Step / Torque Command Pulse Input | Connect via high-speed optocoupler (e.g., 6N137) or level shifter. Use ESP32 MCPWM or RMT peripheral for jitter-free pulses. |
| SIGN+ / SIGN- | Direction / Torque Polarity | Standard GPIO. High = CW, Low = CCW. Ensure setup/hold times are met (usually >2μs). |
| SON (Servo ON) | Enable Drive Output | Active LOW on most drives. Pull to GND to enable the power stage. Add a hardware E-stop relay in this circuit. |
| ALRM (Alarm) | Fault Output (Normally Closed) | Wire to an ESP32 interrupt pin with a pull-up resistor. Triggers if overcurrent, overvoltage, or encoder fault occurs. |
| COM | Opto-isolator Common | If sinking current from ESP32 (3.3V), connect COM to ESP32 3.3V. If sourcing, connect to 24V external supply. |
Safety Warning: Always de-energize the main power (L1/L2 or R/S/T) and verify the DC bus capacitors are discharged (below 30V DC with a multimeter) before wiring or modifying CN1 or the motor power terminals (U/V/W). Industrial servo drives maintain lethal DC bus voltages (approx. 320V DC for 220V AC input) long after main power is removed.
Controller Demands and Failure Signatures
A servo motor demands a drive that exactly matches its encoder resolution and feedback type. A 17-bit absolute encoder (131,072 counts per revolution) requires a drive capable of processing that data stream, usually via a proprietary serial protocol over the CN2 connector. You cannot mix a 17-bit absolute motor with a drive expecting a 2500-line incremental encoder; the drive will immediately throw an encoder mismatch fault.
When tuning or operating in torque control mode, the physical behavior of the motor will tell you what the PID loop is doing wrong. Recognizing these failure signatures saves hours of blind parameter tweaking:
- The Hum (Audible Oscillation): If the motor emits a high-pitched hum or buzz while stationary, the derivative gain (Kd) in the velocity/torque loop is too high, or there is mechanical resonance. The drive is rapidly over-correcting micro-movements. Fix: Reduce Kd by 20%, or enable the drive's notch filter to suppress the specific resonant frequency.
- Overheat (Thermal Shutdown): If the motor casing is too hot to touch (>70°C) and the drive eventually throws an overload alarm, you are operating continuously in the peak torque zone. The RMS torque of your motion profile exceeds the motor's continuous rating. Fix: Upsize the motor, add a gearbox to reduce reflected inertia, or redesign the motion profile to include rest periods.
- Stall / Following Error: The drive faults out with a 'Position Deviation' or 'Following Error' code. This happens when the mechanical load jams, or the commanded acceleration requires more torque than the drive's peak current limit allows. The rotor physically lags behind the magnetic field the drive is generating. Fix: Check for mechanical binding, increase the acceleration ramp time, or verify the electronic gear ratio is not causing command overflow.
For generating the precise pulse trains required to command these drives without jitter, consult the Espressif ESP32 MCPWM peripheral documentation, which details how to configure hardware-level pulse generation independent of the main CPU cores.
Frequently Asked Questions
How do I tune servo motor torque control for high-inertia loads?
For high-inertia loads (inertia ratio > 5:1), standard auto-tuning routines often fail or result in sluggish response. You must switch to manual tuning. Start by setting the integral gain (Ki) to zero and lowering the proportional gain (Kp) until the motor stops oscillating. Gradually increase Kp until you hear a slight hum, then back it off by 15%. Next, slowly introduce Ki to eliminate steady-state error. Finally, apply a low-pass filter to the torque command to prevent high-frequency noise from exciting the mechanical resonance of the heavy load.
Why is my servo motor humming but not moving under torque control mode?
A stationary hum in torque mode usually indicates that the commanded torque is perfectly balanced by the static friction (stiction) of the mechanical system, causing the PID loop to dither back and forth across the zero-crossing. Alternatively, if you are using an analog ±10V command from a microcontroller DAC, electrical noise on the analog line can cause the drive to rapidly switch between slight positive and negative torque commands. Shielded twisted-pair cables and a hardware RC low-pass filter on the analog input are mandatory to cure this.
Can I use an ESP32 to directly drive a servo motor without a dedicated driver?
No. An ESP32 GPIO pins output 3.3V at a maximum of 40mA. An industrial or high-torque hobby servo requires tens to hundreds of amps of switched 3-phase current at high voltages (up to 320V DC bus). Attempting to wire a motor directly to a microcontroller will instantly destroy the MCU and create a severe fire hazard. You must use a dedicated servo drive (for AC servos) or a 3-phase FOC inverter board (for BLDC motors) to handle the power stage, while the ESP32 acts strictly as the low-voltage command signal generator.
What is the difference between torque, velocity, and position control modes in a servo?
In Position Mode, the drive's internal controller manages all three PID loops (position, velocity, torque) to move the shaft to an exact encoder count. In Velocity Mode, the position loop is bypassed; you command an RPM, and the drive modulates torque to maintain that speed regardless of load changes. In Torque Mode, both position and velocity loops are disabled. The microcontroller commands a specific current (and thus, a specific force). The motor will accelerate continuously if the commanded torque exceeds the load friction, making torque mode ideal for applications like web tensioning, capping machines, or compliant robotic grippers where force regulation is more critical than exact placement.






