Skip to content
MoneyDeck

PWM Duty Cycle Calculator

Duty cycle, pulse width, frequency and average voltage of a PWM signal

Updated · Free, no signup

ms
ms
V
V

Duty cycle

25%

Frequency

1,000 Hz

Period

1 ms

On time

0.25 ms

Off time

0.75 ms

Average (DC) voltage

1.25 V

RMS voltage

2.5 V

8-bit PWM value (0–255)

64

Value for analogWrite() on an 8-bit PWM pin.

  • The signal is high for 250 µs of every 1 ms period, a 25% duty cycle at 1 kHz.
  • A low-pass filter or a slow load (motor, heater) sees about 1.25 V on average.

Average voltage at common duty cycles

Duty cycle8-bit valueAverage voltage (V)
5%130.25
10%260.50
25%641.25
50%1282.50
75%1913.75
90%2304.50
100%2555

About the PWM Duty Cycle Calculator

This PWM duty cycle calculator turns any two pieces of information about a pulse-width-modulated signal into the full picture: duty cycle in percent, period, frequency, high and low times, the average (DC-equivalent) voltage and the RMS voltage. You can start from the measured on and off times, from the frequency plus pulse width you see on a scope, or from a frequency and the duty cycle you want to set.

It is aimed at makers dimming LEDs or driving motors from a microcontroller, students working through digital-electronics exercises, and technicians reading oscilloscope traces. The 8-bit value output tells you what to pass to an Arduino-style analogWrite() call to get the same duty cycle.

The math assumes an ideal rectangular waveform that switches instantly between a high and a low level. Real signals have finite rise and fall times and the load (a motor winding, an LED driver, an RC filter) determines what voltage the circuit actually experiences, so treat the average voltage as the DC component of the waveform rather than a guaranteed load voltage.

With the default inputs, the duty cycle is 25%. Change any value above to recalculate instantly.

How to use the pwm duty cycle calculator

  1. 1Choose what you already know: on/off times, frequency and pulse width, or frequency and duty cycle.
  2. 2Enter the times in milliseconds (0.001 ms = 1 µs) or the frequency in hertz.
  3. 3Enter the high and low voltage levels of the signal (low is usually 0 V).
  4. 4Read the duty cycle, period, frequency and average voltage.
  5. 5Use the 8-bit value to set the same duty cycle with analogWrite().

Formula and method

D = t_on ÷ T × 100% · T = t_on + t_off = 1 ÷ f · V_avg = D·V_H + (1 − D)·V_L · V_rms = √(D·V_H² + (1 − D)·V_L²)

Duty cycle is the fraction of each period that the signal spends in its high state. The period T is the sum of the on and off times, or the reciprocal of the frequency. Multiply the high time by the frequency (or divide it by the period) to get D.

For an ideal rectangular wave the average voltage is the time-weighted mean of the two levels, D·V_H + (1 − D)·V_L, which is what an RC low-pass filter or a slow-responding load settles to. The RMS value, which sets heating in a resistive load, is the square root of the time-weighted mean of the squared levels. The 8-bit PWM value is D × 255 rounded to the nearest whole number.

D
Duty cycle (fraction or percent)
t_on, t_off
Time high and time low in one period
T
Period (s)
f
Frequency (Hz) = 1/T
V_H, V_L
High and low signal levels (V)

Worked examples

0.25 ms on, 0.75 ms off at 5 V

The period is 0.25 + 0.75 = 1 ms, so the frequency is 1 kHz and the duty cycle is 0.25 ÷ 1 = 25%. The average voltage is 25% of 5 V = 1.25 V, the RMS value is 5 × √0.25 = 2.5 V, and 0.25 × 255 = 63.75 rounds to an 8-bit value of 64.

20 kHz motor PWM with a 35 µs pulse at 12 V

At 20 kHz the period is 1 ÷ 20,000 = 50 µs. A 35 µs pulse is 35 ÷ 50 = 70% duty, so the motor sees an average of 0.7 × 12 = 8.4 V and the RMS voltage is 12 × √0.7 ≈ 10.04 V. For an 8-bit timer, 0.7 × 255 = 178.5 rounds up to 179.

Arduino 490 Hz pin at 40% duty

A 490 Hz PWM pin has a period of 1 ÷ 490 ≈ 2.041 ms. At 40% duty the pin is high for about 0.816 ms and low for 1.224 ms, averaging 2 V from a 5 V supply. analogWrite(pin, 102) gives that duty cycle.

Frequently asked questions

What is duty cycle?+

Duty cycle is the percentage of each period that a pulsed signal is on (high). A 50% duty cycle square wave is high half the time; 10% means a short pulse followed by a long off time.

How do I calculate duty cycle from frequency and pulse width?+

Multiply the pulse width by the frequency. For example a 200 µs pulse at 1 kHz gives 200e-6 × 1000 = 0.2, or 20% duty. Equivalently, divide the pulse width by the period (1/f).

What is the average voltage of a PWM signal?+

For a signal switching between 0 V and V_high, the average is duty cycle × V_high. A 5 V signal at 60% duty averages 3 V, which is what an RC filter or a slow load such as a motor responds to.

Why is RMS voltage higher than average voltage for PWM?+

RMS weights the voltage by its square, which reflects heating power. For a 0 V/V_high PWM signal V_rms = V_high × √D, which is always at least the average D × V_high when D is between 0 and 1.

What PWM frequency should I use?+

LED dimming usually uses several hundred hertz to a few kilohertz to avoid flicker, while motor drives often run at 20 kHz or more to stay above hearing. Higher frequencies increase switching losses in the transistor.

Related tools