PWM Explorer
This is the heart of PWM. 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, but understanding the analog method provides core insight.
Analog Generation
The classic analog method compares a desired analog level (Modulating Signal) with a high-frequency carrier wave (like a sawtooth or triangle 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 pin is turned ON at the start and turned OFF when 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. Explore some common applications below.
đź’ˇ LED Dimming
By rapidly switching an LED on and off, PWM controls its perceived brightness without changing its color, which can happen with analog dimming. The eye averages the light pulses.
⚙️ DC Motor Control
PWM controls motor speed by varying the average voltage sent to it. An H-Bridge circuit is often used with PWM to also control the motor's direction.
🔊 Class-D Audio Amps
A Class-D amplifier converts an analog audio signal into a high-frequency PWM signal. This signal is amplified efficiently and then filtered to reproduce the original audio sound for a 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—Pulse Amplitude Modulation (PAM) and Pulse Position Modulation (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 directly corrupts signal) | Very Good (Amplitude is fixed) |
Power Efficiency (Tx) | High (Switches are ON/OFF) | Low (Requires linear amplification) | High (Pulses have constant amplitude) |
Primary Use Case | Power control, motor drives | Signal transmission | Optical communication, R/C |