PWM Duty Cycle
Turns the on-time and off-time of a pulse-width-modulated (PWM) signal into its duty cycle, switching frequency, period and average voltage. Use it to read a waveform off an oscilloscope, to set up a microcontroller timer, or to estimate what a motor, heater, fan or LED will see from a PWM drive.
Equations
T = Ton + Toff D = Ton / T f = 1/T Vavg = D·Vpeak
Ton is the time the output is high in each cycle and Toff the time it is low. Their sum is the period T, and f is the switching frequency in hertz. The duty cycle D is the fraction of each period spent on, shown as a percentage. Vpeak is the voltage of the high level, with the low level taken as 0 V. The average voltage is the mean of the square wave over one period. It is the voltage a load sees once an inductor, a capacitor or its own inertia smooths the pulses, as in a buck converter or a motor speed drive [1].
Limits and common mistakes
- Vavg is not the RMS voltage. Heating in a resistor depends on RMS, which is Vpeak·√D for this waveform. At 25 % duty a heater gets 25 % of full power, not the 6 % that (Vavg/Vpeak)² would suggest.
- The page assumes an ideal square wave. Real edges have rise and fall times, and a switch drops some voltage when on, so the real average is a little lower.
- Some loads do not respond to the average. An LED’s brightness follows the duty cycle, but a motor with too low a switching frequency jerks and whines instead of running smoothly.
- Check the units of Ton and Toff. A mix of microseconds and milliseconds gives a frequency off by a factor of 1000.
Worked example
A 12 V four-wire computer fan is driven by the standard 25 kHz PWM signal. The scope shows the signal high for 14 µs and low for 26 µs. What speed setting is the controller asking for, and is the frequency right?
- Enter On time (Ton) 14 µs.
- Enter Off time (Toff) 26 µs.
- Enter Peak voltage (Vpeak) 12 V and press Solve. The Solution shows:
Duty cycle (D): 35 %
Switching frequency (f): 25,000 Hz
Period (T): 4e-5 s
Average voltage (Vavg): 4.2 V
The period of 4e-5 s is 40 µs. Check by hand: 14 + 26 = 40 µs, so f = 1/40 µs = 25 kHz, as the fan expects. D = 14/40 = 35 %, and 0.35 × 12 = 4.2 V. The controller is asking for about a third of full speed.