Electrical
Pulse Width Modulation
Switching a square wave on and off to deliver variable average power
Pulse Width Modulation (PWM) controls the average power delivered to a load by rapidly switching a digital signal between on and off states. The duty cycle (fraction of time on) sets the average output voltage. PWM is ubiquitous in motor speed control, LED dimming, switching power supplies, and audio amplification. Switching frequency is chosen well above the load's response bandwidth so the load filters the pulses into a smooth average. Efficiency is high because transistors operate either fully on (low V_CE) or fully off (no current), minimizing dissipation compared to linear regulation.
- Duty cycleD = t_on / T (0 to 1)
- Average voltageV_avg = D × V_supply
- Switching frequencykHz to MHz typical
- Efficiency90%+ vs ~50% linear
- Used forMotors, LEDs, SMPS, audio
- Resolution8 to 16 bits common
Interactive visualization
Press play, or step through manually. The visualization is yours to drive — try it before reading on.
Watch the 60-second explainer
A condensed visual walkthrough — narrated, captioned, under a minute.
Why PWM matters
- Motor control. Variable speed drives, robotics, EVs.
- Power supplies. Buck, boost, flyback, forward converters.
- LED lighting. Dimming without changing color temperature.
- Audio. Class D amplifiers in everything from earbuds to subwoofers.
- Heating. Industrial process control, 3D printer beds.
- Servos. Pulse width encodes position command.
- Microcontrollers. Built-in PWM peripherals on every modern MCU.
Common misconceptions
- Same as variable voltage. Output is square wave; load filters to average.
- Frequency doesn't matter. Too low: visible flicker, audible whine. Too high: switching losses.
- Always efficient. Switching edges dissipate energy; very high frequency hurts efficiency.
- Linear with duty cycle. True for ideal loads; real motors and LEDs have nonlinearities.
- No filtering needed. Many loads (audio, DC supplies) require LC filter.
- Causes no EMI. Sharp edges radiate; layout and filtering matter.
Frequently asked questions
What's PWM?
A digital signal alternating between high and low at fixed frequency. The fraction of time spent high is the duty cycle. Average voltage equals duty cycle times supply voltage. Loads with sufficient inertia or low-pass filtering see only the average. The transistor is either saturated or cut off, so power dissipation is low.
Why use it instead of a linear regulator?
Efficiency. A linear regulator drops voltage across a transistor, dissipating (V_in - V_out) × I as heat. PWM switches fully on or off, so transistor losses are small. Going from 12V to 5V at 1A: linear wastes 7W, PWM wastes under 1W. Critical for battery-powered devices.
How is the switching frequency chosen?
Above the load's response bandwidth and human perception thresholds. Motors: 10-30 kHz to avoid audible whine. LEDs: above 100 Hz to avoid flicker, often higher to prevent visible artifacts in video. SMPS: 100 kHz to several MHz for small inductors. Higher frequency means smaller filter components but more switching losses.
How does it dim an LED?
LEDs respond instantly to current; they can't average voltage themselves. PWM switches the LED on and off faster than the eye can detect (typically over 200 Hz). Perceived brightness scales with duty cycle. Cheap and simple, but PWM dimming can cause flicker on cameras or with stroboscopic motion if the frequency is too low.
Why does it need an inductor for power supplies?
Buck and boost converters use an inductor to store energy during the on phase and release it during off, smoothing pulses into DC. The inductor resists current changes. Without it, you'd get a harsh square wave at the output. Capacitor on output filters the inductor's ripple current to deliver clean DC.
What's a class D amplifier?
An audio amplifier using PWM. The audio signal modulates the duty cycle of a high-frequency carrier. A passive LC filter at the output removes the carrier, leaving only the audio. Efficiency exceeds 90%, vs about 50% for class AB linear amplifiers. Used in subwoofers, modern home theater receivers, and most portable speakers.
What are the downsides?
Electromagnetic interference from sharp switching edges can radiate into nearby circuits. Switching transistors generate heat at edges (switching losses) that grows with frequency. Audible whine if frequency falls in human hearing range. Filter components add cost and size. Some loads (resistive heaters) don't need PWM—simple thyristor phase control works.