PWM Frequency Calculator

Convert frequency ↔ period, compute on/off time from duty cycle, and estimate PWM frequency from timer settings.

How to Use

  1. Enter Frequency or Period (either one is enough).
  2. Add Duty Cycle if you want On-Time and Off-Time.
  3. Optional: Use Timer Mode inputs (clock, prescaler, TOP) to estimate PWM frequency.
  4. Open Show Work to see formulas and steps.
Live Readout
Results update as inputs change (no URL updates while typing).
f
T
Ton
Toff
Indicator:
Waveform Preview
Preview reflects duty cycle (Ton vs Toff).
On (Ton) Off (Toff)
Inputs & Settings
Enter what you know. The tool will solve the rest.
Common: 50Hz (servo), 1kHz (LED), 20kHz (quiet motor)
Relationship: T = 1/f
0–100% (or 0–1 ratio). Used to compute Ton/Toff.
If you know Ton and Toff, the tool can solve f and duty.
Period is T = Ton + Toff.
Use this if multiple paths are possible.

Timer Mode (Optional)

Estimate PWM frequency from clock, prescaler, and TOP. (Tool works without this section too.)

Examples: 16MHz (AVR), 72MHz (STM32), etc.
Fast PWM often uses f = f_clk / (N × (1 + TOP))
TOP is the maximum counter value for the PWM cycle.
Optional: used only for additional readouts (not required).
Timer f_pwm
Timer Period
Enter clock + prescaler + TOP to estimate PWM frequency.
Show Work (step-by-step)
Work is shown in base units: Hz (frequency) and seconds (time).

Formulas

  • Frequency ↔ Period: f = 1 / T, T = 1 / f
  • Duty Cycle: D = Ton / T, Ton = D × T, Toff = T − Ton
  • From on/off time: T = Ton + Toff, f = 1 / (Ton + Toff)
  • Fast PWM (common): f_pwm = f_clk / (N × (1 + TOP))
  • Phase Correct (common): f_pwm = f_clk / (2 × N × TOP) (implementation may vary by MCU)
Timer formulas differ slightly across MCU families. This tool labels the selected mode and shows the equation used.

FAQ

What PWM frequency should I use for LEDs?

Many setups avoid visible flicker by using ~500 Hz to several kHz. Cameras can still show banding depending on shutter speed.

Why do motors often use 20 kHz PWM?

20 kHz is above most human hearing, reducing audible whine. Tradeoffs include switching losses and driver limitations.

How do Ton and Toff relate to duty cycle?

Duty is the fraction of the period spent “on”: D = Ton / (Ton + Toff).

Why doesn’t my MCU’s PWM match the formula exactly?

Some timers use TOP vs TOP+1, center-aligned counting, or special clock sources. Always confirm with your MCU reference manual.

Tool Info

Last updated:

Updates may include additional timer formulas, presets, and edge-case handling.