PWM Duty Cycle Calculator
Calculate PWM duty cycle, frequency, period, ON/OFF time instantly. Essential for motor control, LED dimming, Arduino projects, and signal processing applications.
PWM Duty Cycle Calculator
Calculate PWM duty cycle, frequency, period, ON/OFF time instantly. Essential for motor control, LED dimming, and signal processing.
Actions
Calculation Mode
Time Parameters
Common PWM Configurations
Related tools
What is PWM (Pulse Width Modulation)?
PWM (Pulse Width Modulation) is a technique used to control the average power delivered to a load by switching it on and off at a high frequency. The duty cycle represents the percentage of time the signal is ON (high) versus the total period. PWM is widely used in motor speed control, LED brightness control, power regulation, audio synthesis, and digital-to-analog conversion. By varying the duty cycle, you can control the effective voltage or power delivered to the load without using variable resistors or linear regulators, making it highly efficient.
PWM Calculation Formulas
Duty Cycle Calculation
Duty Cycle (%) = (ON Time / Period) × 100
Where Period = ON Time + OFF Time. Duty cycle represents the fraction of time the signal is high. A 50% duty cycle means the signal is ON for half the period and OFF for the other half.
ON Time Calculation
ON Time = (Duty Cycle / 100) × Period
Calculate the ON time when you know the desired duty cycle and period. For example, a 25% duty cycle with 10ms period gives ON time = 0.25 × 10ms = 2.5ms.
Frequency and Period
Frequency (Hz) = 1 / Period (s)
Frequency is the number of complete cycles per second. A 1kHz PWM signal has a period of 1ms. Higher frequencies result in smoother control but may increase switching losses.
Complete Example
Given: ON Time = 2ms, OFF Time = 8ms
Step 1: Period = 2ms + 8ms = 10ms
Step 2: Duty Cycle = (2ms / 10ms) × 100 = 20%
Step 3: Frequency = 1 / 0.01s = 100 Hz
Common PWM Applications
Arduino PWM Pins and Frequencies
| Board | PWM Pins | Frequency | Resolution |
|---|---|---|---|
| Arduino Uno | 3, 5, 6, 9, 10, 11 | 490 Hz (980 Hz on 5,6) | 8-bit (0-255) |
| Arduino Mega | 2-13, 44-46 | 490 Hz (980 Hz on 4,13) | 8-bit (0-255) |
| ESP32 | All GPIO pins | 5 kHz (configurable) | 8-16 bit |
| Raspberry Pi Pico | All GPIO pins | 1 kHz (configurable) | 16-bit |
Choosing PWM Frequency
PWM Resolution and Duty Cycle
Understanding Resolution
8-bit PWM (Arduino): 256 steps (0-255). Duty cycle = (value / 255) × 100%. Value 128 = 50% duty cycle. Sufficient for most applications.
10-bit PWM: 1024 steps (0-1023). Finer control, useful for precise motor speed or LED brightness control. Value 512 = 50% duty cycle.
16-bit PWM (ESP32, Pico): 65536 steps (0-65535). Ultra-fine control for professional applications. Value 32768 = 50% duty cycle.
| Duty Cycle | 8-bit Value | 10-bit Value | Application |
|---|---|---|---|
| 0% | 0 | 0 | OFF / Stop |
| 25% | 64 | 256 | Low speed / Dim |
| 50% | 128 | 512 | Medium speed / Half brightness |
| 75% | 192 | 768 | High speed / Bright |
| 100% | 255 | 1023 | Full speed / Maximum brightness |
Frequently Asked Questions
How is duty cycle calculated?
Duty cycle = ON time ÷ period × 100, where period = ON + OFF time and frequency = 1 ÷ period. 0.5 ms on and 1.5 ms off is a 2 ms period, 500 Hz and 25% duty.
How do I set a duty cycle on an Arduino?
analogWrite(pin, value) takes 0–255, so value = duty ÷ 100 × 255: 25% is 64 and 50% is 128. On an Uno the PWM frequency is about 490 Hz on most pins and 980 Hz on pins 5 and 6.
What frequency should I use for LED dimming?
At least a few hundred hertz to avoid visible flicker; 1 kHz or more also avoids banding on cameras.
What frequency should I use for motors?
Many DC motor drivers use 20–25 kHz, above hearing, to avoid whine; lower frequencies work but may hum.
What is the average voltage?
For a resistive load, the average is the supply voltage × duty cycle: 12 V at 25% averages 3 V.
💡 Pro Tip
When using PWM for motor control, always use a motor driver IC (L298N, L293D, TB6612) instead of driving the motor directly from microcontroller pins. Motor drivers provide current amplification, flyback diode protection, and thermal shutdown. For LED dimming, use PWM frequency > 200 Hz to avoid flicker. For servo control, use exactly 50 Hz (20ms period) with 1-2ms pulse width. Always measure actual PWM frequency with an oscilloscope when precision matters, as software delays and interrupts can affect timing.
How to Use the PWM Duty Cycle Calculator
- 1Choose the mode: Select calculate duty cycle, calculate ON/OFF time, or calculate frequency and period.
- 2Choose the time unit: Select microseconds, milliseconds or seconds.
- 3Enter what you know: Type the ON and OFF times, or the duty cycle with the frequency or period.
- 4Read the results: See the duty cycle, frequency, period, ON and OFF times, or pick a preset.
Related Tools
ADC Resolution Calculator
Determine ADC resolution.
DAC Output Calculator
Compute analog output from digital input.
Logic Gate Calculator
Evaluate digital logic outputs.
Clock Frequency Calculator
Calculate clock frequency.
Data Rate Calculator
Compute data transmission rate.
Frequency Calculator
Calculate frequency from time period.
Signal Attenuation Calculator
Determine signal loss in circuits.
RC Time Constant Calculator
Calculate time constant (τ = RC).
Antenna Length Calculator
Determine antenna length for frequency.
RF Power Calculator
Calculate RF signal power.
Lightning Protection Calculator
Estimate protection requirements.
Power Loss Calculator
Calculate losses in electrical systems.