How to achieve reliable CAN long byte communication

Publisher:初入茅庐Latest update time:2017-10-12 Source: ZLG致远电子 Keywords:CAN Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Since the 1980s, CAN bus has been gradually applied in a wide range of industrial applications such as automotive electronics, rail transportation, medical electronics, and engineering machinery. The most "unpleasant" thing about this "old" bus is that it can only transmit eight bytes of data in one frame. If you want to transmit longer bytes at a time, you need to split the frame, and choosing a reliable splitting method is what users must pay attention to.


CAN bus, as a bus born for automotive electronics, proposed the control concepts of "automatic arbitration of priority" and "fast transmission of short frames" in order to achieve the fast control goal of "high real-time performance". Using a communication unit of eight bytes per frame has a series of advantages and disadvantages:


1. Advantages and disadvantages of CAN communication:


advantage


(1) 8 bytes are exactly the storage "container" for 8 bytes, 4 16-bit, 2 32-bit, and 1 64-bit variables. Then the user only needs to store the "register address" in the ID, and then "read" or "modify" the corresponding "value" through 1 frame, which is more convenient;


(2) Short frames improve bus sharing speed. Any CAN node needs to compete with other nodes for the bus again after sending a message. In this way, as long as the user designs an appropriate sending interval, it can ensure that all nodes "share" the bus, improve bus utilization, and ensure that the sending cycle of each node is roughly consistent.


shortcoming

  

(1) The data load is low during long data transmission. When sending multiple frames, since the CAN ID must be sent for each frame, the actual CAN data ratio is very low. For example, the CAN extended frame has a 29-bit ID and 64-bit data, resulting in a data load of only 60%. Therefore, when transmitting long data, CAN is not even as good as RS485/Modbus at the same baud rate;

  

(2) Frame loss during long data transmission will cause the entire packet to fail. When more than 8 bytes of data need to be transmitted at a time, it needs to be transmitted in multiple frames. If one of the frames is "lost", the entire packet will be invalid. This requires the receiving node to confirm each frame to ensure the arrival of each frame, which will greatly reduce efficiency;

  

(3) Poor synchronization when transmitting long data. For example, when outputting control commands with more than 8 bytes at the same time, since each frame arrives in a certain order, the first one to arrive will be acted on first, and the last one to arrive will be acted on later, which will cause output asynchrony.

  

It can be seen that the main contradiction of CAN bus in the current mainstream application is concentrated on its 8-byte short frame long data transmission. Therefore, the vast number of scientific and technological workers in the world have developed a series of improvement and reform methods to solve these shortcomings.

  

2. Reliable CAN long data communication:


Upgrade to CANFD protocol to increase data load rate


A few years ago, Mercedes-Benz engineers told the CAN bus developer CiA (CAN in Automatic) that Mercedes-Benz had exhausted CAN. Mercedes-Benz engineers have increased the CAN bus utilization rate to over 90% by continuously optimizing the communication mechanism. There is no bandwidth available, and the only way to expand the data channel is to continuously add new CAN networks through gateways. This has resulted in more and more bus areas in the entire vehicle.


Although in-vehicle Ethernet can solve the problem of data volume, its wiring changes are too large, the cost increases too much, and it is only suitable for communication between gateways. Therefore, the CiA protocol has joined forces with major car manufacturers to develop a new generation of CANFD protocol to quickly upgrade the existing CAN2.0B. Its main content is to increase the data segment of a frame from 8 bytes to 64 bytes, and at the same time increase the baud rate of the data segment to shorten the communication time. As shown in Figure 1.

 

Figure 1 CANFD message improves data load rate

 

In this way, there is no need to send CANID every 8 bytes. Even if the baud rate is not increased, the data load rate is increased by 8 times. If the baud rate is increased by 8 times, the data load rate can be increased by 64 times, which is equivalent to expanding the bandwidth by 64 times. The improvement effect is very obvious.


Use reliable framing protocol


Mature application layer protocols all have reliable framing protocols, such as CANopen, DeviceNET, J1939 protocol, etc. The general principle is the four-process cycle of "handshake", "transmission", "confirmation" and "end". Here we only introduce the SDO multi-frame transmission in the CANopen protocol.


The CAN-ID of the message sent by the sender (client) is 600h+Node-ID. After the receiver (server) successfully receives it, it responds with a message with CAN-ID 580h+Node-ID. The download protocol is shown in Figure 2.

 

 Figure 2 Common SDO download protocol

 

The upload protocol is shown in Figure 3.

 

 

Figure 3 Common SDO upload protocol

 

Synchronous transmission protocol


Synchronous transmission is to achieve synchronous transmission of the entire network, as shown in Figure 4, just like the formation in a military parade, all the soldiers march in neat steps. Here we take the CANopen synchronous message as an example to explain.

 

 

Figure 4 Synchronization protocol and military parade

 

Each node uses the synchronization message as the trigger parameter of PDO (process data). In order to ensure time accuracy, the COB-ID of the synchronization message has a relatively high priority and the shortest transmission time. CANopen uses 80h as the CAN-ID of the synchronization message, as shown in Figure 5.

 

 

Figure 5 Synchronization message

 

Generally, the synchronization message is sent by the NMT (network management) host, and the data of the CAN message is 0 bytes. However, if there are two synchronization mechanisms in a network, different synchronization beats need to be set. For example, some nodes send one PDO per one synchronization frame, and other nodes send one PDO after receiving two synchronization frames.


In the synchronous protocol, there are two constraints:


Synchronization window time: Index 1007h constrains the time limit for the slave node to send PDO after the synchronization frame is sent. That is, the PDO sent within this time is valid, and the PDO that exceeds the time will be discarded. When the synchronization window ends, the actions are executed simultaneously.


Communication cycle: Index 1006h specifies the cycle of the synchronization frame, that is, the cycle of sending the synchronization packet.


Driven by many enthusiasts, CAN bus has been continuously improved and reformed, bringing vitality to this ancient bus. As an important promoter of CAN bus in China, Guangzhou Zhiyuan Electronics Co., Ltd. has provided CANPRO software as a free standard for CANScope bus comprehensive analyzer, which can analyze mainstream CANOpen, DeviceNet, and J1939 protocols.

 

Figure 6 Protocol analysis


Keywords:CAN Reference address:How to achieve reliable CAN long byte communication

Previous article:[Question Solved] How to calculate non-standard CAN baud rate
Next article:Understanding High-Speed ​​Access Unit "ISO11898-2"

Latest Automotive Electronics Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号