Article content:

What is CAN bus

How the CAN bus works

CAN bus frame composition

CAN bus structure

CAN bus protocol structure

Measured case of CAN bus analysis

What is CAN bus

Controller Area Network (CAN, Controller Area Network) is a serial communication protocol bus used for real-time applications. It can use twisted pair to transmit signals and is one of the most widely used field buses in the world. The CAN protocol is used to communicate between the various components in the car, replacing expensive and bulky power distribution wiring harnesses.

The automotive CAN bus consists of a CAN controller, a CAN transceiver, a data transmission line, and a data transmission terminal. The ECU (engine control unit), TCU (transmission control unit), FEPS (keyless entry and keyless start system), and combination instrument of the CB311 are connected through the CAN bus, and the CAN controller and CAN transceiver are integrated in the in the electronic control unit. The structure of CAN bus is shown in Figure 1.

Figure 1 The overall structure of the CAN bus

Features of the CAN protocol include complete serial data communication, real-time support, transmission rates up to 1Mb/s, 11-bit addressing and error detection capabilities.

How the CAN bus works

The CAN bus uses a serial data transmission method, which can run on a 40m twisted pair at a rate of 1Mb/s, or can be connected by an optical cable, and the bus protocol supports multiple master controllers on this bus.

CAN is similar to the I2C bus in many details, but there are some notable differences. When a node (station) on the CAN bus sends data, it is broadcast to all nodes in the network in the form of a message. For each node, whether or not the data is sent to itself, it is received. The 11-bit characters at the beginning of each group of messages are identifiers, which define the priority of the messages. This message format is called a content-oriented addressing scheme. Identifiers are unique in the same system, and it is impossible for two stations to send messages with the same identifier. This configuration is important when several stations are competing for bus reads at the same time.

When a station wants to send data to other stations, the CPU of the station transmits the data to be sent and its own identifier to the CAN chip of the station, and is in a ready state; when it receives the bus assignment, it turns to send a message state.

The CAN chip organizes the data into a certain message format according to the protocol and sends it out. At this time, other stations on the Internet are in the receiving state. Each station in the receiving state detects the received messages and judges whether these messages are sent to itself, so as to determine whether to receive it. Since the CAN bus is a content-oriented addressing scheme, it is easy to build a high-level control system and configure it flexibly. We can easily add some new stations to the CAN bus without modification in hardware or software. When the provided new station is a pure data receiving device, the data transfer protocol does not require a separate part to have a physical destination address. It allows the synchronization of distributed processes, that is, when the controller on the bus needs to measure data, it can be obtained online, without each controller having its own independent sensor.

The electronic control units of modern automobiles mainly include main controller, engine control system, suspension control system, anti-lock brake control system (ABS traction control system, ASR control system, instrument management system, fault diagnosis system, central door lock system) , seat adjustment system, etc.).

All these sub-control systems are connected to form a real-time control system, that is: after the command is sent, it must be guaranteed to be responded within a certain period of time, otherwise, a major accident may occur. This requires a higher baud rate setting for the cAN communication network in the car. In addition, during the actual operation of the car, a large amount of real-time data exchange is required between many nodes. If all the nodes of the entire car are connected to one CAN network, and many nodes communicate on the CAN bus, and the information management configuration is slightly improper, it is easy to cause the bus load to be too large, resulting in a decrease in the real-time response speed of the system.

This is not allowed in a real-time system. Therefore, after analyzing the reality of each node on the car, according to the real-time requirements of each node, three CAN communication networks with different rates of high, medium and low speed are designed. The nodes with strict real-time requirements are formed into a high-speed CAN communication network, other nodes with relatively low real-time requirements are formed into a medium-speed CAN communication network, and the remaining nodes with less stringent real-time requirements are formed into a low-speed CAN communication network. And set up a gateway to connect the three communication networks with different rates to realize data sharing among all nodes.

CAN bus frame composition

The CAN bus signal is the frame transmitted in the CAN bus. The frame types in the CAN bus are divided into 5 types, namely data frame, remote frame, error frame, overload frame, and frame interval.

1. Data frame: a frame used by the sending node to transmit data to the receiving node.

2. Remote frame: a frame used by the receiving node to transmit data to the sending node with the same ID.

3. Error frame: a frame used to notify other nodes of an error when an error is detected.

4. Overload frame: a frame used by the receiving node to notify that it is not ready.

5. Frame interval: used to separate the data frame and remote frame from the previous frame.

Standard frame and extended frame:

Both data frame and remote frame can use standard frame format or extended frame format

RTR: remote transmission request bit, data frame is dominant, remote frame is recessive.

