Core definitions
| Duty cycle D | = t_on / T (fraction of period the signal is high) |
|---|---|
| Frequency f | = 1 / T |
| Average V | = D · V_high (if V_low = 0) |
| Resolution | = log₂(period in timer ticks) |
| Average power | P = D · V² / R (into resistive load) |
Typical frequencies
| Use | Frequency | Rationale |
|---|---|---|
| LED dimming (visible) | 200 Hz – 2 kHz | Above flicker threshold |
| LED dimming (camera-safe) | > 5 kHz | Avoid rolling shutter stripes |
| Motor control (low) | 10–25 kHz | Above audible range |
| BLDC / ESC | 8–32 kHz | Balance switching loss vs noise |
| DC-DC converters | 100 kHz – 2 MHz | Smaller passives at higher f |
| Audio D-class amp | ~400 kHz | Beyond audio band |
Smoothing to DC
- LC or RC filter with corner well below PWM frequency (f_c < f_pwm / 10) gives a clean DC average.
- Resolution matters: 8-bit PWM = 256 steps, 0.39% per LSB; 10-bit = 0.1% per LSB.
- Slew-rate limits: fast PWM edges cause EMI; add small series resistor or use slew-rate-limited gate drive.
- Fan / motor: DC average drives the load; at very low duty, startup torque may be insufficient — use min-duty floor.
Worked examples
Average power: a 12 V supply switched at 30% duty into a 6 ohm heater delivers P = D × V²/R = 0.30 × 144 / 6 = 7.2 W. The average voltage is 0.30 × 12 = 3.6 V, but the RMS voltage is √0.30 × 12 = 6.57 V, and the power follows the RMS value (6.57² / 6 = 7.2 W). This is why power into a resistive load is linear in duty cycle, while average voltage alone would give the wrong answer (3.6² / 6 = 2.2 W).
Resolution versus frequency: a 16 MHz timer clocked directly gives 16,000,000 / 20,000 = 800 steps at 20 kHz, about 9.6 bits. An 8-bit PWM (256 steps) at the same clock runs at up to 16,000,000 / 256 = 62.5 kHz. Doubling the frequency halves the number of steps, so a faster PWM costs resolution unless the timer clock is faster.
Filtering to DC: a 5 V PWM at 50% duty and 1 kHz through R = 10 kilohms and C = 1 µF (τ = 10 ms) gives 2.5 V with ripple of about V × D(1 − D) × T/τ = 5 × 0.25 × 1 ms / 10 ms = 0.125 V peak-to-peak. It takes about 5τ = 50 ms to settle after a duty change. Lower ripple needs a larger τ or a higher PWM frequency, and both trade against response time.
Choosing a frequency
- Go high enough to be inaudible and invisible, low enough that switching loss stays small. For motors, 16 to 25 kHz avoids whine; for LEDs, a few hundred hertz is the bare minimum and several kilohertz is better for cameras.
- Inductive loads smooth the current themselves. A motor winding with L/R much longer than the PWM period sees nearly constant current, so higher frequency means less current ripple and less heating.
- Dead time matters in half-bridges. Both switches must never conduct together. The gap needed for safe switching sets a minimum on-time and distorts duty near 0% and 100%.