In principle, two nodes are not allowed to have the same ID segment in a CAN-bus network, but what if the two nodes have the same ID segment?
Before the experiment, we must first have a clear understanding of the structure and composition of CAN messages and the principle of arbitration.
1. CAN message structure
The most widely used CAN-bus network standard is version V2.0. The standard is divided into two parts, A and B. The main difference between them is the length of the ID code in the arbitration area. . Among them, CAN2.0A (standard frame) is an 11-bit ID, and CAN2.0B (extended frame) is a 29-bit ID. The following table 1 is the CAN message structure:
Table 1 CAN message structure
2. Arbitration principle
The CAN bus arbitration is based on the “wire and principle”, as shown in Figure 1. When a transceiver sends signals of different levels at the same time, the recessive level is always covered by the dominant level. The CAN controller will monitor whether the bus status is consistent with the level sent by itself while sending the message. If the inconsistency occurs in the ID segment, arbitration will occur, and if it occurs in other areas, a corresponding error will be triggered.
Figure 1 Schematic diagram of the line “and”
Let’s enter the focus, what if the ID segments of two nodes are the same? We use two CAN cards and a CANScope to start the experiment. The CAN card simulates CAN standard nodes to send and receive messages, and CANScope does communication monitoring, as shown in Figure 2.
Figure 2 Experimental platform construction< /p>
3. Experiment 1 “ID segment is the same but data is different”
Use a CAN card to send a CAN frame with ID 000H and data 01020304050607H, and use another CAN card to send ID 000H data as CAN frame of 02020304050607H. The data monitored by CANScope is shown in Figure 3, and a large number of data field filling errors can be observed.
Figure 3 Data field filling error
Why does this happen? We first obtain the corresponding waveforms of the messages sent by the two CAN cards, as shown in Figure 4. Because the two-pin messages are the same standard data frame, and each frame contains 8 bytes of data, the waveforms corresponding to the two frames of messages are completely consistent in the ID segment, RTR, IDE, R0, and DLC segments. Therefore, the arbitration function becomes invalid, and both nodes think that they have obtained priority and continue to send data.
Figure 4 The corresponding waveform of the message Contrast
Now we focus on the data segment, the first byte has the same data, both are 00H; the second byte has different data, 01H and 02H respectively. At the arrow mark in Figure 5, you can see that the logic of the two corresponding bits are 0 and 1, respectively. Earlier we mentioned that the CAN node will detect whether the bus level is consistent with the level sent by itself when sending the message. If the inconsistency occurs in the non-arbitration area, the corresponding error will be triggered. Therefore, if the two frames of messages are sent to the bus at the same time A bit transmission error is bound to occur. Because the bit sending error will cause the node to send 6 dominant bits that violate the filling rule (active error destroys the frame data), a data field filling error occurs, as shown in Figure 3.
Figure 5 Data field conflict
Fourth, Experiment 2 “The same ID and the same data”
Use two CAN cards at the same time to send CAN with ID 000H and data 01020304050607H Frame, CANScope does communication monitoring. First of all, we do not check the “Bus Response” option to make CANScope work in the monitor-only mode. The result of the experiment is shown in Fig. 6, and what appears is the format error of the response delimiter.
Figure 6 Response delimiter format error
Why does this error occur? The node sending the message will send two recessive bits in the ACK segment. If a dominant level is received during the first bit period, the frame is considered to be received correctly. When the arbitration section is the same, both nodes think that they have obtained the right to arbitrate and wait for a response in the ACK section, but there are only two nodes in the network, so the response cannot be received in the ACK section, and a response delimiter error occurs. Simply put, this situation is similar to that only one node in the bus will not be able to send data. Figure 7 is the waveform comparison when there is no response in the ACK segment.
Figure 7 ACK response
p>
We check the bus response and start the experiment again (there are 3 nodes in the bus at this time). At this time, as shown in Figure 8, the bus data transmission and reception are normal.
Figure 8 Start bus response
Summary: When two nodes send packets with the same ID and different data at the same time, a data field filling error will occur; when two nodes send ID at the same time For the same message with the same data, if other nodes respond, no error will occur, and if no other nodes respond, a response error will occur. Therefore, we should avoid the same ID segment when designing the CAN bus