CAN Bus Arbitration & Bit Stuffing
Bus Arbitration:
Bus arbitration is the mechanism used by the CAN Network while transmitting the message to prevent the conflict between the messages
received and
transmitted by the nodes. During the communication between the nodes, there may be the case that two or more CAN nodes
will start transmitting the
data at the exact same time. This may lead to the corruption of the ongoing message transfer. So to solve this
problem Bus Arbitration came into
the picture.
CAN Arbitration is also known as "Carrier Sense Multiple Access with Collision Detection" or CSMA/CD, which assures that the highest priority
message
should be broadcasted. Message Priority is identified by the value of the identifier in the arbitration field. The lowest the value of
the identifier,
the highest is the priority.
We should always keep in mind that CAN message bits are referred to as "Dominant " (0) or "Recessive " (1). If a node writes a "dominant "
it on the bus,
every other node will read the dominant bit regardless of the value written by that node. If a node transmits a "recessive " bit
and reads back a recessive
a dominant bit it will immediately stop transmitting.
For example, suppose we are having two nodes A and B which are transmitting at the same time and the Node A is having identifier 48 and
Node B is having
identifier 56. When both Nodes transmit the 8th bit of Node B which is recessive (1) has been overridden by the dominant (0)
of Node A. This will make Node B
stop transmitting and the transmission of Node A will continue.
Bit Stuffing:
The bit representation used in the CAN messages is driven by the "NRZ (Non-Return to Zero) " coding method. NRZ is the type of digital data transmission in
which binary "1" usually represents the positive voltage and binary "0" represents some other significant conditions usually
the negative voltages.
But in this NRZ technique, there is a major issue when it is applied to encode the data for a "synchronous" link which may have a long sequence
of consecutive bits
of the same value. Because of this consecutive sequence of the same bits and lack of bit transition, it will prevent the receiver
from regenerating the clock due
to which the receiver will be unable to detect the boundaries of the received message.
The solution for this problem is bit stuffing. In this technique, after every five consecutive same bits the transmitter inserts a bit of opposite
polarity into
the bit stream. On the receiver end this stuff bit will be removed while decoding the message. In this way, bit stuffing plays a very important role in the
generation of the synchronous edges on the receiver side.