Research Careers Contact

GlossaryPulse width modulation

Pulse width modulation

Pulse width modulation, or PWM, is a way of controlling average power, or sending a value, by switching a signal fully on and off at a fixed frequency and varying how long it stays on in each period. The fraction of each period spent on is the duty cycle. A 25 percent duty cycle on a 12 V supply delivers an average of 3 V to a load that smooths it.

How it works

A timer in a microcontroller counts at a fixed rate and compares the count with a set value. The output stays high until the count passes that value, then stays low until the period ends. Changing the compare value changes the duty cycle, and changing the timer's top value changes the frequency.

In power electronics, PWM drives the transistors in a motor driver or DC-DC converter. Because each transistor is either fully on or fully off, it wastes little power, unlike a transistor that drops voltage across itself in its linear region. The motor winding or the converter's inductor smooths the switched voltage into a steady current. A three-phase motor drive generates PWM on six transistors at once, with dead time between the high-side and low-side switch of each leg so both are never on together.

PWM is also a signaling method. Traditional servo and ESC inputs read the width of each pulse, repeated at a fixed rate, as the commanded position or throttle. PX4's guides to PWM ESCs and actuator setup describe how these outputs are wired, assigned and calibrated, and digital protocols such as DShot replace the pulse width with digital frames.

PWM vs analog output

An analog output sets a steady voltage directly, through a digital-to-analog converter or a linear stage. PWM produces only on and off levels and relies on the load or a filter to average them. PWM is cheaper, more efficient and available on nearly every microcontroller. Analog output avoids switching noise and ripple, which matters for precise references and audio.

Why it matters

PWM frequency and edge speed set much of a power board's behavior. A low frequency gives audible whine and current ripple in motors. A high frequency raises switching losses and heat in the transistors. Fast edges cut those losses but create the voltage spikes and noise behind EMI problems, and that noise disturbs nearby sensors.

How to get it right

  • Choose a switching frequency that balances ripple, audible noise and transistor losses.
  • Set dead time from the gate driver and transistor timing, with margin.
  • Control edge rates with gate resistors where noise is a problem.
  • Keep PWM power paths short and away from sensor lines and encoder signals.
  • Filter PWM outputs that feed analog circuits.
  • Check the output assignment, rate and range for each servo or ESC before first power-up.

PWM in robotics and drone hardware

Every motor in a robot or drone runs on PWM inside its driver, and many drones command their ESCs with PWM pulses from the flight controller. PX4's guide to PWM ESCs notes that every setup needs the signal ground connected along with the PWM signal. Board layout around the switching stages, and the power integrity of nearby rails, decide whether the rest of the electronics sees clean power and quiet signals.

Learn more