PWM Frequency Calculator

PWM Frequency Calculator
f = 1/T
T = 1/f
f = fclk/(N×(TOP+1))
Resolution = log₂(TOP+1)
PWM Frequency ↔ Period
f PWM Frequency
T Period
n Resolution (bits)
Steps = 2n | Min step time = T/2n
Enter values
PWM Results
PWM Frequency
Hz
Period T
s
Resolution
bits
Steps (2n)
 
Min Step Time
s
Duty Step
%
fPWM = fclk / (N × (TOP+1)) fclk ÷ N (pre) ÷ TOP+1 = fPWM Arduino: 16 MHz / (64 × 256) = 976.6 Hz (default Timer0)

Figure 1: PWM frequency equals the timer clock divided by prescaler and counter range. Higher frequency or resolution requires a faster clock.

Table of Contents
Fundamentals
  1. What Is PWM Frequency?
  2. The Formulas
Mode Guides
  1. Mode 1 — Frequency ↔ Period
  2. Mode 2 — Timer/Prescaler
Deep Dive
  1. Frequency vs Resolution Trade-Off
  2. Recommended Frequencies by Application
  3. Arduino PWM Frequency Guide
Reference
  1. Frequently Asked Questions
  2. Related Calculators

What Is PWM Frequency?

PWM frequency is how often a pulse-width-modulated signal repeats. A 1 kHz PWM signal completes 1,000 ON/OFF cycles per second. The frequency determines smoothness of the output (higher is smoother), audibility (below 20 kHz motors whine), and the size of output filter components (higher frequency allows smaller inductors and capacitors). The Duty Cycle Calculator complements this by computing the ON/OFF timing and voltage within each cycle.

The calculator above has two modes. Mode 1 converts between frequency and period with resolution analysis. Mode 2 takes microcontroller timer settings (clock, prescaler, TOP value) and returns the exact PWM output frequency and resolution in bits.

The Formulas

Basic: f = 1 / T  |  T = 1 / f
Steps: 2bits (e.g. 8-bit = 256 steps)
Min step time: T / steps
Duty step: 100% / steps

Timer mode: fPWM = fclk / (N × (TOP + 1))
Resolution: log₂(TOP + 1) bits

Mode 1 — Frequency ↔ Period with Resolution

Enter PWM frequency (Hz, kHz, MHz) or period (ms, µs, s). Add resolution in bits (default 8). The calculator returns frequency, period, number of steps, minimum step time, and duty cycle step size.

Example: 1 kHz, 8-Bit

Given: f = 1 kHz, 8-bit resolution

T = 1/1000 = 1 ms

Steps = 2&sup8; = 256

Min step time = 1 ms / 256 = 3.91 µs

Duty step = 100% / 256 = 0.39%

256 discrete duty cycle levels, each 0.39% apart. Smooth enough for LED dimming — 256 brightness levels is visually seamless.

Example: 25 kHz, 8-Bit (Motor Drive)

Given: f = 25 kHz, 8-bit

T = 40 µs

Min step time = 40 µs / 256 = 156 ns

25 kHz is above audible range — no motor whine. The 156 ns step time requires a timer clock of at least 6.4 MHz. An Arduino at 16 MHz handles it easily.

Example: 50 Hz Servo — 8-Bit vs 16-Bit

Given: f = 50 Hz

T = 20 ms

At 8-bit: 256 steps, min step = 78.1 µs. Servo range 1.0–2.0 ms spans only ~13 usable steps — too coarse.

At 16-bit: 65,536 steps, min step = 305 ns. Servo range spans ~3,277 positions — smooth. This is why servo libraries use 16-bit timers.

Mode 2 — Timer/Prescaler Configuration

Enter the timer clock frequency (fclk), prescaler divider (N), and TOP value (counter maximum). The calculator returns the exact PWM frequency and resolution in bits. This mode maps directly to microcontroller timer register settings.

Example: Arduino Timer0 Default (Pins 5, 6)

fclk = 16 MHz, N = 64, TOP = 255

fPWM = 16,000,000 / (64 × 256) = 976.6 Hz

Resolution = log₂(256) = 8 bits

The actual default for Arduino Uno pins 5 and 6. analogWrite() writes 0–255 to set duty. To increase frequency, reduce the prescaler: N = 8 gives 7.8 kHz, N = 1 gives 62.5 kHz.

Example: STM32 at 72 kHz

fclk = 72 MHz, N = 1, TOP = 999

fPWM = 72,000,000 / (1 × 1000) = 72 kHz

