Can bus occupies a place in the hardware system. It is one of the most widely used Fieldbus in the world. Different from SPI and UART, it belongs to “high-end and efficient” series.

The origin of CAN bus

Can bus was first developed by Bosch and Intel in the late 1980s. Although it was first used in automotive communication system, with the development of technology, the application scope of CAN bus is no longer limited to automobiles, such as robots, industry and automatic control systems.

Why can bus works so well

Taking the most widely used automobile as an example, the data communication between automobile electronic control systems is basically realized through CAN bus.

In the figure below, the data communication between Motronic control unit and transmission control unit contains five data lines. This is just the transmission line between the two controllers. If we add steering control, wiper control, window control and so on, we need a large number of signal data lines. At this time, the electronic control system circuit of the whole vehicle will be complex, and the maintenance will be very difficult.

o4YBAF_QOZKABJLVAAPk_uqvTZg278.png

If can bus is used, the information between each control unit can be exchanged through two data lines

pIYBAF_QOZiANCQ4AAPcCjOTvEs097.png

Comparison of communication network after using CAN Bus:

pIYBAF_QOZ2AXtzXAAFrYCy5ZHI193.png

Principle of CAN Bus Technology

Can bus uses serial data transmission mode, which can run on 40 m twisted pair at the rate of 1 MB / s. It can also use optical cable connection, and supports multi master controller.

When a node (station) on CAN bus sends data, it broadcasts to all nodes in the network in the form of message. For each node, whether the data is sent to itself or not, it receives it.

pIYBAF_QOaOAAHcYAAHCte76lrM743.png

The software message of CAN bus is in the above group of messages: Arbitration domain, the beginning content of each group of messages, and the first 11 characters are identifiers, which define the priority of the message. This message format is called content-oriented addressing scheme. In the same system, the identifier is unique, so it is impossible for two stations to send messages with the same identifier. This configuration is very important when several stations compete for bus reads at the same time.

The last bit in the arbitration domain is the remote transmission request bit (RTR), which represents whether the information frame is a data frame or a remote request frame without any data

The first two bits are reserved bits. As extension bits, DLC represents the number of data bytes in a frame.

Data field, containing 0-8 bytes of data.

Check field, the cyclic redundancy check field used to check dislocation, 15 bits in total.

The end domain consists of seven recessive levels.

There are five kinds of errors in CAN bus

CRC error: this error occurs when the CRC value of sending and receiving is different;

Format error: the frame format is illegal, and this error occurs;

Response error: the sending node does not receive the response information in the ACK phase, and this error occurs;

Bit sending error: when sending information, the sending node finds that the bus level is inconsistent with the sending level;

Bit fill error: this error occurs when a communication rule is violated on a communication cable.

When one of the five errors occurs, the sending node or the receiving node will send the error frame.

Can bus physical layer

There are three types of interface devices at the node terminal, as shown in the following figure:

pIYBAF_QOaqARy0IAAKRKBpHtXE467.png

The terminal resistance of CAN bus is connected as follows:

pIYBAF_QOa-AKvqOAADckopAHog437.png

The purpose of increasing the terminal resistance is to enhance the reliability of CAN communication and eliminate the reflection interference of CAN bus terminal signal. The two farthest endpoints of CAN bus network usually need to add terminal matching resistance, as shown in the figure above. Generally, if the CAN bus is running on twisted pair, we will increase the resistance by 120 Ω, because the matching resistance is determined by the characteristic impedance of the transmission cable.

Common can controller and transceiver

On the development board, can bus needs controller and transceiver

pIYBAF_QObWACqxPAAI4vHBNP7I470.png

SJA1000 is an independent can controller which is widely used, and the price is very cheap, dozens of yuan. SJA1000 can be combined with 51 MCU and STM32 to build can bus network quickly. SJA1000 is connected with MCU through parallel bus, which needs to be connected through address, data, read-write control and other lines. PCA82C250 transceiver is the physical interface of CAN controller, which can provide differential sending and receiving signals to the bus. Like SJA1000, they all use 5V power supply.

You can buy a home-made can transceiver and a small can controller, for example, you can send data to and receive data from the master controller.

Editor in charge: CC

Leave a Reply

Your email address will not be published. Required fields are marked *