Optimization method for realizing small-period transmission of CAN (Controller Area Network) message
By setting configuration messages for CAN messages and determining whether to send them according to the value of their data field, the on-demand transmission of CAN messages is realized, the problems of bus data congestion and Busoff status are solved, and the quality of CAN messages on the bus is improved. .
Patent Information
- Application Number
- CN202411586488.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-08
- Publication Date
- 2025-02-18
AI Technical Summary
The existing CAN message sending scheme causes the bus load rate to be too high, causing data congestion and delay, and may cause the bus to enter the Busoff state, resulting in error frames.
Set a corresponding configuration message for each frame of the CAN message, and determine whether to send the frame message based on the value of the data field of the configuration message, so as to realize the transmission on demand.
The bus data congestion and Busoff status caused by a large number of small-period packet transmissions are avoided, and the bus load rate is reduced and the quality of CAN packets is improved.
Smart Images

Figure BDA0005124410670000041
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of CAN message, and in particular relates to an optimization method for realizing small-cycle sending of CAN message. Background Art
[0002] The current CAN message sending scheme is to send all periodic messages to the controller or CAN data acquisition device according to the message period defined in the CAN communication matrix, and the period of all messages cannot be too small.
[0003] In the existing scheme, sending a large number of periodic messages may cause the bus load rate to be too high, resulting in bus data congestion and data transmission delay. In addition, if the message cycle is too small and there are too many messages, the bus will enter the Busoff state and generate error frames. Summary of the invention
[0004] The purpose of the present invention is to provide an optimization method for realizing small-cycle sending of CAN messages, which can enable periodic messages to be sent on demand, avoid the bus entering Busoff and generating error frames due to the sending of a large number of small-cycle messages, and can reduce the bus load rate and improve the quality of CAN messages on the bus.
[0005] The technical solution provided by the present invention is:
[0006] An optimization method for implementing small-cycle transmission of CAN messages, comprising:
[0007] Set the corresponding configuration message for each frame message in the CAN message;
[0008] Among them, the value of the data field of the configuration message corresponding to each frame message in the CAN message is different;
[0009] Each time a CAN message is sent, it is determined whether each frame of the CAN message is sent according to the value of the data field of the input configuration message;
[0010] If the value of the data field of the input configuration message is the same as the value of the data field of the configuration message corresponding to a frame message in the CAN message, the message of the frame is sent according to the set period; otherwise, the frame message is not sent.
[0011] Preferably, the attributes of the configuration message are:
[0012] Message ID: 0x123;
[0013] Message sending type: Cyclic;
[0014] Message period: 50;
[0015] Message length: 8.
[0016] Preferably, the value of the data field of the configuration message is in decimal or hexadecimal.
[0017] The beneficial effects of the present invention are:
[0018] The optimization method for realizing small-cycle transmission of CAN messages provided by the present invention can realize on-demand transmission of periodic messages, avoid the bus entering Busoff and generating error frames due to the transmission of a large number of small-cycle messages, reduce the bus load rate, and improve the quality of CAN messages on the bus. DETAILED DESCRIPTION
[0019] The present invention is further described in detail below in conjunction with specific embodiments so that those skilled in the art can implement the invention with reference to the description.
[0020] The present invention provides an optimization method for realizing small-cycle sending of CAN messages, and the specific implementation process is as follows.
[0021] A corresponding configuration message is set for each frame message in the CAN message; wherein the value of the data field of the configuration message corresponding to each frame message in the CAN message is different.
[0022] Each time a CAN message is sent, the value of the data field of the input configuration message determines whether each frame message in the CAN message is sent. If the value of the data field of the input configuration message is the same as the value of the data field of the configuration message corresponding to a frame message in the CAN message, the message of the frame is sent according to the set period; otherwise, the frame message is not sent.
[0023] The attributes of the configuration message are:
[0024] Message ID: 0x123;
[0025] Message sending type: Cyclic;
[0026] Message period: 50;
[0027] Message length: 8.
[0028] The value of the data field of the configuration message is in decimal or hexadecimal.
[0029] Example
[0030] As shown in Table 1, in actual use scenarios, the ten frames of PL2002_Relay--PL2002 do not need to be sent to the bus according to the defined cycle. The optimization method for implementing the small cycle transmission of CAN messages provided by the present invention can enable the above ten frames of messages to be sent periodically as needed according to actual use conditions.
[0031] Table 1
[0032] Message Name Message ID Message sending type Message cycle (ms) Message length PL2002_Relay 0x580 Cyclic 1 8 PL4002_1 0x610 Cyclic 1 8 PL4002_2 0x620 Cyclic 1 8 PL4002_3 0x630 Cyclic 1 8 PL4002_4 0x640 Cyclic 1 8 PL4000_1IN_6OUT 0x560 Cyclic 1 8 PL4000_1IN_3OUT 0x550 Cyclic 1 8 PL4000_1IN_1OUT 0x540 Cyclic 1 8 PL2001 0x510 Cyclic 1 8 PL2002 0x520 Cyclic 1 8
[0033] When designing the CAN database parsing file (DBC file), a configuration message is added to each message frame, and the properties of the configuration message are shown in Table 2. The ten message frames PL2002_Relay--PL2002 are numbered from 1 to 10, and the data field data0 of the configuration message Configuration of each of the ten message frames is set to a different value.
[0034] Table 2
[0035] Message Name Message ID Message sending type Message cycle (ms) Message length Configuration 0x123 Cyclic 50 8
[0036] Each time a CAN message is sent, the value of the data field of the input configuration message determines whether each frame of the CAN message is sent. If the value of the data field of the input configuration message is the same as the value of the data field of the configuration message corresponding to a frame message in the CAN message, the message of the frame is sent according to the set period; otherwise, the frame message is not sent.
[0037] As shown in Table 3, in this embodiment, the data field data0 of the configuration message of the first frame message PL2002_Relay is set to 0x01 (decimal 1), the data field data0 of the configuration message of the second frame message PL4002_1 is set to 0x02 (decimal 2), the data field data0 of the configuration message of the third frame message PL4002_2 is set to 0x03 (decimal 3), and so on, the data field data0 of the configuration message of the tenth frame message PL2002 is set to 0x0A (decimal 10).
[0038] When data0 of the input configuration message Configuration is 0x01 (decimal 1), the first frame message PL2002_Relay message is sent with a period of 1ms, and other frame messages are not sent; when data0 of the input configuration message Configuration is 0x02 (decimal 2), the second frame message PL4002_1 message is sent with a period of 1ms, and other frame messages are not sent; when data0 of the input configuration message Configuration is 0x03 (decimal 3), the third frame message PL4002_2 message is sent with a period of 1ms, and other frame messages are not sent; when data0 of the input configuration message Configuration is 0x0A (decimal 10), the tenth frame message PL2002 message is sent with a period of 1ms, and other frame messages are not sent.
[0039] Table 3
[0040]
[0041] Each time a CAN message is sent, it is possible to determine which frame of message to send according to actual needs and determine the value of the data field of the input configuration message, thereby enabling periodic messages to be sent on demand.
[0042] The optimization method for realizing small-cycle transmission of CAN messages provided by the present invention can realize on-demand transmission of periodic messages, avoid the bus entering Busoff and generating error frames due to the transmission of a large number of small-cycle messages, reduce the bus load rate, and improve the quality of CAN messages on the bus.
[0043] Although the embodiments of the present invention have been disclosed as above, they are not limited to the applications listed in the specification and the implementation modes. They can be fully applied to various fields suitable for the present invention. For those familiar with the art, additional modifications can be easily implemented. Therefore, without departing from the general concept defined by the claims and the scope of equivalents, the present invention is not limited to the specific details and the embodiments shown and described herein.
Claims
1. An optimization method for realizing the small cycle transmission of CAN messages, characterized in that: include: Set the corresponding configuration message for each frame message in the CAN message; Among them, the value of the data field of the configuration message corresponding to each frame message in the CAN message is different; Each time a CAN message is sent, it is determined whether each frame of the CAN message is sent according to the value of the data field of the input configuration message; If the value of the data field of the input configuration message is the same as the value of the data field of the configuration message corresponding to a frame message in the CAN message, the message of the frame is sent according to the set period; otherwise, the frame message is not sent.
2. The optimization method for realizing the small cycle transmission of CAN messages according to claim 1 is characterized in that: The attributes of the configuration message are: Message ID: 0x123; Message sending type: Cyclic; Message period: 50; Message length:
8.
3. The optimization method for realizing the small cycle transmission of CAN messages according to claim 2 is characterized in that: The value of the data field of the configuration message is in decimal or hexadecimal.