Resolution = log₂(1000) = ~10 bits (1,000 steps)

The STM32’s fast clock gives high frequency and high resolution simultaneously. A common motor control configuration. The Bandwidth Calculator can confirm the system bandwidth supports these switching edges.

Example: STM32F4 at 16-Bit Resolution

fclk = 84 MHz, N = 1, TOP = 65535

fPWM = 84,000,000 / 65,536 = 1,281.7 Hz

Resolution = 16 bits (65,536 steps)

Duty step = 0.0015% — extremely smooth. But frequency drops to 1.28 kHz, which would produce audible motor whine. Maximum resolution or maximum frequency — not both without a faster clock.

The Frequency vs Resolution Trade-Off

fclk = fPWM × 2bits

For a fixed timer clock, increasing frequency reduces resolution and vice versa. You cannot have both without a faster clock.

At 16 MHz (Arduino): 25 kHz × 256 = 6.4 MHz — fits. But 25 kHz × 65,536 = 1.64 GHz — impossible. This is why the STM32 (72–168 MHz) outperforms the Arduino for PWM: higher clock means more room for both frequency and resolution. An 84 MHz clock can produce 25 kHz with 3,360 steps (11.7 bits) — impossible on a 16 MHz Arduino at the same frequency.

Recommended Frequencies by Application

ApplicationFrequencyWhy
LED dimming1–25 kHz>200 Hz avoids flicker; >1 kHz avoids camera banding
DC motor control20–25 kHzAbove audible range, eliminates motor whine
Servo control50 HzStandard servo protocol, 20 ms period
Switching PSU100 kHz–1 MHzSmaller inductors and capacitors at higher f
Audio class-D amp250–500 kHzWell above audio band for easy filtering
General purpose490–1000 HzArduino default range, adequate for basic tasks

The Signal Attenuation Calculator is useful when long cable runs carry PWM signals — cable capacitance rounds the pulse edges, reducing the effective resolution at the load end.

Arduino PWM Frequency Guide

The Arduino Uno has three timers, each controlling two PWM pins:

TimerPinsDefault NDefault fResolution
Timer05, 664976.6 Hz8-bit (256 steps)
Timer19, 1087,812.5 Hz8 or 16-bit
Timer23, 1164976.6 Hz8-bit (256 steps)

Changing Timer0’s prescaler affects millis() and delay(). Timer1 and Timer2 can be changed freely. To set the prescaler, write to TCCRnB: prescaler 1 = 62.5 kHz, 8 = 7.8 kHz, 64 = 976 Hz (default), 256 = 244 Hz, 1024 = 61 Hz. The Gain Calculator can size an amplifier if the PWM output needs boosting before driving a load.

Frequently Asked Questions

What PWM frequency should I use for motor control?
20–25 kHz. Above the audible range to eliminate motor whine. Higher is possible but increases switching losses in the MOSFET driver.
What does PWM resolution mean?
The number of discrete duty cycle steps. 8-bit = 256 steps (0.39% per step). 10-bit = 1,024 steps. 16-bit = 65,536 steps. More steps means smoother control. For LED dimming 8-bit is usually sufficient. For precision motor control or audio, 10–12 bits is preferred.
How do I change Arduino PWM frequency?
Change the timer prescaler by writing to TCCRnB. For Timer0: TCCR0B = (TCCR0B & 0b11111000) | prescaler_bits. Prescaler 1 = 62.5 kHz, 8 = 7.8 kHz, 64 = 976 Hz (default). Changing Timer0 affects millis() and delay().
Why can I not have high frequency and high resolution?
The timer clock must be at least fPWM × steps. At 16 MHz, 25 kHz × 256 = 6.4 MHz — fits. But 25 kHz × 65,536 = 1.64 GHz — impossible. You need a faster clock or fewer steps.
What is the difference between this and the Duty Cycle Calculator?
The Duty Cycle Calculator works with timing (ON time, period) and voltage (Vavg, Vrms). This calculator works with timer hardware (clock, prescaler, TOP) and resolution (bits, steps). Use the Duty Cycle Calculator to find what duty cycle you need. Use this to find the timer settings that produce it.
How does PWM frequency affect EMI?
Higher PWM frequencies produce harmonics that can interfere with sensitive circuits. The Noise Figure Calculator analyses receiver sensitivity — if PWM harmonics fall within the receiver bandwidth, they degrade SNR. The Decibel Calculator can express harmonic levels in dBc.

Browse all Electronics Calculators →

Last updated: March 2026