PWM Duty Cycle Calculator – On/Off Time & Average Voltage

PWM Duty Cycle Calculator

Find PWM duty cycle three ways: from on-time and period using D = T_on / T_period times 100, from timer registers with D = CCR / (TOP + 1), or from a target average voltage with D = V_avg / V_supply. Get the duty percent, on-time, off-time, and average output voltage for motors, LEDs, servos, and heaters.

🔌Choose a Mode

🎯Real PWM Setup Presets

📝PWM Inputs

Switching rate; period T = 1 / frequency.

Applies to the frequency field above.

High time of the pulse within one period.

Applies to the on-time field above.

Timer compare register that sets on-time counts.

Period equals TOP + 1 counts; D = CCR / (TOP + 1).

Desired filtered output; D = V_avg / V_supply.

High-level rail driving the load.

Controls rounding on every result card.

Duty Cycle 0 % fraction of period that is high
On-Time T_on 0 ms high time per period
Off-Time T_off 0 ms low time, T minus T_on
Average Output Voltage 0 V D/100 times supply

🔢Formula Snapshot

DTon / T × 100
TonD/100 × T
D regCCR / (TOP+1)
VavgD/100 × Vs

📋On-Time and Period to Duty Cycle

On-Time T_onPeriod TDuty D = Ton / TReads As
1 ms20 ms5%Servo minimum
1.5 ms20 ms7.5%Servo center
2 ms20 ms10%Servo maximum
2.5 us10 us25%Quarter on
5 us10 us50%Square, half on
7.5 us10 us75%Three-quarter on
9 us10 us90%Nearly always on
0 msany0%Fully off

📊Register CCR / TOP to Duty Cycle

CCR (compare)TOP (ARR)Period CountsDuty = CCR / (TOP+1)Resolution
12825525650.0%8-bit
6425525625.0%8-bit
19125525674.6%8-bit Arduino
5121023102450.0%10-bit
700999100070.0%STM32 1000
20484095409650.0%12-bit
32764095409680.0%12-bit

Average Voltage and Power by Duty

Duty DV_avg at 5 VV_avg at 12 VRMS at 5 V (resistive)Power Fraction
10%0.50 V1.20 V1.58 V10%
25%1.25 V3.00 V2.50 V25%
40%2.00 V4.80 V3.16 V40%
50%2.50 V6.00 V3.54 V50%
66%3.30 V7.92 V4.06 V66%
75%3.75 V9.00 V4.33 V75%
100%5.00 V12.0 V5.00 V100%

📏Frequency, Period, and Time Units

FrequencyPeriod T = 1 / fIn SecondsNote
50 Hz20 ms0.02 sServo frame
490 Hz2.04 ms0.00204 sArduino default
1 kHz1 ms0.001 sGeneral LED
20 kHz50 us0.00005 sQuiet motor drive
100 kHz10 us0.00001 sBuck converter
1 us1 MHz0.000001 s1 us equals 1 MHz

🗃Duty Cycle Comparison Grid

ApplicationFrequencyPeriod TOn-TimeOff-TimeDuty DV_avg (5 V)
Servo min50 Hz20 ms1.0 ms19.0 ms5%0.25 V
Servo center50 Hz20 ms1.5 ms18.5 ms7.5%0.38 V
Servo max50 Hz20 ms2.0 ms18.0 ms10%0.50 V
LED dim1 kHz1 ms0.25 ms0.75 ms25%1.25 V
LED half1 kHz1 ms0.5 ms0.5 ms50%2.50 V
Motor drive20 kHz50 us37.5 us12.5 us75%3.75 V
Heater1 kHz1 ms0.4 ms0.6 ms40%2.00 V
Buck 3.3 V100 kHz10 us6.6 us3.4 us66%3.30 V
STM32 CCR7001 kHz1 ms0.7 ms0.3 ms70%3.50 V
Full onanyTT0100%5.00 V

Formula Breakdown

Duty D = Ton / T × 100Duty cycle is the high time divided by the full period, as a percent. A 1.5 ms pulse in a 20 ms frame gives D = 1.5 / 20 × 100 = 7.5%.
Period T = 1 / fThe period is the reciprocal of the PWM frequency. At 50 Hz, T = 1 / 50 = 0.02 s = 20 ms. At 1 kHz, T = 1 ms.
On-time Ton = D/100 × TRearrange to find the pulse width. 25% duty at a 1 ms period gives Ton = 0.25 × 1 = 0.25 ms high time.
Off-time Toff = T − TonWhatever is left of the period is low. With T = 1 ms and Ton = 0.25 ms, Toff = 1 − 0.25 = 0.75 ms.
Register D = CCR / (TOP + 1)In a timer the period is TOP + 1 counts. CCR = 700 with TOP = 999 gives D = 700 / 1000 = 70%.
Avg voltage Vavg = D/100 × VsInto a filtered or inductive load the mean output is duty times supply. 66% of 5 V gives Vavg = 3.3 V.
RMS = Vs × sqrt(D/100)For a square wave into a resistive load the heating RMS voltage is supply times the square root of duty. At 50% of 5 V, RMS = 5 × 0.707 = 3.54 V.

