RobotGuide

Hardware & electrical · topic E18 · 25 hours

Field buses: CAN / RS485 / CAN FD

The wire between joints sets the whole machine's real-time ceiling. CAN's non-destructive arbitration is its most elegant design, and the most common interview question: why does the smaller ID win without losing any data?

Specialization stage · Hardcore
System software · Hands-on Embedded & controls · Proficient

Tools
Tools

What to learn

  • Electricals: differential twisted pair, dominant (0) vs recessive (1), and wired-AND implementing arbitration
  • Non-destructive arbitration: the smaller the ID, the higher the priority; the loser backs off automatically and no data is lost
  • Bit stuffing, CRC15, the ACK slot, error frames and error counters (error active → error passive → bus off)
  • Termination: 120 Ω at each end; the classic symptom of a missing end is «occasional errored frames, collapse under load»
  • Bus load arithmetic: frame length (with stuffing) + bit time → worst-case latency; why 10 axes at 1 kHz do not fit on classic CAN
  • CAN FD: arbitration and data phases at different rates, variable-length CRC — why it goes faster
  • RS485: half-duplex, differential, termination and bias resistors, direction-switch delay; Modbus RTU rides on it
  • Be able to use a USB-CAN analyzer to watch arbitration, error frames, and the bus load curve

The lesson · plain words

CAN is the «nerve bus» of vehicles and robots: noise-immune, multi-master, arbitration without loss. Chassis control, joint drives, and AGV command streams almost all run on CAN / CAN FD. This page covers its soul: arbitration.

Arbitration: the smaller ID speaks first, the loser waits its turn

CAN uses wired-AND levels: a dominant bit (0) overrides a recessive bit (1). When several nodes transmit simultaneously, they compare bit by bit — whoever sends 0 keeps going, and whoever sends 1 and hears 0 on the line drops out (it heard itself being overridden). Watch the animation and drag the two IDs: the smaller ID wins the bus, and the losing message does not have to resend a single bit (arbitration is lossless).

That is why CAN needs no master: priority is baked into the ID. Safety messages (e-stop) get small numbers, logs get large ones — natural prioritization.

Interactive figure · drag it and see

What this figure shows: a two-node arbitration animation — node A and node B each with an ID slider (A sends vs B sends, e.g. 0x... vs 0x...), a bit-by-bit clash where the smaller ID (0 is dominant) wins the bus, with notes that arbitration is lossless (the winner resends not one bit), that two nodes with the same ID mean a misconfigured bus, and that small ID = high priority for safety messages while logs get high numbers. Takeaway: priority is written into the ID itself — drag the two IDs and the smaller one always takes the bus, with zero bits wasted.

Electricals and error handling

Two differential wires (CANH/CANL), 120 Ω termination at both ends (matching the bus impedance: missing it causes reflections, doubling it adds load). Wiring topology: a trunk with short stubs (stubs <30 cm); messy star wiring is a bit-error factory.

The error frame mechanism: any node that detects an error broadcasts an error frame, voiding the message for everyone. Error counters are graded: error active → error passive → bus off (automatic offline). «A node suddenly drops off» usually means its own error counter blew past the limit into bus off.

CAN FD and RS485

Classic CAN carries 8 data bytes and tops out at 1 Mbps. CAN FD speeds the data phase to 5 Mbps and 64 bytes — one full frame carries a complete joint state. New projects go straight to CAN FD; the cost is nearly identical.

RS485 lives in another world: half-duplex master-slave polling, no arbitration, cheap and rugged — it is Modbus's carrier. Good for low-speed configuration / telemetry, wrong for real-time control. Do not make RS485 do CAN's job.

How deep to go

Explain the arbitration process and its losslessness; compute bit timing (sample point at 75–80%); read error frames with candump / a logic analyzer; build a test bus with 120 Ω at both ends. With these, you can handle CAN-layer problems independently.

Three questions — do you really get it?

1. During CAN arbitration, the node with the smaller ID...?

  • AWins the bus with priority, and arbitration is lossless
  • BTransmits afterwards
  • CNeeds to retransmit
Show answer

A. Dominant overrides recessive, bit by bit, and the smaller ID wins. The losing node automatically waits for the next round; its data is never corrupted.

2. What do the 120 Ω resistors at both ends of a CAN bus do?

  • ALimit current
  • BPull the level up
  • CImpedance matching — absorb reflections and keep the signal intact
Show answer

C. The twisted pair's characteristic impedance is about 120 Ω. Matched termination prevents reflections — without it, a long bus produces errors outright.

3. A node «suddenly goes offline and stops transmitting». Most likely cause?

  • AError counter overflow into the bus off state
  • BPower cut
  • CID conflict
Show answer

A. error passive → bus off is the protocol's self-protection. Investigate why it kept sending error frames (usually wiring or baud rate).

Keep going deeper

Links without a marker stay on this site; the rest point to the Chinese edition until its translation batch lands.

How it fails in the field

  • Installing only one 120 Ω: a short bus may «look fine», then collapse once it gets longer or more nodes join
  • Assigning IDs carelessly: low-priority frames starve under load, showing up as «one joint occasionally stops responding»
  • Using CAN like Ethernet: chunking a large payload across frames sends latency straight out of control
  • Ignoring error counters: a node's behavior changes after entering error passive, and you cannot find the cause

You have learned enough when

Given 6 joints, 1 kHz per axis, 8 bytes per frame, you can compute the bus load and judge feasibility; you can explain why «smaller ID wins» loses no data; and you can say how the error counters move when a termination resistor is missing.

The Chinese edition carries the full topic page for Field buses: CAN / RS485 / CAN FD, including the complete outline, depth requirements per career track, and further derivations: robotguide.dev/k/E18/.