Bit stuffing in CAN bus

user1688175 picture user1688175 · Aug 7, 2015 · Viewed 8k times · Source

How does the receiving node (CAN bus) know that a bit stuffing is not an actual bit part of the data?

Check this example below. Both are valid streams, but they have different contents:

Valid - Bit stuffed stream (my stuffed zero in bold)

11111010101

Valid - Not bit stuffed stream

11111010101

Answer

Xerxiz picture Xerxiz · Aug 18, 2015

You misunderstood the stuffing concept.

Because there are additional bits stuffed in the data stream. The sender and the receiver know by rule, that after five zeros or five ones the next bit will be an alternated stuffing bit and no data.

Stuffed after five equal bits

111110010101

Without stuffing:

11111010101

So a message with alternating bits will be shorter on the bus, because there are no additional stuffing bits needed.

The stuffing is needed because CAN is an asynchronous bus and it needs a falling or rising edge every five bits for clock resynchronisation between the different CAN controllers.

If the stuffing would start after three bits for example, you could use oscillators on the different controllers with higher tolerances. But this would increase the stuffing overhead and vice versa. So five bits is kind of a trade-off.