Skip to content
Documentation sections

CAN Bus Bit Timing Calculator

POSThttps://rftools.io/api/py/v1/calculate

Slug can-bus-timing. Calculate CAN bus bit timing parameters including prescaler, time quanta, sync segment, propagation segment, and phase buffer segments for a given baud rate and sample point

Inputs

Send every one of these in inputs, in the units shown. Most are required: a call without one is refused (400) and costs nothing; one the calculator can do without takes the default shown. An input outside its range is still computed and flagged in the provenance.

Inputs of can-bus-timing
NameUnitRangeDefaultDescription
clockFreqnumberMHzat least 148Microcontroller peripheral clock frequency feeding the CAN controller
baudRatenumberkbpsat least 1500Target CAN bus baud rate
samplePointnumber%50 … 9587.5Sample point position as percentage of bit time (CiA 601 recommends 75–87.5%)
sjwnumbertq1 … 41How far a resynchronisation may move the sample point; a wider jump lets the bus take a looser clock, up to the length of either phase segment

Outputs

Returned in values, by key. A value that is unbounded or undefined is null.

Outputs of can-bus-timing
FieldUnitDescription
tqnsTime Quantum (TQ)
nominalBitTimetqNominal Bit Time
syncSegtqSync Segment
propSegtqPropagation Segment
phase1tqPhase Buffer 1 (BS1)
phase2tqPhase Buffer 2 (BS2)
prescalerheadlinenonePrescaler
bitRateActualkbpsThe clock over the prescaler and the quanta of the bit as programmed
bitRateError_pct%Actual over requested, signed; it adds to the oscillator's own tolerance
samplePointActual%Sync, propagation and phase 1 over the whole bit, in whole quanta
oscTolerance_pct%The largest deviation from nominal each node's clock may have (ISO 11898-1): the smaller of min(PS1, PS2)/(2·(13·NBT − PS2)) and SJW/(20·NBT)

Calling it

  • Calculate: one call, the request and response in full, and its errors.
  • Batch: this calculator with others, or a sweep, in one request.
  • Solve for a target: the value of one input that brings an output to a target.