Skip to content
Physical AI
All experiments

CAN arbitration and the frame on the wire

Bitwise, non-destructive arbitration: why the lowest identifier always wins; and what a real classical CAN frame looks like bit by bit, with CRC, stuff bits and the CAN_H/CAN_L differential voltages.

Loading simulation…

What it demonstrates

Bitwise, non-destructive arbitration: why the lowest identifier always wins; and what a real classical CAN frame looks like bit by bit, with CRC, stuff bits and the CAN_H/CAN_L differential voltages.

How it works

Three nodes start transmitting at the same instant. On each identifier bit, the bus level is the wired-AND of everything being sent: a dominant 0 overrides a recessive 1. A node that sends 1 but reads 0 stops transmitting and becomes a receiver.

The winning frame is built exactly as a classical CAN 2.0A data frame: SOF, 11-bit identifier, RTR, IDE, r0, DLC, data, a CRC-15 computed over those bits, then bit stuffing (a complementary bit after five equal bits), and the fixed delimiter, ACK, end-of-frame and intermission bits. The waveform maps each bit to typical high-speed CAN voltages. Optional common-mode noise is added equally to both wires, so the differential signal is unchanged.

Adjustable parameters

  • Three 11-bit identifiers (hex)
  • Payload per node (0–8 bytes hex)
  • Common-mode noise on/off
  • Bit rate (125k, 500k, 1M)

Known limitations

  • Only identical-start arbitration on standard 11-bit data frames is shown; remote frames and extended-ID arbitration (SRR/IDE) are not animated.
  • Voltages are idealised square levels: no rise time, ringing or propagation delay.
  • The ACK slot is drawn as dominant, as it appears once at least one receiver has acknowledged.

Equations

busk=⋀i ∈ activebi,k(0=dominant)\text{bus}_k = \bigwedge_{i\,\in\,\text{active}} b_{i,k} \quad (0 = \text{dominant})
Vdiff=VCAN_H−VCAN_L≈{2 Vdominant0 VrecessiveV_{diff} = V_{CAN\_H} - V_{CAN\_L} \approx \begin{cases} 2\,\text{V} & \text{dominant} \\ 0\,\text{V} & \text{recessive} \end{cases}
CRC-15: x15+x14+x10+x8+x7+x4+x3+1\text{CRC-15: } x^{15}+x^{14}+x^{10}+x^{8}+x^{7}+x^{4}+x^{3}+1

Core update rule

for (let b = 0; b < 11; b++) {
  const levels = ids.map((id, i) => (active[i] ? (id >> (10 - b)) & 1 : null));
  const bus = levels.some((l) => l === 0) ? 0 : 1;   // wired-AND
  active = active.map((a, i) => a && levels[i] === bus); // sent 1, saw 0 → back off
}
// stuffing: after five equal bits insert the complement
if (run === 5) { out.push(1 - b); run = 1; }

Explained in Chapter 5: Communication & Firmware