Two wires, many boards
CAN is two wires that every board on the bus shares as an equal. There is no master: any board can start a message, every board hears every message, and when two start at once the bus itself decides who goes first. A 0 is driven and a 1 is left alone, and that one rule is where everything else comes from.
Two wires, a difference
CAN sends each bit on two wires, CANH and CANL, and the receiver reads the difference between them. Noise that reaches the cable lands on both wires alike and cancels in the difference, which is why CAN runs in cars and factories, next to motors, for tens or hundreds of metres.
A 0 is driven, a 1 is left alone
That is the rule that makes CAN different. To send a 0 a board drives the wires apart: CANH up, CANL down, about 2 V between them. That is called dominant. To send a 1 a board lets go. The wires drift back together, pulled by the resistors at the ends of the bus, and the difference falls to nothing. That is recessive.
Two boards can drive the bus at the same moment without harm. If any board drives a 0, the bus is 0; it is 1 only when every board lets go. Every board also reads the bus while it sends, so a board that sends a 1 and reads back a 0 knows at once that somebody else is talking.
What that buys
- No master. Any board can start a message whenever the bus is idle.
- No collisions lost. When two start together, the bus decides who goes first without spoiling either message: Dominant wins.
- Every message checked. Every frame carries a checksum and must be acknowledged by another board: Every message is acknowledged.
None of that is in your sketch. It is done by the CAN controller inside your microcontroller, and this block is the part between that controller and the two wires.
When it does not work
Both send a difference down two wires, and that is where the likeness ends. RS485 is only a way to move bits: who talks when is up to your sketch. CAN adds the rules in hardware: messages with identifiers, the bus deciding who goes first, every message acknowledged and checked. The CAN controller in your microcontroller does all of that.
No. Every board on a CAN bus is equal: any of them can send whenever the bus is free, and every one receives everything. A sketch that listens for one identifier and ignores the rest is how a board picks its own messages.
The same physical layer, ISO 11898-2 high-speed CAN, so the voltages are the same. But a car's bus runs its own bit rate and messages, and a wrong frame on it can upset real systems. Learn on your own bench bus first, and only listen, never send, on a vehicle.
Four pins to your microcontroller, three to the bus, and what the board does not bring.
What is on the board →Edit this page — content/books/can-bus/two-wires-many-boards.mdx
Questions about this product
See what other owners have asked, and read their solutions.
CAN Bus
Loading discussions…
Discuss this article
Ask about this page. The answer stays here, on the page it belongs to, for whoever hits the same wall next.