💡Practical PWM Tips

Servo pulses live in a narrow band: A standard hobby servo expects a 1.0 to 2.0 ms pulse inside a 20 ms (50 Hz) frame, which is only 5% to 10% duty. Center is about 1.5 ms, or 7.5%. Because the useful range is so small, drive servos with pulse width in microseconds rather than a raw 0 to 100% duty knob, or you waste almost all of your resolution.
Average voltage needs filtering: The Vavg = D/100 times supply result only appears as a smooth DC level if the load integrates the pulses, such as a motor winding, an LED with your eye, or an RC low-pass filter. To make 3.3 V from a 5 V rail you set D = 3.3 / 5 = 66%, but a bare resistor still sees 5 V pulses whose heating RMS is 5 times sqrt(0.66) = 4.06 V, not 3.3 V.

The way pulse width modulation functions is to turn a voltage on and off rapidy. To your eye… Or to some sort of mechanical load, it appear as an average effect rather than the choppy reality. The duty cycle is a single number that describes what’s happening. It represent how long the signal remains in high state during any given cycle. Simply divide the on-time by the overall period to get it.

As a developer, when you’re debugging your code it’s annoying to have to do this math by hand. That’s why the calculator above do the arithmetic for you. Now you can concentrate on whether your timing is even reasonable for your hardware.

How to Calculate Pulse Width Modulation Duty Cycle

Duty cycle is simply a ratio in terms of a percentage. A one-kilohertz switch take place every millisecond. So if the voltage is held high for half that period, your duty cycle is fifty percent. This creates a square wave where there’s an equal amount of on and off time. Hold it high for a quarter of a millisecond and your duty decreases to twenty-five percent.

But you can see here that the period are the reciprocal of frequency. So while you’ve increased the speed of the switching, the window during which that percentage applies has changed. This is why people often mistakenly think that a faster switch means brighter or somehow increases power. It doesn’t.

A microcontroller doesn’t typically allow you to specify a period directly in milliseconds or seconds. Rather, it’s got integer counters that increment until reaching some limit. That’s why there’s this business with registers and modes. In register mode, you load a top value (TOP), which specifies the number of ticks that comprise one complete period, then you specify a compare value (usually referred to as CCR) that indicates when output should flip high or low. Your duty cycle is equal to the compare value divided by the top value… But notice it has to be the top value +1 because the counter count from 0 on up! Omitting that extra count will throw off your calculation slightly. When you’re attempting to dead-center a servo, it becomes not so small.

Finally, work backwards from the voltage. You might want some other analog voltage, say, three point three volts for compatibility with some logic system… And all you’ve got is five-volt rail. If the load averages in the pulses it’s not hard to pretend you’re generating that kind of DC voltage using PWM. Feed it through a motor winding, or an RC filter to smooth out the spikes, and the resulting average is just supply voltage times the duty cycle. Sixty-six percent duty gets you down to three point three from five. At whatever switching rate you choose, the tool figures it out immediately, displaying the precise pulse width needed to get there.

It makes clear a subtle trick about power dissipation, too. Root mean square voltage is not the same as average voltage. The RMS value plays into how much energy are delivered by a waveform to a resistive load such as a heater element or a coil. In other words, for heating, it’s all about the square root of the duty cycle. Is it a fifty percent duty cycle? The RMS voltage will be about seven tenths times the supply voltage, whereas the average voltage would be half the supply. That means the heat produced do not increase at the same rate than the average voltage measured on the load. Knowing this difference lets you avoid over-estimating the thermal stress in your design. It is a subtle point, but it matters when things get hot.

Servo motors are special: they have an extremely narrow duty range. They will accept a pulse anywhere from one to two milliseconds in a twenty-millisecond frame. In percentage terms, that’s just five to ten percent! That’s the whole control window located at the very low end of the percentage scale. Attempting to control them with a generic zero-to-one-hundred slider wastes most of your resolution. Clicking on the preset buttons in the calculator will help you imagine what small differences in microseconds look like in terms of position change. It makes you realize that for servos, time is more intuitive when it’s absolute rather than relative duty.

That’s just a practical compromise between frequency choices. Typically, you’ll see motors running around twenty kilohertz. That frequency is high enough to move audible sound out of range for our ears and also make for smaller filters. But it means more electromagnetic interference and higher transistor losses due to faster switching. On the other hand, lower frequencies will buzz motors or flicker lights, but are easier to handle. To choose a good middle ground for your use, use the reference tables from that page, which match popular frequencies with their corresponding period. You want fast enough to be smooth, but slow enough to stay cool.

At its heart, PWM’s all about trading continuous control for digital precision. You’re chopping up the voltage finely, but you aren’t changing it smoothly. To get the chop right, you need to know your load type, your compare registers, and your period. Knowing that stuff can save you hours of trial and error when you’re trying to size a capacitor on a power supply or debug a microcontroller timer. It’s just a matter of numbers and the math’s easy if you lay it out, but it’s difficult to keep straight in your head as you’re wiring up a prototype. Let the tool do the dividing so you can concentrate on the circuit.

PWM Duty Cycle Calculator – On/Off Time & Average Voltage