SRR: Instead of the remote request bit (in the extended format at the RTR position, hence the name), this bit is a recessive bit. Occupying a bit in this place to keep the standard frame and the extended frame IDE aligned, you can judge that the standard frame takes precedence over the extended frame.

IDE: Identifier extension bit, the standard frame is dominant, and the extended frame is recessive.

R0, R1: reserved bits.

DLC: Data length bits.

CRC: Check Digit.

CRC delimiter: recessive bit

ACK: Acknowledge bit and acknowledgment boundary bit. In the acknowledgement field, the transmitter sends out two recessive bits. After the receiver receives the message, during the response bit, it fills the response bit with the dominant bit as a response, and the response is defined as remaining recessive.

End of frame: Consists of 7 recessive bits.

Data Frame:

SOF Frame Start: The segment at the beginning of the data frame.

Arbitration Field: The segment of this frame priority.

Control field: the number of bytes of data and reserved bits.

Data field: data content.

CRC field: check data.

Acknowledgment Field: A segment that acknowledges normal reception.

End of frame: The segment where the data frame ends.

Remote frame:

By sending a remote frame, a node serving as a data receiver can initiate a data transfer request of its own data source, that is, request the data sender to send a data frame with the same ID. Remote frames have no data segment.

Error frame:

Error Type: Reply Error, Padding Error, CRC Error, Format Error

An error frame consists of a superposition of error flags and a terminator. Error flags are active (positive) error flags and passive (passive) error flags. The active (positive) error flag is 6 dominant bits, and the passive (negative) error flag is 6 recessive bits.

Error positive node: If an error condition is detected, a positive error flag is sent. This will cause other nodes to detect padding errors and start sending error flags. Therefore, the error flag is superimposed between 6 and 12 bits. After the node has sent the error flag, it sends a recessive bit and monitors the bus until a recessive bit appears on the bus, and then sends 7 more recessive bits. Such an error frame is sent.

Error Negative Node: If an error condition is detected, it will attempt to send a Negative Error Flag to indicate this. The passive error node will always wait for 6 consecutive bits with the same polarity, starting from the start of the negative error flag. When 6 consecutive bits of the same polarity are detected, the negative error flag is sent.

Overload frame:

Overload condition: Receiver requests to delay the arrival of the next data frame or remote frame; dominant bit detected in the first and second bits of the interframe intermittent field; if the CAN node is in the 8th of the error delimiter or overload delimiter If the bit is sampled to a dominant bit, the node will send an overload frame and the error counter will not be incremented.

Interframe space:

There must be interframe space in front of the data frame and the remote frame. For active error nodes and passive error nodes, the structure of the interframe space is slightly different. For actively faulty nodes, the frame space consists of a 3-dominant intermittent field and a bus idle. Data frames and remote frames are not allowed in the intermittent field. The length of the bus idle is arbitrary, and when there is a dominant bit, it is considered to be the start of the frame. In addition to the upper two parts of the passive error flag, there are 8 dominant bits pending transmission after the intermittent field. Error passive nodes MUST NOT send data frames and remote frames during the pending transmission phase.

CAN bus structure

In the figure below, the left is the topology of the high-speed CAN bus, and the right is the topology of the low-speed CAN bus.

As shown in the figure, the CAN bus includes two lines, CAN_H and CAN_L. Nodes are connected to the CAN bus through CAN controllers and CAN transceivers.

CAN bus protocol structure

The CAN standard is divided into two categories: the bottom standard (physical layer and data link layer) and the upper standard (application layer). The CAN underlying standard is mainly the international standard of the ISO 11898 series, which means that the physical layer and data link layer of the CAN bus are basically the same for different manufacturers; while the upper layer standard, different application fields or manufacturers will have different practices, so here There is no unified international standard for a piece.

According to the OSI reference model, define the data link layer and the physical layer.

In addition to OSI standardization, SAE J2284, J2411 and other specifications also have similar layers.

Measured case of CAN bus analysis

Automotive control system test case

ECU (Electronic Control Unit) electronic control unit, also known as “trip computer”, “vehicle computer” and so on. In terms of use, it is a special-purpose microcomputer controller for automobiles. Like an ordinary computer, it consists of a microprocessor (MCU), memory (ROM, RAM), input/output interface (I/O), analog-to-digital converter (A/D), and large-scale integrated circuits such as rectifiers and drivers. composition. In a simple word to describe “ECU is the brain of the car”. In order to ensure the smooth operation of the vehicle, the following items are generally required to be tested during the development and testing of the vehicle:

• Timing relationship of multiple ECU control signals • Multiple sensor signals such as rotational speed, fuel injection pulse, crank angle etc. • Decoding and analysis of CAN bus

Reviewing Editor: Tang Zihong

Leave a Reply

Your email address will not be published.