CALCULATORS / EMBEDDED TIMING AND DIGITAL SYSTEMS
PWM frequency, resolution and duty calculator
Ideal timer PWM rate and duty quantization; edge-aligned timer.
SCENARIO COMPARISON
Compare the numbers.
This source describes an analytical model. Its quantities and checks are the view.
| Scenario | frequencyHz | duty | resolution |
|---|---|---|---|
| 1000 | 0.25 | 0.001 | |
| 800 | 0.25 | 0.001 |
All calculated quantities are listed with the inputs. Switch to Source to inspect the equations.
Change an input to see the consequences.
BASELINE INPUTS
CALCULATED
Edits change the baseline source.
Illustrative first-order example. Checks are editable requirements, not design standards. The broader topic may require additional equations, data, and validation.
Formula and units
This example uses the following equations. Input names and units match the editable source above.
- frequency
frequency = clock/(prescaler*periodCounts) [Hz]- duty
duty = compareCounts/periodCounts- resolution
resolution = 1/periodCounts
Original worked example
These are the baseline values in the downloadable source. Edits above let you test your own values.
Given
- clock
- 48000000 Hz
- prescaler
- 48
- period counts
- 1000
- compare counts
- 250
Calculated
- frequency
- 1000 Hz
- duty
- 0.25
- resolution
- 0.001
Assumptions and limits
Ideal timer PWM rate and duty quantization; edge-aligned timer.
The requirement checks use the limits written in this example. Passing a check does not establish that the model covers every load, material behavior, or operating condition in a real design.
Download this .napkin example ↓Take it further with your agent
Napkin keeps the inputs, equations, checks and assumptions together in one study. Your agent sets it up; you change the numbers.
codex 'Use Napkin (https://napkin.engineering/mcp, or the local Napkin plugin) to build a study: PWM frequency, resolution and duty. Inputs: clock; prescaler; timer width; mode. Outputs: frequency; duty increments; on-time. Model scope: Declared clock, peripheral and execution assumptions. Read napkin_capabilities and the current snapshot. Ask me for the values that matter, label assumptions with units, author .napkin source, validate it and apply it with napkin_source using the current revision, then open the study. Add checks for the limits I supply. Keep unsupported analyses explicit.'Claude needs the Napkin connector; Codex needs the Napkin plugin. Set up your agent ↗
The broader study
The topic brief below describes the broader scope. The worked example above states the particular calculation it implements.
- Inputs: clock, prescaler, timer width, mode
- Outputs: frequency, duty increments, on-time
- Modes: calculate, compare, sweep
- Drawing: Timing diagram or event simulation
EXECUTABLE WORKED EXAMPLE · FIRST-ORDER MODEL · CHECK THE SCOPE & ASSUMPTIONS
More in embedded timing and digital systems
- Timer counts and interrupt period calculator
- ADC quantization and input range calculator
- ADC acquisition settling calculator
- UART baud-rate divider and error calculator
- I2C pull-up and rise-time budget calculator
- SPI transaction throughput calculator
- Firmware memory budget calculator
- Task and interrupt CPU budget calculator
- Switch debounce timing calculator
- Watchdog and recovery timing calculator
- State transition table memory calculator