The CAN protocol is the abbreviation of Controller Area Network. This protocol was originally proposed by the automotive industry. With the development of intelligentization in the automotive industry, more and more electronic instruments are installed inside the car, making the signal line wiring more and more complicated. There is an urgent need for a simple bus protocol that can mount multiple devices to solve this problem. So after it was proposed in the late 1980s, it developed rapidly and officially became ISO11898 and ISO11519 in 1993, a few years later (these two are high-speed applications and low-speed applications respectively).
Since it was mentioned earlier that it was proposed by the automotive industry and later developed into a standard protocol for other industries, it must solve the pain points of internal electronic system communication in the automotive industry, that is, it requires a communication bus with fewer data lines, and the bus needs to be able to mount multiple devices, the delay between communications cannot be large, and it must have the ability to work in complex environments (that is, the so-called strong anti-interference ability). So how is it achieved?
First of all, the most important thing is the two-wire (CANH/CANL) differential signal used by the CAN protocol. Those who understand the 485 protocol should roughly understand the meaning of the differential signal, that is, the voltage difference between the two lines represents the logic 0/1, thereby conveying data. The biggest advantage of the differential signal is anti-interference, because interference will cause similar changes in the levels of the two lines. For example, if an interference causes the voltage of one of the data lines to rise by 20mv at a certain moment, then the other data line in the twisted pair will also be affected in the same way, but the voltage difference between the two lines does not change, that is, it does not affect the correctness of the data. At the same time, due to the small number of data lines, the two-wire system has the characteristics of simple wiring and low cost.
CAN bus communication is carried out through 5 types of frames, namely:
(1): Data frame - a frame used by the sending unit to transmit data to the receiving unit
(2): Remote control frame - a frame used by the receiving unit to request data from the sending unit with the same ID
(3): Error frame - a frame used to notify other units of an error when an error is detected
(4): Overload frame - a frame used by the receiving unit to notify that it is not ready to receive
(5): Frame interval - a frame used to separate data frames and remote control frames from previous frames
The CAN bus is an information arbitration process. When all devices are connected to the CAN bus, as mentioned above, the CAN bus must be able to meet the needs of multiple device mounting, so a complete mechanism is needed to handle the information transmission and reception of multiple devices. When the bus is idle, the unit that sends the message first will get the right to publish information to the bus. When multiple units send data at the same time, arbitration will start from the first bit of the arbitration segment. The more dominant levels are presented, the higher the priority will be.
When the data frame and remote control frame with the same ID appear on the bus, the last bit of the arbitration segment, that is, the data frame with the dominant RTR bit, will have priority.
When the remote control frame or extended format data frame with the same ID appears on the bus, the standard format RTR bit with the dominant RTR bit will have priority.