ECParts Toolkit LogoECParts Toolkit

LED PWM Dimming Calculator

Estimate LED PWM duty cycle, average current, average power, on-time, off-time, gamma-corrected PWM code, timer register settings, resolution limits, gate-drive loss and camera exposure guidance.

PWM behavior depends on driver topology, timer architecture, current rise and fall time, MOSFET switching, wiring, LED capacitance, minimum pulse width, camera shutter behavior and human visual sensitivity.

Engineering tool

LED PWM Dimming Calculator

Estimate PWM duty cycle, average LED output, gamma-corrected brightness, timer registers, resolution trade-offs, driver timing and gate-drive loss.

PWM switching frequency.

Commanded PWM duty cycle.

Current during the on portion of PWM.

Forward voltage at peak current.

Optional driver efficiency for input power estimate.

Dynamic PWM Summary

1 kHz PWM at 50% duty has 1 ms period, 500 µs on-time, 500 µs off-time and 10 mA average LED current.

Result console

Average LED current
10mA
Average LED power
30mW
PWM period
1ms
On-time
500µs
Off-time
500µs
Duty cycle
50%
Peak LED current
20mA
Peak LED power
60mW
Average input power
30mW
On pulseDuty ≈ 50.0%
Simplified PWM waveform preview. Real LED current may rise and fall more slowly than the command signal.

Timer register formulas vary between microcontroller families; confirm the exact datasheet convention.

LED PWM timing diagramA PWM waveform with period, on-time, off-time, duty cycle and LED average output labels.TonToffPWM Period = 1 / fPWMPeak LED currentDuty controls average currentand average LED power
PWM dimming changes average LED output by changing on-time, while peak pulse current may remain unchanged.

Formula reference

LED PWM Dimming Formulas

Calculations use Hz, seconds, amperes, volts and coulombs internally. Timer equations use a documented generic convention.

Period = 1 / fPWMTon = Period x DutyToff = Period - TonIaverage = Ipeak x DutyPaverage = Vf x Ipeak x DutyDuty gamma = Brightness^GammaPWM code = round(Duty x (2^bits - 1))Fast PWM TOP = fCLK / (Prescaler x fPWM) - 1Center PWM TOP = fCLK / (2 x Prescaler x fPWM)Pgate = Qg x Vgate x fPWM x N

Variable definitions

Duty is entered as percent and converted to a decimal internally.
fPWM
PWM frequency
Ipeak
LED current during the on pulse
TOP
timer period or counter limit value
Qg
MOSFET gate charge
Camera guidance uses cycles per exposure, not a hard pass/fail standard

How to Use

  1. 1. Use Average Output mode for duty cycle, average current and LED power.
  2. 2. Use Required Duty mode when firmware needs a duty value for a target current, power or linear brightness.
  3. 3. Use Gamma Correction mode for user-facing brightness controls.
  4. 4. Use Timer Register and Resolution modes before committing firmware timer settings.
  5. 5. Use Response & Flicker mode to check minimum pulse width, driver timing, gate-drive loss and camera exposure risk.

Worked Examples

Average current: 1 kHz PWM at 25% duty has a 1 ms period, 250 µs on-time, 750 µs off-time, 5 mA average current from 20 mA peak and 15 mW average LED power at 3 V.

Required duty: 700 mA peak current and 350 mA target average current requires 50% duty. At 2 kHz, on-time and off-time are both 250 µs.

Gamma correction: 50% perceived brightness with gamma 2.2 gives about 21.76% duty. At 8-bit resolution, the PWM code is about 55 of 255.

Timer setup: 16 MHz clock, 1 kHz Fast PWM and prescaler 64 gives TOP = 249 and actual frequency = 1000 Hz.

Resolution trade-off: 16 MHz timer clock, prescaler 1 and 8-bit edge-aligned PWM gives a maximum frequency of 62.5 kHz; center-aligned is about 31.25 kHz.

Gate-drive loss: 20 nC gate charge, 10 V gate drive, 20 kHz PWM and one MOSFET gives 4 mW gate-drive power.

