What is CAN bus? How to apply it?

What is CAN?
There are many ways to classify buses, such as external and internal buses, system buses and non-system buses, etc. No matter what they are, they are called "BUS" in English, which means "bus", which means that a bus is just like a bus. As long as you are on the running route of the bus, you can get on the bus. The boarding point is the bus stop. The same bus is connected and a node (device) is added. The node connection can put the data on the bus and transmit it to other nodes.

The CAN bus is a broadcast type bus. This means that all nodes can listen to all transmitted messages. Messages cannot be sent individually to a given node; all nodes will always capture all messages. However, CAN hardware can provide local filtering functions, allowing each node to respond selectively to messages.
Since the 1980s, there have been more and more automotive ECUs, such as ABS, electronically controlled doors and windows, and electronic fuel injection devices. If the conventional point-to-point wiring method is still used, that is, one end of the wire is connected to the switch and the other end is connected to the electrical equipment, it will lead to a sharp increase in the number of wires on the vehicle, resulting in redundant wiring harnesses and increased maintenance costs. This puts forward higher requirements for the wiring harness distribution and information communication of automobiles. Bus technology can realize real-time sharing of information and solve the problems of many wire bundles, difficult wiring, and high cost in traditional wiring methods. CAN (Controller Area Network) bus technology came into being.
Introduction to CAN bus
The CAN bus was developed by BOSCH, a German company famous for R&D and produc
tion of automotive electronic products, and eventually became an international standard (ISO11519). It is one of the most widely used field buses in the world. The CAN bus is a multi-master bus system. Traditional bus systems such as USB or Ethernet realize the transmission of large amounts of data from node A to node B under the coordination of a bus controller. The messages of the CAN network are broadcast, that is, the data detected by all nodes on the network at the same time is consistent. It is a serial communication bus based on the message broadcast mode.

The many advantages of the CAN bus have made it widely used, such as transmission speed up to 1Mbps, communication distance up to 10km, lossless bit arbitration mechanism, and multi-master structure.
CAN bus standard
The CAN bus standard stipulates the physical layer and data link layer, and the application layer needs to be customized by the user. Different CAN standards only differ in the physical layer. Physical layer and data link layer: ISO11898; Application layer: Different application fields use different application layer standards.


CAN physical layer
CAN topology network
The device connected to the CAN bus is called a node device (CAN Node), and the topology of the CAN network is generally linear. The most commonly used wire harness is a twisted pair, and symmetrical differential level signals are transmitted on the wire. The figure below is a schematic diagram of the CAN bus network. The nodes mainly include Host, controller and transceiver. The Host is often integrated with a CAN controller, which is responsible for processing protocol-related functions to reduce the burden on the Host. CAN transceivers connect the controller to the transmission medium. Usually the controller and bus transceiver are isolated by optocoupler or magnetic coupling, so that even if overvoltage on the bus damages the transceiver, the controller and Host device can be protected.
When sending data, the CAN controller sends the binary code to be sent to the CAN transceiver through the CAN_Tx line, and then the transceiver converts this ordinary logic level signal into a differential signal, which is output to the CAN bus through the differential lines CAN_High and CAN_Low. network. The process of receiving data is the opposite. Using differential signals can achieve better electromagnetic compatibility results. Therefore, the CAN bus physical transmission medium only requires two wires.

The maximum signal transmission rate of the high-speed CAN bus is 1Mbps and supports the longest distance of 40m. ISO11898-2 requires the installation of terminating resistors RL on both sections of the high-speed CAN bus (the terminating resistor is generally 120Ω, because the characteristic impedance of the cable is 120Ω, in order to simulate an infinite transmission line.) to eliminate reflections. The maximum speed of low-speed CAN is only 125Kbps, so ISO11898-3 has no termination requirements.

Because the greater the transmission distance, the greater the signal delay. In order to ensure the correct sampling of messages, the signal rate on the bus must also decrease accordingly. The figure below shows the recommended relationship between signal rate and distance.

CAN transceiver
The CAN bus is divided into high-speed CAN and low-speed CAN, and the transceiver is also divided into high-speed CAN transceiver (1Mbps) and low-speed CAN transceiver (125Kbps). Low-speed CAN is also called Fault
Tolerance CAN means that even if one line on the bus fails, the bus can still communicate. Just like the MAX3232 in the serial port is used for level conversion, the role of the CAN transceiver is to convert logic signals into differential signals.

Differential signals
The CAN bus uses differential signal transmission, and usually only two signal lines are needed for normal communication. In differential signals, logic 0 and logic 1 are represented by the voltage difference between two differential signal lines. When it is at logic 1, when the voltage difference between CAN_High and CAN_Low is less than 0.5V, it is called the recessive level (Recessive); when it is at logic 0, the voltage difference between CAN_High and CAN_Low is greater than 0.9V, it is called the dominant level (Dominant) .
High speed CAN


Low-speed fault-tolerant CAN (Fault Tolerance CAN)
The differential signal is actually obtained by subtracting CAN_LOW from CAN_HIGH. In the logic signal, 5V represents 1, 0V represents 0, and in the differential signal:
● 0V---------logic 1------invisible level
● 2.0V-------logic 0-----dominant level
Dominant levels have higher priority than invisible levels.

The CAN bus follows the "wired AND" mechanism: the "dominant" bit can overwrite the "recessive" bit; the bus is in the "recessive" state only when all nodes send the "recessive" bit. This "wired AND" mechanism makes the CAN bus exhibit dominant priority characteristics.


CAN bus connector

Generally in embedded systems, the CAN interface of the processor MCU comes out with CAN TXD and CAN RXD, which are transmitted with one hand. However, a transceiver is required to actually connect to the CAN network. The transceiver outputs differential signals CANH and CANL, as shown in the figure below. shown

Articles you may also like
Design of High Current H-Bridge Motor Drive Circuit
The working principle, key parameters, and selection of TVS
Understanding NAND Gate: The Universal Logic Gate in Digital Circuits
Gas Discharge Tube Symbols, Characteristics and Structure
-
stmicroelectronics
ARM® Cortex®-M0+ STM32G0 Microcontroller IC 32-Bit Single-Core 64MHz 64KB (64K x 8) FLASH 32-LQFP (7x7)
