A PWM (Pulse Width Modulation) speed controller varies the average voltage delivered to a DC motor by rapidly switching the power on and off at a fixed frequency, changing the duty cycle to control speed without wasting energy as heat. What this changes in a real circuit is critical: unlike a simple resistor that drops voltage and starves the motor of current, a PWM controller delivers the full supply voltage during the 'on' pulses. This preserves the magnetic field strength inside the motor, allowing it to maintain high torque even at very low speeds.

The Core Concept: PWM does not actually lower the voltage; it chops the time the voltage is applied. The motor's internal inductance and mechanical inertia smooth out these rapid pulses into a steady, lower average speed.

The Core Mechanism: Duty Cycle and Average Voltage

The speed of a brushed DC motor is directly proportional to the average voltage applied to its terminals. In a PWM speed controller, this average voltage is determined by the duty cycle—the percentage of time the switching element (usually a MOSFET) is turned on during one complete cycle.

The math is straightforward:

V_average = V_supply × (Duty Cycle / 100)

If you are driving a 24V motor from a 24V battery pack and you want the motor to see an average of 18V, you need a 75% duty cycle. The MOSFET turns on for 75% of the cycle and off for 25%.

Switching Frequency Matters: For most DC motor applications, the PWM frequency is set between 1 kHz and 20 kHz. Frequencies below 1 kHz cause audible whining and mechanical vibration. Frequencies above 25 kHz increase switching losses in the MOSFET, generating excess heat without providing any mechanical benefit to the motor.

To generate this signal, microcontrollers like the ESP32 use dedicated hardware peripherals. The ESP32 MCPWM (Motor Control PWM) peripheral handles the high-frequency switching and dead-time insertion automatically, freeing up the CPU for other tasks.

Worked Numeric Example: 12V Motor at 20 kHz

To understand why PWM is the universal standard for motor control, let us look at the thermal math of driving a 12V DC motor that draws 10A at full load. We want to run this motor at 75% speed.

Scenario A: The Linear Resistor Approach (The Wrong Way)

To drop the average voltage from 12V to 9V (75% of 12V) using a series resistor, the resistor must drop 3V while passing 10A.

  • Resistance needed: R = V / I = 3V / 10A = 0.3 Ω
  • Power dissipated as heat: P = I² × R = 100 × 0.3 = 30 Watts

You would need a massive, expensive 50W chassis-mount resistor bolted to a heatsink. The energy is literally burned into the air.

Scenario B: The PWM Controller Approach (The Right Way)

Using a PWM controller with a modern logic-level MOSFET (like the IRFZ44N, which has an Rds(on) of roughly 0.017 Ω at 25°C junction temperature).

  • Conduction loss: When the MOSFET is ON, it passes 10A. P = I² × Rds(on) = 100 × 0.017 = 1.7 Watts.
  • Switching loss: At 20 kHz, the MOSFET spends a tiny fraction of time in the linear region. Assuming a modest 0.5W switching loss.
  • Total heat dissipated: 1.7W + 0.5W = 2.2 Watts.

A standard, $0.50 TO-220 package with a tiny clip-on heatsink handles 2.2W effortlessly. You achieve the exact same 9V average motor speed, but you waste 13 times less energy as heat.

Where You Meet PWM Speed Controllers in Practice

You will encounter PWM speed control in almost every embedded system that moves or pumps. Recognizing the application helps you choose the right frequency and current rating.

  • 3D Printer Extruders and Bed Heaters: The hotend fan and the heated bed are both driven by PWM. The bed heater uses a very low frequency (around 10-50 Hz) because the thermal mass of the aluminum plate acts as the low-pass filter, while the fan uses 25 kHz to remain silent.
  • RC Crawlers and Rock Racers: These rely on PWM ESCs (Electronic Speed Controllers) to deliver massive torque at 5% duty cycle, allowing the vehicle to inch over obstacles without stalling the motor.
  • Solar Water Pumps: A PWM controller matches the high-voltage, low-current output of a solar panel's Vmp (Maximum Power Point) to the lower-voltage, high-current requirement of a 12V or 24V diaphragm pump.
  • CNC Router Spindles: Brushed DC spindle motors use high-current PWM controllers to maintain RPM under cutting loads by dynamically adjusting the duty cycle based on tachometer feedback.

