CAN communication common problems and solutions
CAN (Controller Area Network) is a multi-host local network serial communication protocol developed by the German Bosch company in the early 1980s to solve the problem of data exchange between numerous electronic control units (ECUs) in modern automobiles. Due to its high performance, high reliability and unique design, it has attracted more and more attention and is widely used in many fields.
The CAN bus application environment is complex and diverse, and various abnormal situations may occur. The following will analyze common CAN interface abnormal situations and solutions.
- CAN bus wiring problem
Common wiring errors for CAN transceivers include incorrect wiring of RXD and TXD connected to the CAN controller, and incorrect wiring of CANH and CANL connecting the CAN transceiver to the transceiver.
The TXD pin of the CAN transceiver is a data input pin and needs to be connected to the TXD output pin of the controller. The RXD pin of the CAN transceiver is a data output pin and needs to be connected to the RXD input pin of the controller. RS485 and RS232, which use Tx to indicate transmission and Rx to indicate reception, have different definitions. Engineers who are first exposed to CAN transceivers may connect TXD and RXD in reverse according to their habits, resulting in inability to communicate.
The CAN transceiver's CANH pin needs to be connected to the CANH pin of the other transceiver, and CANL needs to be connected to CANL. Connecting CNAH and CANL reversely will cause communication abnormalities.
- The problem of voltage mismatch between CAN transceiver and controller
For systems using multiple voltages, it may happen that the CAN transceiver power supply is 5V and the controller power supply voltage is 3.3V. Judging from the internal structure diagram of the TJA1050, the TXD and RXD pin output voltages are related to the VCC power supply voltage. .
The power supply voltage of the TJA1050 transceiver is generally 5V, so the voltage on the TXD and RXD pins is 5V. At this time, if the power supply voltage of the controller is 3.3V (for example, using STM32F407 as the controller), and the two chips with different power rails are directly connected at this time, it may be because the two chips have different judgment voltages for high and low levels, thus causing communication abnormalities.
Different voltages will also cause the 5V voltage to be input to the 3.3V pin to increase the 3.3V chip terminal voltage.
- No terminal resistor added
The terminal resistance of CAN communication is 120 ohms. During the process of high-speed CAN communication, inductance may occur, which will affect the high and low voltages of CAN communication, making the system unable to distinguish the dominant or invisible levels. Therefore, a terminal resistor is connected in parallel, so that When the impedance is high, current can flow through the terminal resistor, thereby ensuring the normal operation of CAN communication.
- Communication baud rate configuration problem
When designing, we need to consider the bus rate of the CAN bus we want to access. The bus rate needs to be consistent to send and receive data normally.
Sometimes when we are testing, the communication is normal when the number of nodes we connect is small, but when we try to connect more nodes, the CAN network crashes. When this happens, you can check the data waveform on the CAN bus to see if the waveform is deformed. Since the CAN controller has high requirements on control timing, the deformed waveform may cause the waveform timing received by the controller to be incorrect, causing the controller to malfunction. Decoding failed.
- It is easy to be damaged during application. It will be normal after replacing the chip.
This situation usually occurs due to insufficient interface protection of the CAN chip. In complex usage scenarios, strong electromagnetic and electrostatic interference often exist. If the protection capability of the CAN transceiver is not enough, it will be destroyed due to the influence of the external environment. In this case, we need to add a protection circuit or replace the chip with stronger protection capability.