With CAN, bus access occurs via the bus participant completely uncoordinated according to the principle of decentralized bus access. Since the requests for sending a message are usually asynchronous for the application processes distributed across the network, it is possible for several participants to simultaneously start sending a message. In general, however, a participant may then only occupy the bus if this was previously free.
Whenever several participants simultaneously start sending a message, a selection phase (arbitration phase) decides which participant may remain on the bus at the end of the selection phase. A bus access conflict like this is resolved by connecting the bits of the message arbitration field bit by bit. The arbitration field of a CAN message consists of the message identifier as well as the RTR bit (remote transmission request bit), which differentiates between a data frame and a remote frame.
In the CAN standard format, the message identifier has a length of 11 bits. In the extended format, the message identifier has a length of 29 bits. The most significant bit of the identifier is transmitted first.
The basis of the bit-by-bit arbitration is the distinction between two physical bus levels, namely a dominant (overriding) and a recessive (yielding) level. Such level ratios can easily be depicted, for example through an open collector activation (“wired-and” connection).
Realization of dominant/recessive level based on a wired-and connection. In the example, the bus level 0 (0 V) is dominant, while the level 1 (5 V) is recessive.
In the example, the bus is then only at H level (5 V) if none of the participants pull the bus line to the L level. The H level thus corresponds to the recessive level, while the L level corresponds to the dominant level. Recessive/dominant level ratios can also be represented using optical media. In this case, a recessive level is represented by the “dark” state, and a dominant level is represented by the “light” state.
As long as the bus is free, it is on a recessive level. A participant that occupies the bus signals this by switching on a dominant bit (start of frame, SOF).
During the arbitration phase, each sending participant compares the bus level it switched on with the actual level present on the bus. Each participant that has sent a recessive bit and observes a dominant bit, immediately stops its arbitration attempt and becomes the consumer of the message being sent by another participant. Under the prerequisite that an identifier is only assigned to one message and that a logical zero is represented by a dominant bus level, only the participant whose message has the lowest identifier value remains on the bus at the end of an arbitration process. The message priority is therefore higher, the lower the value of the identifier assigned to this message.
Example of an arbitration process in the CAN protocol. The participants 1, 2, and 3 start an arbitration attempt at the same time (1). Participant 2 loses the bus access right at time (2), while participant 1 loses the bus access right at time (3). Both participants therefore go into the receiving state; at the end of the arbitration phase (4), only participant 3 has the bus access right and switches its message to the bus.
The underlying bit-by-bit arbitration in the CAN protocol based on the identifier of a message thus ensures that in the event of simultaneous occupation of the bus by several participants, only one participant always remains on the bus. The message sent by this participant is not destroyed here so that this entails a “loss-free” bus arbitration.
In the event that the transfer of a certain message is simultaneously initiated by a producer as a data frame and by a consumer as a remote frame, the arbitration conflict cannot be solved based on the message identifier alone. In this case, the RTR bit (remote transmission request bit) following the identifier decides on the bus access right.
The principle of bit-by-bit arbitration is based on an arbitrating participant comparing the value of the bit it switched on to the actual value present on the bus. When determining the earliest possible sampling time (comparison time) after switching on a bit, the maximum possible signal propagation times between the participants and the participant-internal signal delays must therefore be taken into consideration. The process of bit-by-bit arbitration therefore limits the maximum possible network expansion at a given data rate, i.e., bit duration. However, we will deal with this topic in another blog post.