A Scheduling Method for CAN Data Transmission and Reception
By scheduling data transmission and reception on the CAN bus, calculating the periodic and non-periodic data transmission and reception times of multiple devices, optimizing the data transmission and scheduling of the CAN bus, solving the problem that the load situation and data timeliness of the CAN bus in the prior art are not effectively considered. The problem of this achieves efficient and timely data transmission.
Patent Information
- Application Number
- CN202310113174.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-15
- Publication Date
- 2025-02-14
- Estimated Expiration
- 2043-02-15
AI Technical Summary
The existing CAN bus data arbitration mechanism fails to effectively consider the CAN bus load situation and data timeliness, resulting in delayed data acquisition when multi-device interaction.
By scheduling data transmission and reception on the CAN bus, the periodic and non-periodic data transmission and reception times of multiple devices are calculated, the data transmission scheduling of the CAN bus is optimized, and the data transmission scheduling of the CAN bus is collected within the maximum delay time, ensuring timeliness and reliability.
It realizes efficient data transmission within the maximum delay time, reduces the load of the CAN bus, solves the problem of data delay, and ensures the timeliness and reliability of data.
Smart Images

Figure CN116112311B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of CAN data, and in particular to a scheduling method for sending and receiving CAN data. Background Art
[0002] With the continuous progress of industrial measurement and control technology and production automation technology, traditional communication technologies such as RS-232, RS-485 and CCITTV.24 can no longer meet the needs of modern industrial control. The emergence of fieldbus has gradually become a new type of communication technology in the field of industrial measurement and control with its low price and reliable performance. CAN bus has become the most widely used fieldbus in the world due to its high reliability and good error detection ability. However, there are often multiple devices on the vehicle that need to process the data on the CAN bus, and the data transmission and reception of the CAN bus requires a certain amount of time (to reduce the load condition of the CAN bus).
[0003] The previous CAN data arbitration mechanism only arbitrates data sent by multiple nodes at the same time through the ID of the frame arbitration segment. The unit with high priority continues to send, and other units immediately stop sending and enter the receiving state. In actual situations, the load of the CAN bus and the timeliness of the data are not considered. In the face of the load of the CAN bus, the data transmission of the CAN bus requires a time interval, so it is necessary to increase the CAN data transmission delay. When multiple devices need to interact with the CAN bus for data, simply using the priority to interact with the device for data will cause other devices to obtain data, and there is a delay problem. For example, the Chinese patent with application publication number CN 113923073 A discloses a method for allocating IDs on the CAN bus and a CAN bus system. All nodes on the CAN bus participate in the host competition through the competition bus. The winning node acts as the host and the non-winning node acts as the slave. All nodes upload their serial numbers and IDs to the CAN bus, and all nodes on the bus receive and store the uploaded serial numbers and IDs of each node. The host records whether the ID of each node has been allocated by setting the variable allocation flag. The node to be allocated requests the host to allocate an ID through the ID allocation request command. The host determines whether the ID and serial number of the node to be allocated conflict with the serial numbers and IDs of other nodes that have been stored. If there is no conflict, the host allocates the original serial number and original ID and updates the variable allocation flag accordingly; if there is a conflict, the host allocates the original serial number and new ID and updates the variable allocation flag accordingly; the allocated information is allocated to the node to be allocated via the CAN bus through the ID allocation command.
[0004] This patent is aimed at the data transmission and reception of the CAN bus, and adopts its inherent mode, either by using the ID allocation priority method or by using the priority mechanism of the microcontroller for data processing. However, when multiple devices need data from the CAN bus, the load of the CAN bus on the industrial vehicle is not taken into account. Therefore, the current situation is that the data transmission and reception of the CAN bus requires a time interval. When there is a time interval between the data transmission and reception of the CAN bus, it is essential to focus on the timeliness of the data.
[0005] Therefore, it is a problem worth studying to provide a scheduling method for CAN data reception and transmission by scheduling data reception and transmission on the CAN bus and calculating the periodic and non-periodic data reception and transmission times of multiple devices that need to be on the CAN bus. Summary of the invention
[0006] The object of the present invention is to provide a scheduling method for CAN data reception and transmission by scheduling data reception and transmission on a CAN bus and calculating the periodic and non-periodic data reception and transmission times of a plurality of devices requiring the CAN bus.
[0007] The object of the present invention is achieved in that:
[0008] A scheduling method for CAN data transmission and reception includes the following steps: Step 1: Status data setting: setting the number of devices that need to perform CAN data transmission and reception, determining the data transmission and reception time required for each device, and setting a maximum delay time; ensuring that the required CAN data is received within the maximum delay time, ensuring the timeliness of this process.
[0009] Step 2: Scheduling mechanism for periodic CAN data transmission and reception: when periodic data is sent, the data processing status of the CAN bus, whether the total time of data acquired by the CAN device, serial port device, and platform module device is less than the maximum delay time, if the total time of data acquired by the CAN device, serial port device, and platform module device is less than the maximum delay time, then the optimal weight and the number of related data transmissions are obtained; if the total time of data acquired by the CAN device, serial port device, and platform module device is not less than the maximum delay time, then return to step 1 to set the number of related data transmissions; ensure that the periodic CAN data can collect relevant data within the maximum delay time, and ensure the timeliness and reliability of its data;
[0010] Step 3: Periodic and Aperiodic CAN Data Transceiver Scheduling Mechanism: When periodic and aperiodic data are sent, the data processing situation of the CAN bus, and whether the total time of the data obtained by the CAN device, serial port device, and platform module device is less than the maximum delay time. When the total time of the data obtained by the CAN device, serial port device, and platform module device is less than the maximum delay time, the optimal weight and the relevant number of data transmission lines are obtained. When the total time of the data obtained by the CAN device, serial port device, and platform module device is not less than the maximum delay time, return to Step 1 to set the relevant number of data transmission lines to perform data transmission with the highest efficiency, reduce the load of the CAN bus, and solve the data latency problem; ensure that periodic and aperiodic CAN data can collect relevant data within the maximum delay time to ensure the timeliness and reliability of the data.
[0011] In Step 2, the data acquisition of the CAN device, serial port device, and platform module device for the CAN bus is periodic, and the number of CAN buses obtained by the three are dx, dy, and dz respectively. The time for sending and receiving one piece of data is x ms, y ms, and z ms; and the time interval for sending CAN data is set to P ms; the maximum delay is set to Tlimit; calculate the total time of the data obtained by the CAN device, serial port device, and platform module device within one cycle by the following formula:
[0012] Tcycle = 2 * (dx * x + dy * y + dz * z) + (dx + dy + dz) * p + (dx + dy + dz) * 2x;
[0013] Tcycle < Tlimit.
[0014] In Step 3, when both periodic data and aperiodic data exist, the time is:
[0015] Ts = Tcycle + Tn; Tn is the aperiodic time, and Tn is at least one of the CAN device data, serial port device data, and platform device data; Tn represents the total time, the sum of the periodic time and the aperiodic time, and Tcycle represents the periodic time.
[0016] When parsing the aperiodic time and the periodic time simultaneously, it is necessary to set the weight ratio for the periodic data and the aperiodic data to optimize the CAN scheduling mechanism. Set the weight of the periodic data to a and the weight of the aperiodic data to b, a + b = 1. The formula is as follows:
[0017] Then Ts = a * Tcycle + b * Tn, Ts < Tlimit; Tlimit is the maximum delay time;
[0018] According to the maximum delay time set by timeliness, the optimal weights a, b and the optimal number dx, dy, dz of data received by CAN devices, serial port devices, and platform module devices are calculated; therefore, according to the optimal weights a, b and the optimal number dx, dy, dz of data received by CAN devices, serial port devices, and platform module devices, the scheduling of CAN bus data reception and transmission is optimized to maximize data transmission efficiency, reduce the load of the CAN bus and solve data delay problems.
[0019] The beneficial effects of the present invention are as follows: the present invention optimizes the scheduling of CAN bus data reception and transmission, performs data transmission with maximum efficiency, reduces the load of the CAN bus and solves the problem of data delay. The present invention calculates the periodic and non-periodic time of data reception and transmission to optimize its data reception and transmission efficiency; the present invention calculates the weights of periodic and non-periodic data reception and transmission to schedule data according to its timeliness; in addition, the present invention calculates the number of data transmissions and receptions of related equipment, optimizes the data reception and transmission scheduling of the CAN bus, and ensures the most efficient data reception and transmission within the timeliness. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1 is a flow chart of the present invention;
[0021] Figure 2 It is a schematic diagram of the structure of the present invention. Implementation
[0022] The present invention will be further described below with reference to the accompanying drawings and embodiments. Figure 1 As shown, a scheduling method for CAN data transmission and reception includes the following steps: Step 1: Status data setting: Set the number of devices that need to transmit and receive CAN data, determine the data transmission and reception time required for each device, and set the maximum delay time; ensure that the required CAN data is received within the maximum delay time, and ensure the timeliness of this process. Suppose the transmission and reception time of CAN device data is xms, the transmission and reception time of serial port device time is yms, the data transmission and reception time of platform module device is zms, and the CAN data transmission and reception time of terminal device is the same as that of CAN device. Set the soft delay time interval to reduce the load of the device terminal CAN when sending it to pms. Parse the received data, and set the number of CAN messages that need to be sent to degree (d).
[0023] like Figure 2 As shown, for example: there are three devices that need terminal CAN device data, such as platform terminal device, serial port device, and a CAN device, and send data to our device terminal at the same time. The terminal device needs to query the receiving device for data and obtain relevant data. This requires corresponding CAN bus data scheduling to ensure the timeliness of the data.
[0024] Step 2: Scheduling mechanism for periodic CAN data transmission and reception: When periodic data is sent, the data processing status of the CAN bus, whether the total time of data obtained by the CAN device, serial port device, and platform module device is less than the maximum delay time, if the total time of data obtained by the CAN device, serial port device, and platform module device is less than the maximum delay time, then the optimal weight and the number of related data transmissions are obtained, if the total time of data obtained by the CAN device, serial port device, and platform module device is not less than the maximum delay time, then return to step 1 to set the number of related data transmissions; ensure that the periodic CAN data can collect relevant data within the maximum delay time, and ensure the timeliness and reliability of its data. The data acquisition of the CAN bus by the CAN device, serial port device, and platform module device is periodic, and the number of CAN bus lines obtained by the three are dx, dy, and dz respectively, and the time for sending and receiving one data is xms, yms, and zms; and the time interval for sending CAN data is set to Pms; set the maximum delay to Tlimit; calculate the total time of data obtained by the CAN device, serial port device, and platform module device within a cycle as follows:
[0025] Tcycle=2*(dx*x+dy*y+dz*z)+(dx +dy+ dz)*p+ (dx +dy+ dz)* 2x;
[0026] Tcycle <Tlimit。
[0027] Step 3: Scheduling mechanism for sending and receiving data of periodic and non-periodic CAN: When periodic and non-periodic data are sent, the data processing status of the CAN bus, whether the total time of data acquired by the CAN device, serial port device, and platform module device is less than the maximum delay time, when the total time of data acquired by the CAN device, serial port device, and platform module device is less than the maximum delay time, the optimal weight and the number of related data transmissions are obtained, when the total time of data acquired by the CAN device, serial port device, and platform module device is not less than the maximum delay time, return to step 1 to set the number of related data transmissions; perform data transmission with maximum efficiency, reduce the load of the CAN bus and solve the problem of data delay; ensure that periodic and non-periodic CAN data can collect relevant data within the maximum delay time, and ensure the timeliness and reliability of its data.
[0028] When both periodic data and non-periodic data are present, the time is:
[0029] Ts=Tcycle+Tn; Tn is the non-periodic time, Tn is at least one of CAN device data, serial port device data, and platform device data; Tn represents the total time, the sum of the periodic time and the non-periodic time, and Tcycle represents the periodic time.
[0030] When parsing non-periodic time and periodic time simultaneously, it is necessary to set weight ratios for periodic data and non-periodic data to optimize the CAN scheduling mechanism. Set the weight of periodic data as a and the weight of non-periodic data as b, where a + b = 1. The formula is as follows:
[0031] Then Ts = a * Tcycle + b * Tn, Ts < Tlimit; Tlimit is the maximum delay time;
[0032] Based on the maximum delay time set according to timeliness, find the optimal weights a, b and the optimal number of received data dx, dy, dz for CAN devices, serial port devices, and platform module devices; Therefore, according to the optimal weights a, b and the optimal number of received data dx, dy, dz for CAN devices, serial port devices, and platform module devices, optimize the scheduling of CAN bus data transmission and reception, and perform data transmission with the highest efficiency, reduce the load of the CAN bus, and solve the data latency problem.
[0033] In the existing technology, for the data transmission and reception of the CAN bus, its inherent mode is adopted, either using the ID allocation priority method or using the priority mechanism of the microcontroller for data processing. However, when multiple devices require CAN bus data, the load situation of the CAN bus on industrial vehicles is not considered. The CAN load of industrial vehicles is relatively large, resulting in data loss or excessive time and poor timeliness. Using the method provided by this patent, the amount of CAN data required by forklift vehicles is relatively large. Therefore, we optimize the algorithm on forklift vehicles and optimize the CAN data sending situation. It is found that when applying this solution, there will be no situation where data is lost or the parsing time is too long and the timeliness is poor when one device sends CAN data to another device.
[0034] This invention optimizes the scheduling of CAN bus data transmission and reception, performs data transmission with the highest efficiency, reduces the load of the CAN bus, and solves the data latency problem. This invention calculates the periodic and non-periodic times of data transmission and reception to optimize its data transmission and reception efficiency; This invention calculates the weights of periodic and non-periodic data transmission and reception and schedules data according to its timeliness; In addition, this invention calculates the number of data transmission and reception of related devices to optimize the scheduling of CAN bus data transmission and reception, ensuring the most efficient data transmission and reception within the time limit.
Claims
1. A scheduling method for CAN data transmission and reception, characterized in that: The following steps are included: Step 1: Status data setting: set the number of devices that need to send and receive CAN data, determine the data sending and receiving time required for each device, and set the maximum delay time; To ensure that the required CAN data is received within the maximum delay time, ensuring the timeliness of this process; Step 2: Scheduling mechanism for periodic CAN data transmission and reception: After setting the number of devices for CAN data transmission and reception in step 1, when periodic data is sent, the data processing status of the CAN bus, whether the total time of data acquired by the CAN device, serial port device, and platform module device is less than the maximum delay time, when the total time of data acquired by the CAN device, serial port device, and platform module device is less than the maximum delay time, the optimal weight and the number of related data transmissions are obtained; when the total time of data acquired by the CAN device, serial port device, and platform module device is not less than the maximum delay time, return to step 1 to set the number of related data transmissions; to ensure that the periodic CAN data can collect relevant data within the maximum delay time, and ensure the timeliness and reliability of its data; Step 3: Data transmission and reception scheduling mechanism for periodic and non-periodic CAN: After the operation in step 2, when periodic and non-periodic data are sent, the data processing status of the CAN bus, whether the total time of data acquired by the CAN device, serial port device, and platform module device is less than the maximum delay time, when the total time of data acquired by the CAN device, serial port device, and platform module device is less than the maximum delay time, the optimal weight and the number of related data transmissions are obtained, when the total time of data acquired by the CAN device, serial port device, and platform module device is not less than the maximum delay time, return to step 1 to set the number of related data transmissions; perform data transmission with maximum efficiency, reduce the load of the CAN bus and solve the problem of data delay; ensure that periodic and non-periodic CAN data can collect relevant data within the maximum delay time, and ensure the timeliness and reliability of its data; In step 2, the CAN device, serial port device, and platform module device obtain data from the CAN bus periodically, and the number of CAN bus lines obtained by the three are dx, dy, and dz respectively, and the time for sending and receiving one data line is xms, yms, and zms; and the time interval for sending CAN data is set to Pms; the maximum delay is set to Tlimit; and the total time for the CAN device, serial port device, and platform module device to obtain data within one cycle is calculated as follows: Tcycle=2*(dx*x+dy*y+dz*z)+(dx +dy+ dz)*p+ (dx +dy+ dz)* 2x; Tcycle < Tlimit; In step 3, when both periodic data and non-periodic data are present, the time is: Ts=Tcycle+Tn; Tn is the non-periodic time, Tn is at least one of CAN device data, serial port device data, and platform device data; Ts represents the total time, the sum of the periodic time and the non-periodic time, and Tcycle represents the periodic time; When analyzing both non-periodic time and periodic time, it is necessary to set a weight ratio for periodic data and non-periodic data to optimize the CAN scheduling mechanism. Set the periodic data weight to a, the non-periodic weight to b, a+b=1, and the formula is as follows: Then Ts=a*Tcycle+b*Tn, Ts< Tlimit; Tlimit is the maximum delay time; According to the maximum delay time set by timeliness, the optimal weights a, b and the optimal number dx, dy, dz of data received by CAN devices, serial port devices, and platform module devices are calculated; therefore, according to the optimal weights a, b and the optimal number dx, dy, dz of data received by CAN devices, serial port devices, and platform module devices, the scheduling of CAN bus data reception and transmission is optimized to maximize data transmission efficiency, reduce the load of the CAN bus, and solve data delay problems.
Citation Information
Patent Citations
Method for allocating ID to CAN bus and CAN bus system
CN113923073A
Gateway scheduling method applied to vehicle-mounted CAN-CANFD hybrid network
CN109639596A
A method for controlling can by can coordinator
KR101654720B1