What is the CAN bus?
CAN is short for Controller Area Network, developed by the German company BOSCH, which is known for its research and development and production of automotive electronics products. It eventually became an international standard (ISO 11898) and is one of the most widely used fieldbuses in the world.
In North America and Western Europe, the CAN bus protocol has become the standard bus for automotive computer control systems and embedded industrial control local area networks, and there is also the J1939 protocol, which is based on CAN and is designed specifically for large trucks and heavy machinery vehicles.
Features of the CAN bus
(1) It is a multi-master bus, meaning that each node can become a master and the nodes can communicate with each other.
(2) The communication medium can be twisted pair, coaxial cable or optical fiber, and the communication rate can reach 1 mb/s.
(3) The CAN bus communication interface integrates the physical layer and data link layer functions of the CAN protocol, and can complete the framing processing of communication data, including bit stuffing, data block encoding, cyclic redundancy check, priority discrimination and other tasks.
(4) One of the biggest features of the CAN protocol is that it abolishes the traditional station address encoding and instead encodes the communication data blocks. The advantage of this method is that the number of nodes in the network is theoretically unlimited. The identifier of the data block can be composed of 11 or 29 bits of binary numbers, so 2^11 or 2^29 different data blocks can be defined. This data block encoding method also allows different nodes to receive the same data at the same time, which is very important in distributed control.
(5) The maximum data segment length is 8 bytes, which can meet the general requirements of control commands, working status and test data in the industrial field. At the same time, 8 bytes will not occupy the bus time for too long, thus ensuring the real-time performance of communication.
(6) The CAN protocol uses CRC verification and provides corresponding error handling functions, ensuring the reliability of data communication. The excellent performance, high reliability and unique design of the CAN bus make it particularly suitable for interconnecting various measurement and control units in industrial equipment. Therefore, it has received much attention from the industry and is recognized as one of the most promising fieldbuses.
CAN bus working principle
The CAN bus uses serial data transmission and can operate at a rate of 1Mb/s over a 40m twisted-pair cable, or via fiber optic cable. Furthermore, the bus protocol supports multiple master controllers. While CAN shares many similarities with the I2C bus in some details, there are also some significant differences.
When a node (station) on the CAN bus sends data, it broadcasts it as a message to all nodes in the network. Each node receives the data, regardless of whether it is addressed to it.
The first 11 characters of each message group are an identifier that defines the message priority; this message format is called a content-oriented addressing scheme. The identifier is unique within the same system; it is impossible for two stations to send messages with the same identifier. This configuration is crucial when several stations are simultaneously competing to read the bus.
When a station wants to send data to other stations, its CPU transmits the data to be sent and its own identifier to the station's CAN chip and enters a ready state; when it receives a bus allocation, it switches to the message sending state.
The CAN chip organizes data into a specific message format according to the protocol and sends it out. At this time, other stations on the network are in receiving mode. Each station in receiving mode checks the received messages to determine whether they are addressed to it, and then decides whether to accept them.
Because the CAN bus uses a content-oriented addressing scheme, it is easy to build high-level control systems and configure them flexibly. New stations can be easily added to the CAN bus without requiring modifications to the hardware or software.
When the new station provided is a pure data receiving device, the data transmission protocol does not require individual parts to have physical destination addresses. It allows for distributed process synchronization, meaning that when a controller on the bus needs measurement data, it can obtain it from the network without each controller having its own independent sensor.
Advantages of CAN bus
● It has advantages such as strong real-time performance, long transmission distance, strong anti-electromagnetic interference capability, and low cost;
● It adopts a two-wire serial communication method, which has strong error detection capability and can work in high noise interference environment;
● It has priority and arbitration functions, and multiple control modules are connected to the CAN-bus through the CAN controller to form a multi-master local network;
●The message can be received or blocked based on its ID;
● Reliable error handling and detection mechanisms;
● If the sent message is corrupted, it can be automatically resent;
● Nodes have the function of automatically disconnecting from the bus in case of severe errors;
● The message does not contain a source address or destination address; it only uses identifiers to indicate function information and priority information.
Disclaimer: This article is a reprint. If there are any copyright issues, please contact us promptly for deletion (QQ: 2737591964). We apologize for any inconvenience.