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
| Symbol | Meaning |
|---|---|
| bits | PWM duty cycle resolution in bits |
| f_clk | Timer clock frequency (Hz) |
| f_PWM | PWM 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
| Symbol | Default unit | Accepted units |
|---|---|---|
| Resolution (bits) | ||
| Timer Clock | MHz | Hz, kHz, MHz, GHz |
| PWM Frequency | kHz | Hz, kHz, MHz, GHz |
Worked examples
| Given | Result | |
|---|---|---|
| Minimum range | Timer Clock 100 kHz, PWM Frequency 100 Hz | Resolution (bits) = 9.966 |
| Low range | Timer Clock 1 MHz, PWM Frequency 1 kHz | Resolution (bits) = 9.966 |
| Typical | Timer Clock 10 MHz, PWM Frequency 100 kHz | Resolution (bits) = 6.644 |
| High range | Timer Clock 100 MHz, PWM Frequency 0.5 MHz | Resolution (bits) = 7.644 |
| Maximum range | Timer Clock 1 GHz, PWM Frequency 5 MHz | Resolution (bits) = 7.644 |
Solving for each variable
| Solve for | Given | Result |
|---|---|---|
| Resolution (bits) | Timer Clock 100 kHz, PWM Frequency 100 Hz | 9.966 |
| Timer Clock | Resolution (bits) 0.025, PWM Frequency 100 Hz | 101.7 Hz |
| PWM Frequency | Resolution (bits) 0.025, Timer Clock 100 kHz | 98.28 kHz |
How Resolution (bits) changes with Timer Clock
| Timer Clock (input) | Resolution (bits) (result) |
|---|---|
| 1 MHz | 3.322 |
| 2.5 MHz | 4.644 |
| 5 MHz | 5.644 |
| 7.5 MHz | 6.229 |
| 10 MHz | 6.644 |
| 15 MHz | 7.229 |
| 20 MHz | 7.644 |
| 40 MHz | 8.644 |
| 70 MHz | 9.451 |
| 100 MHz | 9.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.