Duty cycle calculator
A 2 ms pulse in a 10 ms period is a 20 % duty cycle, with 8 ms off. Enter both times in the same unit, with no voltage needed; a pulse wider than its period is refused rather than shown above 100 %. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Pulse width
- 2
- Period
- 10
- Off time
- 8 %
- Duty cycle
- 20
- Duty percent
- 20
- Duty fraction
- 0.2
A duty cycle calculator converts two time durations—the pulse width of the active interval and the period of the full repeating cycle—into the percentage of time a waveform stays high. The closed formula is duty percent equals pulse width divided by period, times one hundred. Oscilloscope users, firmware authors, radar engineers, and students all meet this ratio when they describe a square wave, a clock enable, a laser shot, or a digital strobe without needing supply voltage or an average-output model.
What duty cycle means and how the percent is defined
Duty cycle is the fraction of a repeating interval during which a signal, switch, or pulse is in its active state. For a two-level waveform that is high for a pulse width tau and then low until the next identical edge, the period T is the time from one cycle start to the next, and the duty cycle in percent is one hundred times tau divided by T. The complementary off time is T minus tau, and the repetition frequency is the reciprocal of T.
The ratio is dimensionless, so tau and T must share a time unit—both microseconds, both milliseconds, or both seconds—before you divide; mixing units would silently scale the percent. Classroom numbers are immediate: a two millisecond pulse in a ten millisecond period is twenty percent; a five microsecond pulse in an eight microsecond period is sixty-two point five percent; a pulse that fills the whole period is one hundred percent; a pulse of zero width is zero percent.
Period must be strictly positive because a zero-length cycle leaves no finite denominator, and a negative duration is not a physical period. Use the same formula on a clock enable, a radar pulse train, a laser Q-switch, or a digital strobe: the definition does not depend on amplitude, and this landing does not ask for volts. Teachers and automated graders care about the domain as much as the arithmetic: a student who plugs T equals zero has left the formula, and a silent Infinity would hide that mistake.
What you can do with it
Oscilloscope and lab checks
Convert cursor measurements of pulse width and period into a textbook duty-cycle percent without a spreadsheet or a calculator that silently allows over-unity duty.
Radar, comms, and homework oracles
Compute pulse-train duty for radar or digital strobe problems, and reject zero-period or over-wide pulses the same way a grader should mark those domain errors.
FAQ
How is duty cycle calculated from pulse width and period?
Keep both durations in the same time unit so the ratio is dimensionless and the result is a percent in the closed interval from 0 to 100.
What if pulse width is larger than the period?
A pulse wider than one period is outside the textbook duty-cycle model, so this calculator does not emit a percentage above 100.
Which units should pulse width and period use?
Any shared time unit: seconds, milliseconds, microseconds, or clock ticks. Only the ratio matters. Mixing units (ms with µs) silently scales the percent, so convert first.
Is the duty cycle calculator free?
The browser tool is free and runs locally.
What else does the result show besides the percentage?
It also gives the duty as a plain fraction, the off time and the repetition frequency. For a 2 ms pulse in a 10 ms period that means 0.2, 8 ms off and 0.1 cycles per millisecond.
Related tools
For developers — API access
Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.
API endpoint
Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/elec/duty-cycle \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"pulse_width":2,"period":10}'const res = await fetch("https://api.kit.forhosting.com/elec/duty-cycle", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"pulse_width": 2,
"period": 10
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/elec/duty-cycle",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"pulse_width": 2,
"period": 10
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/elec/duty-cycle", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"pulse_width":2,"period":10}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"pulse_width":2,"period":10}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/elec/duty-cycle", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"pulse_width": 2,
"period": 10
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "elec.duty_cycle",
"status": "queued",
"_links": {
"result": "/tasks/tsk_…/result"
}
}The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Limits
max_abs | 1000000000000 |
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |
Technical notes
Enter pulse_width and period in the same time unit; the tool returns the duty cycle in percent together with the dimensionless fraction, the complementary off time, and the reciprocal frequency. Period must be strictly positive: a zero period would divide by zero, so the API returns invalid_input instead of Infinity. Pulse width must not exceed period: an over-wide pulse is outside a single cycle, and this endpoint fails rather than silently reporting more than one hundred percent. Successful API calls use the published $0.002 base price; invalid input is not billed.
What duty cycle means and how the percent is defined
Pulse width must be non-negative and must not exceed the period: a pulse longer than one cycle cannot be expressed as a duty inside that cycle, and this calculator rejects that case with invalid_input rather than inventing a percentage above one hundred. That last rule is the opposite of a PWM average-voltage helper that may report over-unity duty so a lab notebook can see an over-wide compare match; here the search intent is the textbook duty-cycle percent, which lives on the closed interval from zero to one hundred.
How to call the API and what comes back
Pulse width must be non-negative and must not be larger than period; an over-wide pulse fails with a message that pulse width exceeds period. Missing fields, empty strings, non-numeric tokens, NaN, and infinities fail by naming the field. Send a JSON body with two required finite numbers: pulse_width (aliases pw, t_pulse, width, ton, t_on, high_time, and pulse) for the active interval, and period (aliases T, t_period, cycle_time, and t) for the full cycle length in the same time unit. Absolute values must stay within the published limit of one trillion so intermediate ratios remain finite in IEEE double precision on the Worker and in the browser. Period must be strictly positive; values whose absolute magnitude is at or below one times ten to the minus fifteen are treated as zero and rejected, and any strictly negative period is also invalid_input. On success the response echoes rounded pulse_width and period, sets duty_cycle and duty_percent to the same percent value, duty_fraction to the dimensionless ratio, off_time to period minus pulse_width, frequency to one over period, formula to the documented percent string, equation to a human-readable substitution line, unit to the percent sign, message to a short English summary, and steps to an ordered array of given values, formula, fraction, percent, off time, frequency, and summary. Failed validation returns invalid_input and is never charged. Pricing is a flat $0.002 per successful request with unit item. Prefer sending JSON numbers rather than pre-formatted strings when you control the client; string numbers are accepted only when they match a strict finite numeric pattern including optional scientific notation. Pair the response with your own plot if you need a sketch of the square wave; this endpoint computes the scalar duty and does not emit oscilloscope images or timer-register bitfields.
Practical tips, limits, and related searches
Keep pulse width and period inside the published absolute range so the ratio stays finite under the magnitude cap. Use the same time unit for both fields before you call if you want duty already dimensionless and frequency already in the reciprocal of that unit without mental rescaling afterward. Prefer this capability when you already have scalar pulse width and period and only need the textbook percent on zero to one hundred; if your source is a compare-match and a clock divider, convert those into seconds or ticks first so both intervals share a unit. When teaching, pair examples: pulse width two and period ten yields twenty percent; pulse width five and period eight yields sixty-two point five percent; pulse width equal to period yields one hundred percent; pulse width zero with positive period yields zero percent; setting period to zero demonstrates the hard invalid_input path; and a pulse of twelve with period ten demonstrates the over-wide rejection that distinguishes this landing from PWM helpers that allow duty above one hundred percent. This page targets people searching for a duty cycle calculator, pulse width over period, or duty percent online; it is not a PWM average-voltage tool, not a 555 astable resistor-capacitor sizer, not a microcontroller timer-register programmer, and not a full SPICE transient simulator. Failed tasks that return invalid_input do not consume prepaid balance, which keeps exploratory scripts cheap when learners deliberately set period to zero. Round-trip checks are easy: recompute pulse width divided by period times one hundred by hand and confirm the published duty_cycle matches within the same twelve-decimal rounding, and confirm that scaling both durations by the same positive factor leaves the percent unchanged as the formula predicts.
Integration use cases
Firmware and timer configuration
Turn planned high time and full period into the duty percent a datasheet, comment, or unit test should quote before you program a compare-match register.
Technical questions
What happens when period is zero?
The ratio pulse_width / period is undefined. This tool returns invalid_input instead of Infinity or NaN, and the failed task is not billed.