CANOpen Series Tutorial 05: CAN Bus Synchronization, Bit Stuffing, and Priority Determination

Follow Our Public Account for Updates to never miss any news!

CANOpen Series Tutorial 05: CAN Bus Synchronization, Bit Stuffing, and Priority Determination

This tutorial was originally published by the author strongerHuang in September 2018.

Tags: CAN, CANOpen, CanFestival

Copyright: Commercial Use Prohibited

Disclaimer:This document is for personal learning use only. Please contact the author via the public account for authorization if you wish to reprint.

1Introduction

This tutorial continues to update content related to the CAN bus protocol, which is quite important and will directly affect your future programming of the CAN bus. To exaggerate a bit, it will impact your software architecture.

The content of this article is relatively easy to understand, and beginners should take a look.

2

Bit Stuffing

Bit stuffing is a function set to prevent burst errors. When the same level lasts for 5 bits, a bit of inverted data is added.

This function is easy to understand, as shown in the figure below. The bit stuffing does not require programming control and is automatically completed by the controller. Its purpose is also to improve the stability of the CAN bus.

CANOpen Series Tutorial 05: CAN Bus Synchronization, Bit Stuffing, and Priority Determination

(1) Operation of the Sending Unit

When sending data frames and remote frames, if the same level lasts for 5 bits between the SOF and CRC segments, a 1 bit of the inverted level must be inserted in the next bit (the 6th bit).

(2) Operation of the Receiving Unit

When receiving data frames and remote frames, if the same level lasts for 5 bits between the SOF and CRC segments, the next bit (the 6th bit) needs to be deleted before receiving. If the level of this 6th bit is the same as the previous 5 bits, it will be considered an error and an error frame will be sent.

3

Priority Determination

In the previous discussion about “CAN bus differential signals,” explicit and implicit were described. This is actually a characteristic of the CAN bus and is an important function for determining the priority of the CAN bus.

In the idle state of the CAN bus, the unit that starts sending messages first gains the right to send.

When multiple units start sending simultaneously, each sending unit begins arbitration from the first bit of the arbitration segment. The unit that continuously outputs the explicit level the most can continue to send.

CANOpen Series Tutorial 05: CAN Bus Synchronization, Bit Stuffing, and Priority Determination

The above figure describes the process of CAN control arbitration, where unit 2 ultimately gains the right to seize the CAN bus, meaning unit 2 has a higher priority.

When unit 1 fails arbitration, it automatically switches to receiving (originally meant to send, but with a lower priority than others, it starts receiving data. At the same time, the controller will continue to send this uncompleted data in the next round).

3.1 Priority of Data Frames and Remote Frames

When data frames and remote frames with the same ID compete on the bus, the last bit (RTR) of the arbitration segment, with explicit bit data frame, has priority and can continue to send.

The arbitration process of data frames and remote frames is shown in the figure below:

CANOpen Series Tutorial 05: CAN Bus Synchronization, Bit Stuffing, and Priority Determination

3.2 Priority of Standard Format and Extended Format

When standard format ID competes with remote frames of the same ID or extended format data frames on the bus, the RTR bit of the standard format, with explicit bit, has priority and can continue to send.

CANOpen Series Tutorial 05: CAN Bus Synchronization, Bit Stuffing, and Priority Determination

Tip:

For friends who do not understand the differences between data frames and remote frames, standard format and extended format, I recommend referring to my previous article “CANOpen Series Tutorial 04“.

4

Others

The important content of the CAN bus protocol has been discussed here. There are still some less important contents, such as the need to add a 120-ohm resistor between CAN_H and CAN_L in hardware design, transmission distance of the bus, etc.

The upcoming articles will discuss how to program control the sending and receiving of CAN bus data in conjunction with STM32 chip integrated CAN controllers and examples.

5

Notes

1. Some images and text in this document come from the internet and are for personal learning use only. Copyright is reserved, commercial use is prohibited.

2. This article was edited and organized by me alone, so there may be some errors.

3. This article is included in the public account “strongerHuang”. Follow the public account and reply with [CANOpen Series Tutorial] to view the entire series of tutorials.

6Conclusion

If you find this article helpful, remember to give me a thumbs up and share. (Likes are the motivation for the author to update articles)

Scan the QR code below to follow and see more exciting content in the bottom menu!

CANOpen Series Tutorial 05: CAN Bus Synchronization, Bit Stuffing, and Priority Determination

Long press to recognize the QR code in the image to follow

CANOpen Series Tutorial 05: CAN Bus Synchronization, Bit Stuffing, and Priority Determination

Appreciation is recognition and support for the author!

Leave a Comment