Don’t understand CAN protocol? How to avoid bus arbitration failure?

Publisher:ping777Latest update time:2023-02-02 Source: ZLG Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

The CAN bus can be mounted with multiple control units, and each unit can send and receive data. In order to avoid conflicts, the protocol stipulates that only units with high priority can occupy the bus and send data when the channel is idle. So how does the CAN unit What about determining priorities?


How CAN arbitration is implemented


1. The position of CANID in the CAN message


The CANID of each CAN message consists of 11bit/29bits that uniquely identify it. Taking the standard CAN frame as an example, the position of the 11bitCANID in the CAN frame is shown in Figure 1. After SOF is the Identifier. The CANID to be sent out by each node passes CANID arbitration, and messages with high priority are sent first. At the same time, the corresponding node obtains the right to use the CAN bus first, while the node that fails arbitration stops sending data and turns to receiving data. It can only wait for the next SOF moment before arbitration.


1675243312447641.png

Figure 1 Standard CAN data frame format


2. Implementation of CAN bus arbitration mechanism


So how is the priority of CANID determined? In fact, the CAN bus ID arbitration method is equivalent to a "wired AND" structure. The phase AND of dominant (logic 0) and invisible (logic 1) becomes dominant, that is, 0&1=0. The hardware circuit diagram can be referred to Figure 2. The bus arbitration method of the standard CAN frame format is shown in Figure 3. Because the high bit comes first and the low bit comes last, the smaller the value of the CAN identifier, the higher the priority.


7.png

Figure 2 Line and circuit diagram


1675243291720998.png

Figure 3 Bus arbitration mode diagram


Conditions and phenomena for CANID conflicts to occur


1. Conditions for CANID conflict


This article takes our company's protocol conversion module CSM300 as an example to introduce. CSM300 is an embedded CAN and UART/SPI that integrates microprocessor, CAN-bus controller, CAN-bus transceiver, DC-DC conversion, and high-speed digital isolation. Bidirectional conversion module. If we combine two CSM300 modules with IDs 00 00 00 00 to form a CAN bus network system, arbitration will fail when these two modules with the same ID send data to the CAN bus side at the same time.


2. The phenomenon of CANID conflict


Taking CSM300 as an example, the circuit hardware simple connection diagram is shown in Figure 4. Two host computers are used to send a set of data to two modules with the same configuration through two serial ports at the same time. At this time, the two modules will receive the RXD pin at the same time. The received data is converted to the CAN bus terminal. Because the IDs of the two CAN nodes are the same, the CAN bus arbitration fails, and the two sending nodes cannot receive the feedback signal and will always send the last frame of data. At this time, the waveform at the CAN bus end is shown in Figure 5.


9.png

Figure 4 CSM300 circuit connection diagram


1675243270872988.png

Figure 5 CAN bus waveform diagram


How CSM series avoids CANID conflicts


In order to meet applications in different environments, the CSM300 series and CSM100 series have three conversion methods for users to choose: transparent conversion, transparent conversion with logo, and custom protocol conversion, as shown in Figure 6.


11.png

Figure 6 Conversion mode selection diagram


In the transparent conversion mode, the user can configure the module to a different ID through the MCU or host computer to avoid arbitration failure. In the transparent conversion mode, the module does not need to perform additional processing on the data, which maximizes the data conversion speed and also improves the efficiency. Buffer utilization. However, the CANID of each module in this mode cannot be changed after the configuration is completed unless the user configures it again. In addition, in this mode, two sets of UART frames with close time intervals may be recognized as a set of data for conversion, causing data conversion errors.


In the transparent band identification conversion mode, the user can fix the position and length of the CANID in the serial frame during configuration, as shown in Figure 7, and control the CAN frame ID of the sent data by changing the serial frame data, which is convenient for users to send at the same node. CAN data with different IDs. However, in this mode, it is necessary to ensure that the time interval of the serial frames is large enough to avoid data conversion errors caused by the module not being able to correctly identify the end of each group of serial frames. For specific requirements on the minimum interval of serial frames in transparent band identification mode, please refer to the user manuals of CSM100 and CSM300.


12.png

Figure 7 Transparent band logo conversion configuration diagram


Effective custom protocol conversion serial frames include frame header, frame tail, frame ID, frame length, etc. Users can control the CAN frame ID by changing the serial frame data, making it convenient for users to send CAN data with different IDs on the same node. At the same time, the user will fix the frame header and frame tail during configuration, as shown in Figure 8. In this mode, the user informs the module of the frame header, frame tail, and data length of the serial frame through serial frame data. Therefore, this conversion method can effectively avoid errors. Data conversion errors caused by short serial frame intervals.


13.png

Figure 8 Custom conversion configuration diagram


Reference address:Don’t understand CAN protocol? How to avoid bus arbitration failure?

Previous article:Apply the latest CAN bus enhancements for safe and reliable high-speed automotive communications
Next article:Analysis and Countermeasures of Automotive EPB Wire Harness Wire Breakage

Latest Automotive Electronics Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号