Circuit fundamentals
PWM average voltage
Also called: pulse-width modulation · duty cycle · analogWrite
Definition
Pulse-width modulation switches a signal fully on and off quickly; the fraction of time it is on, the duty cycle, sets the average voltage delivered.
Picture it
A motor or LED is too slow to follow fast switching, so it responds to the average. 25 % on-time from a 12 V supply looks like 3 V. Because the switch is either fully on or fully off it wastes little power, unlike a resistor dropping the extra voltage.
The maths
duty D = t_on / T V_avg = D × V_supply f = 1 / T
| Quantity | Unit | Symbol |
|---|---|---|
| voltage | volt | V |
| percentage | per cent | % |
| frequency | hertz | Hz |
| time | second | s |
Worked example
A 12 V motor driver runs at 20 kHz with a 40 % duty cycle. What is the period, the on-time and the average voltage?
- T = 1 / 20000 = 0.00005 s = 50 µs
- t_on = 0.40 × 50 = 20 µs
- V_avg = 0.40 × 12 = 4.8 V
AnswerT = 50 µs, on for 20 µs, average 4.8 V.
✓ The 3 numbers in this answer are recomputed from scratch by an automated test.
Common misconceptions
- Misconception: PWM is not a true analogue voltage; a scope shows full-height pulses.
- Misconception: Changing PWM frequency does not change the average; duty cycle does.