Common Confusions: What PWM is NOT

When sourcing parts or reading motor control tutorials, beginners frequently mix up three distinct technologies. Clearing this up prevents catastrophic hardware failures.

1. PWM vs. Linear Voltage Regulators (LDOs/Buck Converters):
A buck converter actually steps down the voltage continuously using an inductor. A PWM motor controller just chops the raw supply voltage. Do not use a standard buck converter module to run a high-inertia DC motor; the motor's regenerative braking (back-EMF) will push voltage back into the buck converter's output, often blowing its output capacitors.
2. PWM DC Controllers vs. VFDs (Variable Frequency Drives):
A PWM DC controller changes the duty cycle to control a brushed DC motor. A VFD changes both the voltage and the AC frequency (Hz) to control an AC induction motor. You cannot use a DC PWM controller on an AC treadmill motor, and you cannot use a VFD on a 12V DC scooter motor.
3. Open-Loop PWM vs. Closed-Loop ESCs:
A basic PWM module just sends the pulses you command. If the motor hits a physical load, it slows down. A closed-loop ESC (like those used in drones) reads the motor's back-EMF or uses a Hall-effect sensor to actively adjust the PWM duty cycle thousands of times a second to maintain a target RPM regardless of load.

Decision Tree: Selecting Your PWM Controller Module

Choosing the right hardware depends entirely on your continuous current draw and supply voltage. Use this decision matrix to pick your driver. For a comprehensive breakdown of driver ICs, the SparkFun Motor Driver Selection Guide is an excellent benchmark.

If Your Load Is... And Your Voltage Is... Then Choose This Architecture Concrete Part / Module Pick
< 2A Continuous 5V - 12V Dual H-Bridge IC (Integrated logic and MOSFETs) TB6612FNG (Efficient, low heat, replaces the outdated L298N)
2A - 10A Continuous 12V - 24V Discrete MOSFET H-Bridge Module Monster Moto Shield (Uses VNH2SP30 chips, excellent thermal pads)
10A - 30A Continuous 12V - 24V High-Power Half-Bridge / H-Bridge Module IBT-2 Module (Dual BTS7960 chips, massive current handling)
> 30A Continuous 24V - 48V Custom PCB with Parallel Logic-Level MOSFETs Custom board using IRF3205 MOSFETs with dedicated gate drivers (e.g., IR2104)
The Default High-Power Pick: If you are building a typical DIY robotics project, an automated gate opener, or a heavy-duty linear actuator driver in the 12V-24V range, stop looking and buy the IBT-2 module (based on the Infineon BTS7960). It handles up to 43A peak, features built-in optocouplers to protect your microcontroller from ground loops, and costs around $8 to $12. It is the undisputed workhorse of high-current DIY PWM control.

Frequently Asked Questions

Do I need a flyback diode if my PWM module already has them?
Most dedicated motor driver modules (like the IBT-2 or TB6612FNG) include internal Schottky flyback diodes to clamp inductive kickback. However, if you are building a custom MOSFET circuit on a breadboard or perfboard, you must add an external fast-recovery or Schottky diode (like the 1N5819 or MBR2045) across the motor terminals. Failing to do so will cause the motor's back-EMF to avalanche the MOSFET, destroying it instantly on the first off-cycle.

Why does my motor whine loudly at low speeds?
Your PWM frequency is likely set too low (e.g., 490 Hz, which is the default for many standard Arduino `analogWrite()` pins). The motor windings are physically vibrating at that acoustic frequency. Move your PWM signal to a hardware timer pin and increase the frequency to at least 16 kHz to push the whine above the range of human hearing.

Can I use a PWM speed controller for a brushless (BLDC) motor?
No. A standard DC PWM controller only switches a single high-side or low-side path. A BLDC motor requires a 3-phase inverter and a commutation algorithm (like trapezoidal or FOC) to energize the stator coils in sequence. You need a dedicated BLDC ESC, not a simple PWM DC speed controller.