TFT

PWM Frequency Calculator – Calculate PWM Output Frequency

Calculate PWM frequency based on clock speed, prescaler, and resolution. Essential for motor control and power electronics.

How PWM Frequency Calculation Works
Understanding pulse-width modulation timing
1

Apply the Prescaler

The prescaler divides the input clock frequency. A prescaler of 64 means the timer counts once for every 64 clock cycles, effectively slowing down the base frequency before PWM generation.

2

Account for Resolution

Resolution in bits determines the PWM counter range. An 8-bit resolution means 2^8 = 256 steps. Higher resolution gives finer duty cycle control but lowers maximum frequency.

3

Calculate Final Frequency

PWM frequency equals clock frequency divided by (prescaler × 2^resolution). The period is simply the inverse – how long one complete PWM cycle takes in seconds or microseconds.

PWM Frequency Features and Applications
Why PWM frequency matters in electronics

**Motor Speed Control**

PWM frequency affects motor performance. Too low causes audible whine and torque ripple. Too high increases switching losses. Typical motor control uses 8-20 kHz for optimal efficiency.

**LED Dimming**

LED drivers use PWM for smooth dimming. Frequencies above 200 Hz prevent visible flicker. High-end lighting uses 1-10 kHz for camera-compatible, flicker-free operation.

**Power Supply Regulation**

Switch-mode power supplies rely on PWM. Higher frequencies allow smaller inductors and capacitors but increase switching losses. Typical SMPS operates at 50 kHz to 2 MHz.

**Audio Signal Generation**

Class-D amplifiers use PWM to reproduce audio. Frequencies must exceed 20 kHz (above human hearing) with careful filtering. High-quality audio PWM runs at 300-500 kHz.

Common PWM Frequency Ranges

ApplicationTypical FrequencyResolutionNotes
DC Motor Control8-20 kHz8-10 bitAbove audible range
LED Dimming200 Hz - 10 kHz8-12 bitFlicker-free visible light
Switch-Mode PSU50 kHz - 2 MHz8-16 bitTrade-off: size vs efficiency
Servo Control50-400 Hz10-12 bitStandard hobby servo protocol
Class-D Audio300-500 kHz16-24 bitUltrasonic carrier frequency
Frequently Asked Questions

What is a good PWM frequency for motors?

For DC motors, 8-20 kHz works well. Below 8 kHz causes audible noise; above 20 kHz increases switching losses without benefit. Brushless motors often use 16-32 kHz. Stepper motors benefit from 20-40 kHz for smooth microstepping.

How does PWM resolution affect frequency?

Higher resolution means more steps per cycle, which lowers maximum frequency. Doubling resolution (e.g., 8 to 9 bits) halves the max frequency. Choose resolution based on control precision needs, not just maximum frequency.

What does the prescaler do in PWM?

The prescaler divides the clock before it reaches the PWM timer. Common values are 1, 8, 64, 256. It lets you achieve lower frequencies without changing resolution, useful when your clock is too fast for your application.

Why is my PWM making noise?

Audible noise means your PWM frequency is below 20 kHz. Motors and inductors physically vibrate at the PWM frequency. Increase frequency above 20 kHz or add mechanical damping. Check for loose components resonating at your PWM frequency.

Can I change PWM frequency on Arduino?

Yes, by modifying timer prescalers and registers. Arduino Uno defaults to ~490 Hz (pins 5,6: ~980 Hz). You can reconfigure timers for frequencies from a few Hz to 62.5 kHz, but it requires direct register manipulation.