Hardware

Pulse-Width Modulation

Explore the principles, applications, and technical nuances of PWM through dynamic visualizations and hands-on examples. Learn how this fundamental technique controls power in everything from LED lights to industrial motors.

PWM Explorer

A PWM signal is a digital signal that rapidly switches between ON (High) and OFF (Low). By changing how long the signal is ON versus OFF over a fixed time period, we can control the average voltage. Use the sliders below to see this in action.

The percentage of time the signal is ON in one cycle. This directly controls the average power or voltage.

How many ON/OFF cycles happen per second. Higher frequencies lead to smoother output for many devices.

Resulting Average Voltage

2.50 V

(Assuming a 5V supply)

How PWM is Generated

PWM signals can be created using both analog and digital methods. Digital generation via microcontrollers is most common today due to its precision and flexibility.

Analog Generation

The classic method compares a desired level (Modulating Signal) with a high-frequency carrier wave. The comparator's output is a PWM signal where the pulse width is determined by the intersection points.

Digital Generation

A microcontroller uses a timer/counter. The timer counts from 0 up to a 'period' value. The output is ON until the counter reaches a 'compare' value, which sets the duty cycle.

Timer counts: 0

Period Register = 100

Compare Register (Duty) = 75

Output: HIGH

What is PWM Used For?

PWM's efficiency and precision make it ubiquitous. It's used for controlling power in countless devices, from simple toys to industrial machinery.

đź’ˇ LED Dimming

By rapidly switching an LED on and off, PWM controls its perceived brightness without changing its color.

⚙️ DC Motor Control

PWM controls motor speed by varying the average voltage sent to it. An H-Bridge circuit can also control direction.

🔊 Class-D Audio Amps

A Class-D amplifier converts audio into a high-frequency PWM signal, amplifies it efficiently, then filters it for the speaker.

Sine wave (audio) modulated into a PWM signal

PWM in Context

PWM is one of several ways to modulate a signal using pulses. Understanding its alternatives—PAM and PPM—highlights why PWM is so uniquely suited for power control.

Feature PWM (Width) PAM (Amplitude) PPM (Position)
Modulated Parameter Pulse Width (Duration) Pulse Amplitude (Height) Pulse Position (Timing)
Noise Immunity Good (Amplitude is fixed) Fair (Amplitude noise corrupts signal) Very Good (Amplitude is fixed)
Power Efficiency (Tx) High (Switches are ON/OFF) Low (Requires linear amplification) High (Constant amplitude pulses)
Primary Use Case Power control, motor drives Signal transmission Optical communication, R/C