Productive Toolbox

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

ms
ms

Common PWM Configurations

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

•
Motor Speed Control: PWM controls DC motor speed by varying the average voltage. Higher duty cycle = faster speed. Typical frequency: 1-20kHz. Used in robotics, drones, electric vehicles, and industrial automation. Avoids heat dissipation of linear control methods.
•
LED Dimming: Control LED brightness without changing current. Duty cycle directly controls perceived brightness. Frequency > 100Hz avoids visible flicker. Used in displays, automotive lighting, and smart home systems. More efficient than resistive dimming.
•
Power Regulation: Switch-mode power supplies use PWM to regulate output voltage efficiently. Buck converters, boost converters, and DC-DC converters all rely on PWM. Efficiency > 90% compared to 50-60% for linear regulators.
•
Servo Control: Standard servos use 50Hz PWM with 1-2ms pulse width to control position. 1ms = 0°, 1.5ms = 90°, 2ms = 180°. Used in robotics, RC vehicles, and automation.
•
Audio Synthesis: Class-D amplifiers use PWM to generate audio signals with high efficiency. PWM frequency typically 200-500kHz, well above audible range. Used in portable speakers and automotive audio systems.

Arduino PWM Pins and Frequencies

BoardPWM PinsFrequencyResolution
Arduino Uno3, 5, 6, 9, 10, 11490 Hz (980 Hz on 5,6)8-bit (0-255)
Arduino Mega2-13, 44-46490 Hz (980 Hz on 4,13)8-bit (0-255)
ESP32All GPIO pins5 kHz (configurable)8-16 bit
Raspberry Pi PicoAll GPIO pins1 kHz (configurable)16-bit

Choosing PWM Frequency

•
Low Frequency (50-500 Hz): Used for servo control, heating elements, and applications where switching losses must be minimized. Visible flicker in LEDs. Lower EMI. Suitable for high-power applications with slow response time requirements.
•
Medium Frequency (1-20 kHz): Most common range for motor control and LED dimming. Above human hearing range (20 kHz) to avoid audible noise. Good balance between switching losses and control smoothness. Arduino default: 490-980 Hz.
•
High Frequency (20-500 kHz): Used in switch-mode power supplies, Class-D amplifiers, and applications requiring smooth output. Allows smaller filter components. Higher switching losses. Requires fast switching devices (MOSFETs, IGBTs).

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 Cycle8-bit Value10-bit ValueApplication
0%00OFF / Stop
25%64256Low speed / Dim
50%128512Medium speed / Half brightness
75%192768High speed / Bright
100%2551023Full 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

  1. 1Choose the mode: Select calculate duty cycle, calculate ON/OFF time, or calculate frequency and period.
  2. 2Choose the time unit: Select microseconds, milliseconds or seconds.
  3. 3Enter what you know: Type the ON and OFF times, or the duty cycle with the frequency or period.
  4. 4Read the results: See the duty cycle, frequency, period, ON and OFF times, or pick a preset.