Dominant wins
Every CAN message starts with an identifier, and when two boards start at the same instant the identifiers decide who goes first. Each board reads the bus while it sends; the first to send a 1 and read back a 0 stops and listens. The lower identifier always wins, and its message goes out whole.
Identifiers, not addresses
A CAN message carries an identifier, 11 bits in the standard format, so from 0x000 to 0x7FF. It says what the message is (a temperature, a switch, a motor speed), not who it is for. Every board receives every message and keeps the ones it wants.
When two start at once
Both boards send their identifier bit by bit, highest bit first, and read the bus back as they go. While their bits agree, nothing happens. At the first bit where one sends 1 and the other 0, the bus shows 0, because 0 is dominant. The board that sent 1 reads back a 0 it did not send, stops sending, and becomes a listener.
The winner never noticed. Its message carries on without a single bit disturbed, and the loser tries again as soon as the bus is free.
What it means for your sketch
- Lower identifier, higher priority. 0x010 beats 0x100 every time.
- One identifier per kind of message, per board. Two boards sending the same identifier both win arbitration and then collide in the data.
- Nothing to write. Arbitration happens in the CAN controller. The sketch queues a message and the controller sends it when the bus lets it.
When it does not work
Not if both might send it. Two boards sending the same identifier at the same moment both win arbitration and then collide in the data, which shows up as errors. Give each kind of message, from each board, an identifier of its own.
On a busy bus the lowest identifiers always win, so a high identifier waits whenever anything else wants the bus. Send the frequent messages less often, or give the one that matters a lower identifier.
No. It says what the message is, and every board receives every message. A board that only cares about some identifiers sets its controller's acceptance filter, so the rest never reach the sketch.
Edit this page — content/books/can-bus/dominant-wins.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.