TSE.
MathematicsFinanceHealthPhysicsEngineeringBrowse all

Engineering · Electrical Engineering · Signal Processing

PWM Duty Cycle Calculator

Calculates PWM duty cycle, on-time, off-time, frequency, and average output voltage from pulse width modulation parameters.

Calculator

Advertisement

Formula

D is the duty cycle (%), t_on is the on-time (s), T is the total period (s), f is the PWM frequency (Hz), V_avg is the average output voltage (V), and V_high is the high-level supply voltage (V). The off-time is t_off = T − t_on.

Source: Horowitz & Hill, The Art of Electronics, 3rd Edition; IEEE Std 1346-1998.

How it works

Pulse Width Modulation (PWM) is a method of encoding information or controlling power by varying the width of pulses in a fixed-frequency square wave. The duty cycle is the ratio of the on-time (t_on) to the total period (T), expressed as a percentage. A 50% duty cycle means the signal is high for exactly half the period; a 100% duty cycle means the signal is continuously high. PWM is used extensively in switching power supplies, servo motor control, class-D amplifiers, and LED brightness control because it is highly energy-efficient compared to linear regulation.

The core relationships are straightforward: the period T is the reciprocal of frequency (T = 1/f), the duty cycle D = (t_on / T) × 100%, and the off-time is simply t_off = T − t_on. For a digital PWM signal switching between 0 V and a supply voltage V_high, the time-averaged output voltage is V_avg = D × V_high. This average voltage is what a downstream low-pass filter or inductive load sees, making duty cycle the primary control knob for output power. For example, at D = 75% and V_high = 12 V, the average voltage delivered is 9 V.

Engineers use PWM duty cycle calculations in a wide range of practical applications: microcontroller timer configuration (determining compare register values), motor speed control (varying torque output by adjusting average voltage), SMPS design (setting output voltage via feedback-controlled duty cycle), and audio/lighting applications where perceived intensity is modulated. Understanding the relationship between on-time, period, and average voltage is critical for correct circuit behavior and efficiency optimization.

Worked example

Given: A PWM signal with a frequency of 1 kHz, an on-time of 0.5 ms, and a high-level voltage of 5 V.

Step 1 — Calculate the period:
T = 1 / f = 1 / 1000 Hz = 1 ms

Step 2 — Calculate the duty cycle:
D = (t_on / T) × 100% = (0.5 ms / 1 ms) × 100% = 50%

Step 3 — Calculate the off-time:
t_off = T − t_on = 1 ms − 0.5 ms = 0.5 ms

Step 4 — Calculate the average output voltage:
V_avg = D × V_high = 0.50 × 5 V = 2.5 V

This result confirms that a 50% duty cycle at 5 V produces an average of 2.5 V — exactly half the supply rail, as expected. Now suppose we increase the on-time to 0.8 ms: D = (0.8/1) × 100% = 80%, and V_avg = 0.80 × 5 V = 4.0 V. This demonstrates how increasing the duty cycle directly raises the effective output voltage.

Limitations & notes

This calculator assumes an ideal rectangular PWM waveform with instantaneous rise and fall times, which is an approximation for real circuits. In practice, gate driver propagation delays, MOSFET switching times, and RC time constants introduce dead time and waveform distortion, particularly at high frequencies (above ~100 kHz). The average voltage formula V_avg = D × V_high is valid only when the load acts as a low-pass filter (e.g., a motor winding or RC circuit) — it does not represent instantaneous voltage. Additionally, at very low duty cycles, minimum on-time constraints imposed by controller ICs may prevent the signal from reaching the computed value. The calculator does not account for shoot-through, body diode conduction in H-bridges, or power losses in switching devices. For duty cycles calculated as less than 0% or greater than 100% (which would indicate invalid input combinations), results should be disregarded.

Frequently asked questions

What is duty cycle in PWM and why does it matter?

Duty cycle is the percentage of one period during which a PWM signal is in the high (on) state. It directly controls the average power or voltage delivered to a load — a higher duty cycle means more energy per cycle. This is why PWM is used to control motor speed, LED brightness, and switching power supply output with high efficiency.

How do I calculate PWM duty cycle from on-time and frequency?

First calculate the period: T = 1 / f. Then compute duty cycle as D = (t_on / T) × 100%. For example, with f = 2 kHz (T = 0.5 ms) and t_on = 0.1 ms, D = (0.1 / 0.5) × 100% = 20%.

What PWM frequency should I use for motor control?

For DC motors, PWM frequencies between 1 kHz and 20 kHz are common. Frequencies below 1 kHz can cause audible buzzing from the motor windings. Above 20 kHz, switching losses in the MOSFETs increase significantly. For servo motors, 50 Hz is the standard convention used for position control signals.

What is the average voltage formula for a PWM signal?

The average (DC equivalent) voltage of a PWM signal is V_avg = D × V_high, where D is the duty cycle as a decimal (e.g., 0.75 for 75%) and V_high is the supply voltage. This assumes the low state is 0 V; if the low voltage is non-zero, use V_avg = V_low + D × (V_high − V_low).

Can duty cycle ever exceed 100% or be negative?

No. A duty cycle below 0% or above 100% is physically impossible for a standard PWM signal. If the on-time entered is greater than the period (1/frequency), the result would exceed 100%, which indicates an invalid input. Maximum practical duty cycles in switching converters are often limited to around 95–98% to ensure proper gate driver bootstrap charging.

Last updated: 2025-01-15 · Formula verified against primary sources.