What is CAN arbitration and how does it work?
CAN arbitration resolves bus access conflicts through a bit-by-bit comparison: the message with the lowest identifier remains alone on the bus, which gives efficient and loss-free communication.
Decentralized bus access
On a CAN network, bus access is completely decentralized: each participant decides on its own. Since the requests to send from the application processes distributed across the network are usually asynchronous, several participants may start sending at the same time. In general, a participant may only occupy the bus if it was previously free.
Whenever several participants start simultaneously, a selection phase — the arbitration phase — decides which one will remain on the bus. The conflict is resolved by comparing the arbitration fields of the messages bit by bit. This field consists of the message identifier and the RTR bit, which distinguishes a data frame from a remote frame.
In the standard format, the message identifier is 11 bits long; in the extended format, 29 bits. The most significant bit of the identifier is transmitted first.
Dominant and recessive levels
Bit-by-bit arbitration is based on the distinction between two physical bus levels: a dominant (overriding) level and a recessive (yielding) level. Such level ratios are easily depicted, for example through an open collector activation, that is, a “wired-and” connection.
In this example, the bus is only at H level (5 V) if none of the participants pull the bus line to the L level. The H level therefore corresponds to the recessive level, the L level to the dominant level. These level ratios can also be represented using optical media: the “dark” state then represents the recessive level and the “light” state the dominant level.
As long as the bus is free, it remains at the recessive level. The participant that occupies it signals this by switching on a dominant bit, the start of frame (SOF).
How arbitration runs
During the arbitration phase, each sending participant compares the level it switched on with the level actually present on the bus. Any participant that has sent a recessive bit and observes a dominant bit immediately stops its attempt and becomes the consumer of the message sent by another. Provided that an identifier is only assigned to one message and that a logical zero is represented by a dominant level, only the participant whose message has the lowest identifier value remains on the bus at the end of the arbitration. The message priority is therefore higher, the lower the value of its identifier.
Bit-by-bit arbitration based on the identifier thus ensures that, in the event of simultaneous occupation, only one participant remains on the bus. The message it sends is not destroyed: the arbitration is loss-free.
In the event that the transfer of a given message is initiated at the same time by a producer as a data frame and by a consumer as a remote frame, the conflict cannot be resolved by the identifier alone. In that case the RTR bit, which follows the identifier, decides the bus access right.
A consequence for the network size
The principle of bit-by-bit arbitration assumes that a participant compares the value of the bit it switched on to the value actually present on the bus. When determining the earliest possible sampling time after switching on a bit, the maximum signal propagation times between participants and the internal delays must be taken into consideration. Arbitration therefore limits the maximum possible network expansion at a given data rate — which is the subject of our article on CAN bit rate and line length.