The principles and characteristics of the CAN protocol are specifically described in detailed specifications and international standards. The specification of CAN mainly includes the CAN specification (V2.0)  formulated by Philips Semiconductors in September 1991. The technical specification includes two parts, A and B. Among them, the CAN specification (V2.0A) gives the standard format of CAN messages with an identifier (ID) of 11 bits: CAN specification (V2.0B) gives a standard with an ID of 11 bits and an ID of 29 bits. Extend two CAN message formats. The international standards mainly include: Road Transportation Vehicles-Data Information Exchange-High-speed Communication Controller Area Network, namely the high-speed CAN international standard ISO11898, promulgated by ISO in November 1993. In 1995, the standard was supplemented with the 29-bit CAN extended frame part. , ISO also defines the international standard ISO11519-2 for low-speed, fault-tolerant CAN. In 2004, ISO launched time-triggered CAN for fault-tolerant technology, that is, the TTCAN international standard ISO11898-4.
CAN is a protocol based on the production/consumption model. Unlike the server/client model, CAN is implemented by using a message-oriented transmission protocol. Under this protocol, no site addresses are defined in the network, only messages are defined. Sites that produce messages are called producers, and sites that receive messages are called consumers. Sending and receiving of messages is managed by message identifiers.
The message identifier is unique in the whole network, it not only defines the content of the message, but also defines the priority of the message. The specific transmission mechanism of CAN messages is based on priority competition non-destructive arbitration, that is, non-destructive carrier sense multiple access (CSMA) mechanism. CAN-based systems often have high flexibility in combined configuration, which is reflected in the following aspects: ① It is easier to add and remove nodes in the CAN network, and it is easy to standardize modules; ② When several nodes need the same message at the same time, they can Realize transmission, that is, send more and receive more, which not only saves time but also ensures data synchronization, and the receiver does not need to know the producer; ③The node can receive the information it wants by receiving and filtering, and can realize point-to-point and multi-point-to-point communication; ④Data transmission does not depend on specific types of nodes, and it is easy to realize the upgrade of CAN network.
- The network layered structure of the CAN bus
The CAN protocol follows the ISO/OSI (open system interconnect) network open system model. According to this standard model, the CAN protocol can be divided into two layers, namely the physical layer and the data link layer, and the data link layer is subdivided into logical link control. (logical link control, LLC) sublayer and media access control (media access control, MAC) sublayer.
The operation of the LLC sublayer and the MAC sublayer is monitored by a “fault confinement” entity. Error confinement is a self-checking mechanism that distinguishes between short-term disturbances and permanent failures. The physical layer may be monitored by “bus fault management” and error confinement, an entity that detects and manages physical media failures. The CAN protocol is to establish a common communication mechanism between any two CAN instruments. Compatibility of the CAN protocol includes different aspects such as electrical characteristics and interpretation of data conversion.
The LLC sublayer describes the upper part of the OSI data link layer. The main functions of the LLC sublayer are reception filtering, overload notification and recovery management. Reception filtering means that the LLC sublayer decides whether to receive a packet by screening and screening the entire identifier or part of the identifier of the packet: overload notification means that when an overload condition occurs, the LLC sublayer sends an overload frame to notify, thereby Delay the next data frame or remote frame; recovery management refers to the automatic retransmission function of the LLC sublayer for lost or damaged packets during transmission.
The LLC sublayer (for users) provides two types of connectionless transmission services: non-response data sending services and non-response remote data request services. According to these two services, there are two types of frames from the LLC sublayer to the user:
LLC data frame and LLC remote frame. For both types of frames, the LLC sublayer informs the user whether the frame was successfully sent or received. In addition, the LLC sublayer accepts services provided by the MAC sublayer.
The function of the MAC sublayer: It is the core of CAN and mainly defines the transmission rules, that is, the realization of the control frame structure, the execution of arbitration, error detection, error calibration, fault definition and other functions. When to start sending new messages on the bus and when to start receiving new messages are defined in the MAC sublayer. The MAC sublayer can be divided into two completely independent parts:
Send part and receive part. The physical layer implements physical signal transmission between different nodes. The Bosch CAN protocol has almost no physical layer definition. It is also a CAN-based network, and the physical layer may be quite different. However, the physical layer of all nodes in the same network must be the same. The physical layer protocol is mainly determined by the data transfer rate, cost and reliability. In practical applications, the transmission medium of CAN can use twisted pair, coaxial cable, optical fiber, etc., but in fact, considering the cost, twisted pair is generally used, and shielded twisted pair is used when high speed is required. The data on the CAN bus adopts non-return to zero (NRZ) encoding, and the data bits can have two complementary logics, namely “dominant” and “recessive”. A “dominant” level is represented by a logic “0” and a “recessive” level is represented by a logic “1”. When a twisted pair is used, the signal is transmitted by differential voltage. The two signal lines are called CANH and CANL respectively. Both are about 2.5V in static state. At this time, the state is expressed as logic “1”, which can also be called recessive. When CAN_H is higher than CAN_L, it represents logic “0”, which is called dominant. At this time, the voltage value is usually 3.5V for CANH and 1.5V for CANL, as shown in Figure 1.
- Frame structure of CAN bus
CAN messaging is represented and controlled by the following 4 different frame types.
Data Frame: A data frame carries data from the sending node to the receiving node.
Remote Frame: Request to send a data frame with the same identifier.
Error Frame: An error frame is sent by any unit that detects a bus error.
Overload Frames: Overload frames are used to provide an additional delay between preceding and following data frames (or remote frames).
2.1. Data frame
The data frame defines two forms of the standard frame format with an identifier ID of 11 bits and an extended frame format with an identifier ID of 29 bits. The data frame in both formats consists of 7 different bit fields, namely frame start, arbitration field, control field, data field, CRC field, response field, and frame end. The difference between the standard frame and the extended frame is that the number of ID bits is different, mainly in the structure of the arbitration field and the control field.
1) Frame start
The start of frame is used to identify the beginning of a data frame or remote frame, and its role is to indicate to other nodes on the bus that it wants to send information. It’s only 1 bit. The value of the frame start bit is “0”, and the dominant level is output on the bus. When the bus is idle, its state is “1”, which is a recessive level. When a node wants to send data, it first detects the state on the bus, and if the bus is at a recessive level for a period of time, it can start sending. The first bit sent is the frame start bit, which is a 1-bit dominant level. When other nodes on the bus detect a dominant level “0” on the bus, the bus level changes from “1” to “0”. 0″ as the reference, at the same time, the receiving system starts to receive data.
2) Arbitration Field
The arbitration field is used to represent the identity identifier of the data of the current frame, that is, the information ID. The information ID is used to determine the priority and content of the current frame, and indicates that the current frame is a data frame or a remote frame. In the standard format, the arbitration field consists of 11-bit identifiers and RTR bits; while in the extended frame, the arbitration field consists of 29-bit identifiers, SRR (substitute remote request) bits, IDE (identifier extension) bits and RTR bits.
The identifier is the unique identification number assigned to the CAN message, indicating the content, priority and other information of the data of this frame. The identifier of the CAN specification (V2.0A) standard frame is 11 bits, and the identifier of the CAN specification (V2.0B) extended frame is 29 bits. In the CAN specification (V2.0A) and the CAN specification (V2.0B), there is no specific definition for each bit of the identifier, and various communication associations in Europe and the United States have developed CAN protocols based on CAN protocols for different fields. , each bit of the identifier ID is defined in detail.
When RTR is a dominant level “0”, the frame is a data frame; when RTR is a recessive level “1”, it is a remote frame. SRR, in extended format, this bit is recessive level “1”.
IDE, when the bit is a dominant level “0”, the frame is a standard frame and belongs to the control field: when the bit is a recessive level “1”, the frame is an extended frame and belongs to the arbitration field.
3) Control field
The control field is used to indicate the length of the content of the Benton data field, which consists of 6 bits. In the standard frame format, the first bit is the IDE bit, the second bit is the reserved bit r0, the first two bits are the dominant level, and the first two bits are the dominant level. Bits 3 to 6 are the data length control bits DLC.
In the extended frame format, the first bit is the reserved bit rl, the second bit is the reserved bit r0, the two bits are recessive levels, and the third to sixth bits are the data length control bit DLC. DLC uses hexadecimal to indicate the data length. For example, 0000 represents the data length of the data field is 0 bytes, that is, the data length is 0 bits (b), and 0001 represents the data length of the data field is 1 byte, that is, the data length is 8 bits ( b), 0010 represents that the data field data length is 2 bytes, that is, the data length is 16 bits (b…1000 represents that the data field data length is 8 bytes, that is, the data length is 64 bits (b).
4) Data field
The data field is used to load the data that the data frame needs to transmit. The data field consists of 0~8 bytes, and the length is controlled by the DLC.
5) CRC field
CRC is used to check whether the data has errors during transmission. The CRC field includes the CRC sequence and the CRC delimiter, as shown in Figure 2.
The CRC sequence is a frame check sequence derived from the cyclic redundancy code, and is most suitable for frames with less than 127 bits. For the CRC calculation, the polynomial coefficients to be divided are given by the unstuffed bitstreams consisting of frame start, arbitration field, control field, data field, and the coefficients of the 15 least significant bits are 0. Divide this polynomial by the following polynomial generator with coefficients modulo 2 Figure 3:
The remainder of this polynomial division is the CRC sequence sent on the bus. The implementation of this function can be done using a 15-bit shift register. Following the CRC sequence is the CRC delimiter, which is represented by a separate “recessive bit”.
6) Answer field
The response field is two bits long and includes the response gap and response delimiter. In the reply field, the sending node sends two recessive bits. When the receiving node receives a valid message, the receiver will send a dominant bit to the sending node during the acknowledgement gap to indicate the acknowledgement. All nodes that receive a matching CRC sequence will respond with dominant bits written to the sending node’s recessive bits during the acknowledgement gap. The ACK delimiter is the second bit of the ACK field and must be a recessive bit. The acknowledgement gap is surrounded by two recessive bits, the CRC delimiter and the ACK delimiter.
7) Frame end
Each data frame and remote frame is defined by a flag sequence, which consists of 7 recessive bits.
2.2. Remote Frame
For the remote frame, two formats of standard frame with identifier ID of 11 bits and extended frame with identifier ID of 29 bits are also defined. The remote frame in both formats is also composed of 6 different bit fields, namely frame start, arbitration field, control field, CRC field, response field ACK, and frame end. The difference between remote frame and data frame is that remote frame does not data field. In contrast to data frames, the RTR bit of remote frames is recessive.
2.3. Error frames
The error frame consists of two fields. The first field of the error frame provides the superposition of error flags for different nodes: the second field is the error delimiter. Error flags come in two forms: activation errors and endorsement errors. Activation errors consist of 6 consecutive dominant bits; recognition errors consist of 6 consecutive recessive bits unless overridden by dominant bits of other nodes. The overlapping sequence of error flags is a minimum of 6 bits and a maximum of 12 bits. The error delimiter consists of 8 recessive bits.
The overload frame includes the overload flag field and the overload delimiter. The overload flag consists of 6 dominant bits, and it is the same as the active error flag. The overload delimiter consists of 8 recessive bits. It should be noted that in the process of CAN bus communication, the remote frame is used for the request of the data frame, the node can send the requested data frame after receiving the data request, and the data frame can also be sent to the bus regularly in the form of broadcast, so Remote frames and data frames are generally implemented by software; error frames and overload frames are automatically implemented by hardware (CAN controller and CAN transceiver) in CAN bus communication.
Read more: How are hybrid vehicles coupled?