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
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
f = 1 / T | T = 1 / fSteps:
2bits (e.g. 8-bit = 256 steps)Min step time:
T / stepsDuty step:
100% / stepsTimer 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
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)
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
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)
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
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
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
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
| Application | Frequency | Why |
|---|---|---|
| LED dimming | 1–25 kHz | >200 Hz avoids flicker; >1 kHz avoids camera banding |
| DC motor control | 20–25 kHz | Above audible range, eliminates motor whine |
| Servo control | 50 Hz | Standard servo protocol, 20 ms period |
| Switching PSU | 100 kHz–1 MHz | Smaller inductors and capacitors at higher f |
| Audio class-D amp | 250–500 kHz | Well above audio band for easy filtering |
| General purpose | 490–1000 Hz | Arduino 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:
| Timer | Pins | Default N | Default f | Resolution |
|---|---|---|---|---|
| Timer0 | 5, 6 | 64 | 976.6 Hz | 8-bit (256 steps) |
| Timer1 | 9, 10 | 8 | 7,812.5 Hz | 8 or 16-bit |
| Timer2 | 3, 11 | 64 | 976.6 Hz | 8-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?
What does PWM resolution mean?
How do I change Arduino PWM frequency?
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?
What is the difference between this and the Duty Cycle Calculator?
How does PWM frequency affect EMI?
Related Calculators
Browse all Electronics Calculators →