Tools / PWM Timing Calculator
How to work out PWM on time and off time
PWM switches a pin fully on and off. The frequency sets how often; the duty cycle sets how much of each cycle is on.
Period = 1/f; Ton = D × period
Result
- Period
- 1 ms
- On time
- 250 µs
- Off time
- 750 µs
What this leaves out
- Timer resolution, switching losses and driver suitability require specific hardware verification.
Step by step
The working with your numbers
- Find the period
T = 1 ÷ f = 1 ÷ 1,000 = 1 ms - Change the duty cycle to a fraction
D = 25 % ÷ 100 = 0.25 - On time
Ton = D × T = 0.25 × 1 ms = 250 µs - Off time
Toff = T − Ton = 1 ms − 250 µs = 750 µs
See it
Three cycles of your PWM signal
Does the answer make sense?
- OK: Ton + Toff = 1 ms, one full period.
- OK: 1 kHz is fine for LEDs. For motors, frequencies under 20 kHz can whine audibly.
Common mistakes
- Thinking a higher duty cycle changes the frequency. It only changes how the period is split.
- Using analogWrite() for a servo. Arduino's analogWrite runs at about 490 Hz (980 Hz on some pins); servos need 50 Hz pulses from the Servo library.
- Driving a motor straight from a pin. A pin gives about 20 mA; use a transistor or MOSFET and a flyback diode.
Learn it, try it, build it
Calculated, not measured. Check the exact part datasheet and your real circuit before powering anything.
Just need the number? Use the PWM timing calculator on Geekobot.
Common questions
How do you work out PWM on time?
Find the period T = 1 ÷ f, then multiply by the duty cycle as a fraction. At 1 kHz and 25 %: T = 1 ms, so the pin is on for 0.25 ms and off for 0.75 ms.
What PWM frequency should I use for LEDs?
Anything above a few hundred hertz looks steady to the eye. Arduino's default of about 490 Hz is fine for indicator LEDs.