Engineering Notes

  • PWM controls average LED output by rapidly switching current on and off.
  • Peak current may remain unchanged during each pulse.
  • PWM duty cycle and perceived brightness are not necessarily linear.
  • Gamma correction can improve apparent brightness-step uniformity.
  • Higher PWM frequency reduces the time available for each pulse.
  • Higher resolution requires more timer counts and may reduce maximum PWM frequency.
  • Driver minimum pulse width limits low-duty-cycle performance.
  • MOSFET gate-drive loss increases with switching frequency.
  • Camera banding depends on PWM, exposure and rolling-shutter behavior.
  • Timer register behavior varies between microcontrollers.

Common Mistakes

  • Assuming brightness is perfectly linear with duty cycle.
  • Ignoring gamma correction for user-facing controls.
  • Choosing PWM frequency without checking timer resolution.
  • Ignoring driver minimum on-time.
  • Confusing PWM frequency with microcontroller clock frequency.
  • Using the wrong timer-mode formula.
  • Forgetting the prescaler.
  • Treating addressable LED update rate as internal PWM frequency.
  • Ignoring MOSFET switching and gate-drive loss.
  • Calling a design flicker-free based only on frequency.

Support reference

FAQ

What is PWM LED dimming?

PWM dimming rapidly switches LED current on and off. The duty cycle controls average current and average optical output.

How do I calculate average LED current from duty cycle?

Multiply peak LED current by duty cycle as a decimal: Iaverage = Ipeak x D.

Does PWM reduce peak LED current?

Usually no. PWM often keeps peak current the same and reduces average current by changing on-time.

What PWM frequency should I use for LEDs?

There is no universal frequency. Human perception, driver response time, timer resolution, EMI, audio interaction and camera exposure all matter.

What is PWM duty cycle?

Duty cycle is the percentage of one PWM period that the output is commanded on.

How do I calculate PWM on-time?

First calculate period = 1 / frequency, then multiply by duty cycle as a decimal.

Why does perceived brightness not match duty cycle?

Human brightness perception is nonlinear, so equal electrical duty steps may not look equally spaced.

What is gamma correction?

Gamma correction maps requested perceived brightness to a nonlinear PWM duty cycle for smoother apparent brightness steps.

How many brightness levels does 8-bit PWM provide?

8-bit PWM provides 256 numeric states, with a maximum code of 255.

How do I calculate a timer prescaler and TOP value?

For edge-aligned PWM, TOP = fCLK / (prescaler x fPWM) - 1. The calculator can evaluate common prescalers automatically.

What is the difference between fast PWM and phase-correct PWM?

Fast PWM is edge-aligned and uses one count ramp. Phase-correct or center-aligned PWM effectively uses an up/down count and often halves the frequency for the same TOP.

Why does higher PWM frequency reduce resolution?

Higher frequency leaves fewer timer counts per PWM period, reducing the number of distinct duty-cycle steps.

What is minimum PWM pulse width?

It is the shortest on or off pulse that the driver, MOSFET or LED current loop can respond to reliably.

Can PWM cause camera banding?

Yes. Camera banding depends on PWM frequency, exposure time, rolling shutter behavior and waveform modulation depth.

Is 20 kHz PWM always flicker-free?

No. A high frequency may reduce visible flicker and audio interaction, but flicker cannot be judged by frequency alone.

How does MOSFET gate charge affect switching loss?

Gate-drive power is approximately Qg x Vgate x fPWM x device count. Total switching loss includes more than gate-drive loss.

Can I PWM the input of any LED driver?

No. Some drivers support PWM on an enable or dimming pin, while others may not tolerate input-side PWM.

What is the difference between analog dimming and PWM dimming?

Analog dimming changes LED current amplitude. PWM dimming switches current pulses and changes average output.

Documentation

Design notes, guides, and engineering articles linked to this tool.

Disclaimer

This calculator provides engineering estimates for PWM dimming and firmware planning. Final designs should be verified against LED, driver, MOSFET, timer and camera requirements, and applicable lighting or safety standards.