PWM Resolution (Bits) Calculator

bits = log2(fclk / fpwm)

Quick answer: This calculator solves bits = log₂(f_clk / f_PWM) for Resolution (bits). With Timer Clock 10 MHz, PWM Frequency 100 kHz, the result is 6.644. It solves in 3 directions, so you can enter the values you have and get the one you need.

Calculator

Loading calculator…

Formula

bits = log₂(f_clk / f_PWM)

Description

The resolution of a timer-based PWM output is determined by the ratio of the timer clock frequency to the desired PWM frequency. The timer counts from 0 to (fclk/fpwm − 1), giving fclk/fpwm distinct duty cycle steps. The resolution in bits is the base-2 logarithm of this count. Higher timer clock frequencies or lower PWM frequencies give more resolution. For example, a 72 MHz timer generating a 20 kHz PWM has 72M/20k = 3600 steps ≈ 11.8 bits of resolution.

Variables

SymbolMeaning
bitsPWM duty cycle resolution in bits
f_clkTimer clock frequency (Hz)
f_PWMPWM output frequency (Hz)

Practical Notes

Common applications: LED dimming requires 10-12 bits for smooth visual perception. Motor control typically needs 8-12 bits. Audio-class PWM (class D amplifiers) requires 12-16 bits. If the calculated resolution is insufficient, options include: increasing the timer clock, decreasing the PWM frequency, or using dithering to achieve fractional bit resolution. Some microcontrollers offer high-resolution PWM timers (e.g., STM32 HRTIM at 4.6 GHz equivalent) for precisely controlled duty cycles.

Symbols and units

SymbolDefault unitAccepted units
Resolution (bits)
Timer ClockMHzHz, kHz, MHz, GHz
PWM FrequencykHzHz, kHz, MHz, GHz

Worked examples

GivenResult
Minimum rangeTimer Clock 100 kHz, PWM Frequency 100 HzResolution (bits) = 9.966
Low rangeTimer Clock 1 MHz, PWM Frequency 1 kHzResolution (bits) = 9.966
TypicalTimer Clock 10 MHz, PWM Frequency 100 kHzResolution (bits) = 6.644
High rangeTimer Clock 100 MHz, PWM Frequency 0.5 MHzResolution (bits) = 7.644
Maximum rangeTimer Clock 1 GHz, PWM Frequency 5 MHzResolution (bits) = 7.644

Solving for each variable

Solve for GivenResult
Resolution (bits)Timer Clock 100 kHz, PWM Frequency 100 Hz9.966
Timer ClockResolution (bits) 0.025, PWM Frequency 100 Hz101.7 Hz
PWM FrequencyResolution (bits) 0.025, Timer Clock 100 kHz98.28 kHz

How Resolution (bits) changes with Timer Clock

Timer Clock (input)Resolution (bits) (result)
1 MHz3.322
2.5 MHz4.644
5 MHz5.644
7.5 MHz6.229
10 MHz6.644
15 MHz7.229
20 MHz7.644
40 MHz8.644
70 MHz9.451
100 MHz9.966

Embed this calculator

Paste this into any page. It keeps working when this page updates, and credits the source.

Frequently asked questions

How do you calculate PWM Resolution (Bits)?

Use bits = log₂(f_clk / f_PWM). With Timer Clock 10 MHz, PWM Frequency 100 kHz, Resolution (bits) works out to 6.644.

What is the formula for PWM Resolution (Bits)?

The formula is bits = log₂(f_clk / f_PWM). The resolution of a timer-based PWM output is determined by the ratio of the timer clock frequency to the desired PWM frequency.

How do you find Timer Clock when you know the other values?

Rearrange for Timer Clock: with Resolution (bits) 0.025, PWM Frequency 100 Hz, Timer Clock is 101.7 Hz.

How do you find PWM Frequency when you know the other values?

Rearrange for PWM Frequency: with Resolution (bits) 0.025, Timer Clock 100 kHz, PWM Frequency is 98.28 kHz.

What does bits mean in the PWM Resolution (Bits) formula?

bits is PWM duty cycle resolution in bits.

What should I watch out for when using PWM Resolution (Bits)?

Common applications: LED dimming requires 10-12 bits for smooth visual perception. Motor control typically needs 8-12 bits. Audio-class PWM (class D amplifiers) requires 12-16 bits. If the calculated resolution is insufficient, options include: increasing the timer clock, decreasing the PWM frequency, or using dithering to achieve fractional bit resolution. Some microcontrollers offer high-resolution PWM timers (e.g., STM32 HRTIM at 4.6 GHz equivalent) for precisely controlled duty cycles.