A CAN network load balancing method, apparatus, device and medium

By using the timestamp synchronization and load balancing algorithm of the master ECU node, the transmission time of the slave ECU node is planned, which solves the delay and conflict problems caused by the increase of CAN bus load and realizes stable and real-time signal transmission.

CN116614198BActive Publication Date: 2026-05-05IMOTION AUTOMOTIVE TECH (SUZHOU) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
IMOTION AUTOMOTIVE TECH (SUZHOU) CO LTD
Filing Date
2023-06-30
Publication Date
2026-05-05

AI Technical Summary

Technical Problem

The CAN bus experiences increased load as the number of nodes or the amount of data increases, leading to data transmission delays and conflicts, which affect the real-time performance and stability of signal transmission.

Method used

The master ECU node periodically sends timestamps for clock synchronization, obtains the transmission load of the slave ECU node, plans a time schedule based on a preset balancing algorithm, allocates transmission time points, and ensures that the slave ECU node sends CAN messages according to the schedule.

Benefits of technology

This reduces the peak load on the CAN bus, ensuring the stability and real-time performance of signal transmission, and reducing data conflicts and delays.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116614198B_ABST
    Figure CN116614198B_ABST
Patent Text Reader

Abstract

This application discloses a CAN network load balancing method, apparatus, device, and medium, relating to the field of communication technology and applied to a master ECU node. The method includes: after power-on, sending a local clock timestamp to each slave ECU node at preset time intervals, so that each slave ECU node synchronizes its local clock based on the timestamp; obtaining the transmission load reported by each slave ECU node after synchronizing its local clock, and planning the transmission time points of each slave ECU node based on the transmission load to obtain a time schedule table; and sending the time schedule table to each slave ECU node so that each slave ECU node sends CAN messages at the target time points specified in the time schedule table according to its local clock. In this application, the master ECU node can uniformly schedule the time for slave ECU nodes to send CAN messages based on their transmission load, reducing the peak load of the CAN bus and ensuring the stability and real-time performance of signal transmission.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of communication technology, and in particular to a CAN network load balancing method, apparatus, device, and medium. Background Technology

[0002] CAN (Controller Area Network) is one of the most widely used fieldbuses today. Current CAN NM (Network Management) can implement ordered sleep / wake-up of the CAN bus, keeping it silent when there is no communication requirement.

[0003] The CAN bus is shared by multiple nodes. As the number of nodes on the bus increases or the amount of data transmitted by each node increases, the bus load will increase, potentially leading to increased data transmission latency. Furthermore, collisions may occur when multiple nodes transmit data simultaneously; that is, multiple nodes accessing the bus at the same time cause data conflicts. Although the CAN bus employs collision detection and retransmission mechanisms, collisions can still cause increased transmission latency. The CAN bus uses an identifier-based priority mechanism to handle situations where multiple nodes transmit data simultaneously. Higher-priority frames will gain earlier access to the bus, while lower-priority frames must wait. If the priority settings in the design are unreasonable, when the CAN network experiences transmission peaks during operation, low-priority CAN messages may experience severe periodic fluctuations due to arbitration failure, causing significant delays for frames with high real-time requirements, thus affecting the real-time performance of signal transmission.

[0004] In summary, how to achieve load balancing on the CAN bus to ensure the real-time performance and stability of signal transmission is a problem that needs to be solved. Summary of the Invention

[0005] In view of this, the purpose of this invention is to provide a CAN network load balancing method, apparatus, device, and medium, capable of achieving load balancing on the CAN bus to ensure the real-time performance and stability of signal transmission. The specific solution is as follows:

[0006] In a first aspect, this application discloses a CAN network load balancing method applied to a master ECU node, comprising:

[0007] After power-on, the local clock timestamp is sent to each slave ECU node at preset time intervals so that each slave ECU node can synchronize its local clock based on the timestamp.

[0008] The transmission load reported by each slave ECU node after synchronizing its local clock is obtained, and the transmission time of each slave ECU node is planned based on the transmission load to obtain a time scheduling table.

[0009] The time schedule table is sent to each of the slave ECU nodes so that each slave ECU node can send a CAN message at the target time specified in the time schedule table according to its local clock.

[0010] The step of planning the transmission time points of each slave ECU node based on the transmission load to obtain a time scheduling table includes:

[0011] Based on the preset time interval, the currently allocable first time window and the second time window to be reserved are determined;

[0012] Based on the transmission load and using a preset balancing algorithm, the transmission time points of each slave ECU node are planned within the first time window to obtain a time scheduling table.

[0013] Optionally, the step of sending the timestamp of the local clock to each of the slave ECU nodes at preset time intervals, so that each of the slave ECU nodes can synchronize its local clock based on the timestamp, includes:

[0014] The local clock timestamp is sent to each of the slave ECU nodes at preset time intervals so that each slave ECU node can synchronize its local clock based on the timestamp and the timestamp propagation time.

[0015] Optionally, obtaining the transmission load reported by each of the slave ECU nodes after synchronizing its local clock includes:

[0016] After synchronizing their local clocks, each ECU node determines its transmission load based on the frequency of its CAN message transmission, the data length of the CAN message, and the transmission rate.

[0017] Obtain the transmission load reported by each ECU node.

[0018] Optionally, the CAN network load balancing method further includes:

[0019] Determine whether the current condition meets the preset load balancing criteria. If it does, update the preset time interval and send the timestamp of the local clock to each slave ECU node according to the updated time interval; wherein the updated time interval is greater than the preset time interval.

[0020] Optionally, after sending the time schedule to each of the slave ECU nodes so that each slave ECU node sends a CAN message at the target time specified in the time schedule according to its local clock, the method further includes:

[0021] When a load rebalancing request is received from any of the ECU nodes, the sending time of the ECU node is replanned within the second time window based on the current sending load carried in the load rebalancing request, using the preset balancing algorithm, so as to obtain an updated time scheduling table.

[0022] The updated time schedule is sent to the slave ECU node so that the slave ECU node can send CAN messages at the time specified in the updated time schedule according to its local clock.

[0023] Secondly, this application discloses a CAN network load balancing method, applicable to any slave ECU node, including:

[0024] After power-on, the system acquires the timestamps sent by the main ECU node at preset time intervals and synchronizes the local clock based on the timestamps.

[0025] After synchronizing the local clock, the local transmission load is reported to the master ECU node so that the master ECU node can plan the transmission time of each slave ECU node based on the transmission load to obtain a time scheduling table.

[0026] Obtain the time schedule table sent by the master ECU node, and send a CAN message at the target time point specified in the time schedule table according to the local clock;

[0027] The master ECU node plans the transmission time of each slave ECU node based on the transmission load to obtain a time scheduling table, including:

[0028] The master ECU node determines the currently allocable first time window and the second time window to be reserved based on the preset time interval, and plans the transmission time points of each slave ECU node within the first time window based on the transmission load and using a preset balancing algorithm, so as to obtain a time scheduling table.

[0029] Optionally, after sending the CAN message at the target time specified in the time schedule according to the local clock, the method further includes:

[0030] Detect the actual transmission time of the CAN message sent locally, and obtain the time deviation between the actual transmission time and the target time.

[0031] If the time deviation exceeds a preset deviation threshold, a load rebalancing request carrying the local current transmission load is sent to the master ECU node so that the master ECU node can re-plan the transmission time based on the load rebalancing request.

[0032] Thirdly, this application discloses a CAN network load balancing device applied to a master ECU node, comprising:

[0033] The time synchronization module is used to send the timestamp of the local clock to each slave ECU node at preset time intervals after power-on, so that each slave ECU node can synchronize its local clock based on the timestamp.

[0034] The scheduling table acquisition module is used to acquire the transmission load reported by each slave ECU node after synchronizing the local clock, and to plan the transmission time of each slave ECU node based on the transmission load to obtain the time scheduling table.

[0035] The message sending module is used to send the time schedule to each of the slave ECU nodes, so that each slave ECU node can send a CAN message at the target time specified in the time schedule according to its local clock.

[0036] The scheduling table acquisition module is specifically used for:

[0037] Based on the preset time interval, the currently allocable first time window and the second time window to be reserved are determined;

[0038] Based on the transmission load and using a preset balancing algorithm, the transmission time points of each slave ECU node are planned within the first time window to obtain a time scheduling table.

[0039] Fourthly, this application discloses an electronic device, comprising:

[0040] Memory, used to store computer programs;

[0041] A processor is used to execute the computer program to implement the steps of the aforementioned disclosed CAN network load balancing method.

[0042] Fifthly, this application discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, it implements the steps of the aforementioned disclosed CAN network load balancing method.

[0043] As can be seen, after power-on, the master ECU node in this application sends the timestamp of its local clock to each slave ECU node at preset time intervals, so that each slave ECU node can synchronize its local clock based on the timestamp; obtains the transmission load reported by each slave ECU node after synchronizing its local clock, and plans the transmission time points of each slave ECU node based on the transmission load to obtain a time schedule table; sends the time schedule table to each slave ECU node so that each slave ECU node can send CAN messages at the target time points specified in the time schedule table according to its local clock; wherein, the step of planning the transmission time points of each slave ECU node based on the transmission load to obtain a time schedule table includes: determining the currently allocable first time window and the second time window to be reserved based on the preset time interval; and planning the transmission time points of each slave ECU node within the first time window based on the transmission load and using a preset equalization algorithm to obtain a time schedule table. Therefore, the master ECU node periodically sends its local clock timestamps to each slave ECU node so that each slave ECU node can synchronize its local clock based on the timestamps. The period interval is a preset time interval. After obtaining the timestamps and synchronizing their local clocks, each slave ECU node reports its local transmission load to the master ECU node. The master ECU node then plans the transmission times of each slave ECU node based on these transmission loads to obtain a time schedule table, which is then sent to each slave ECU node so that each slave ECU node can send CAN messages at the target time specified in the time schedule table according to its local clock. Furthermore, when planning the transmission times of each slave ECU node based on the transmission load, the master ECU node needs to determine the currently allocable first time window and the second time window to be reserved based on the preset time interval. First, it uses a preset equalization algorithm to plan the transmission times of each slave ECU node within the first time window to obtain a time schedule table, which is then sent to each slave ECU node. That is, in the initial planning of transmission times, this application does not divide the entire period interval but also reserves a portion of the time window for subsequent planning. In this way, the master ECU node in this application schedules the time for the slave ECU nodes to send CAN messages in a unified manner according to the transmission load of the slave ECU nodes, so as to ensure the stable transmission of CAN messages by each slave ECU node, thereby reducing the peak load of the CAN bus and ensuring the stability and real-time performance of signal transmission. Attached Figure Description

[0044] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.

[0045] Figure 1 This is a flowchart of a CAN network load balancing method disclosed in this application;

[0046] Figure 2 This application discloses a specific CAN network load balancing method flowchart;

[0047] Figure 3 This is a schematic diagram of a specific CAN network load balancing process disclosed in this application;

[0048] Figure 4 This application discloses a specific intention to represent time scheduling.

[0049] Figure 5 This is a flowchart of another CAN network load balancing method disclosed in this application;

[0050] Figure 6 This is a schematic diagram of the structure of a CAN network load balancing device disclosed in this application;

[0051] Figure 7 This is a structural diagram of an electronic device disclosed in this application. Detailed Implementation

[0052] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of the present invention.

[0053] Currently, the CAN bus is shared by multiple nodes. As the number of nodes on the bus increases or the amount of data transmitted by each node increases, the bus load increases, potentially leading to increased data transmission latency. Furthermore, when multiple nodes transmit data simultaneously, collisions may occur, meaning multiple nodes accessing the bus at the same time cause data conflicts. Although the CAN bus employs collision detection and retransmission mechanisms, collisions can still cause increased transmission latency. The CAN bus uses an identifier-based priority mechanism to handle situations where multiple nodes transmit data simultaneously. Higher-priority frames gain earlier access to the bus, while lower-priority frames must wait. If the priority settings in the design are unreasonable, when the CAN network experiences transmission peaks during operation, low-priority CAN messages may experience severe periodic fluctuations due to arbitration failure, resulting in significant delays for frames with high real-time requirements, thus affecting the real-time performance of signal transmission. Therefore, this application discloses a CAN network load balancing method, apparatus, device, and medium that can achieve load balancing on the CAN bus to ensure the real-time performance and stability of signal transmission.

[0054] See Figure 1 As shown in the figure, this application discloses a CAN network load balancing method applied to a master ECU node. The method includes:

[0055] Step S11: After power-on, the local clock timestamp is sent to each slave ECU node at preset time intervals so that each slave ECU node can synchronize its local clock based on the timestamp.

[0056] In this embodiment, after power-on, the master ECU node sends its local clock timestamp to each slave ECU node at preset time intervals, enabling each slave ECU node to synchronize its local clock based on the timestamp. Typically, the preset time interval is set to 10ms, as 10ms is the minimum message period, chosen for rapid time synchronization. However, other times, such as 15ms or 20ms, can be used in specific situations. Assuming a preset time interval of 10ms, the master ECU node sends timestamps at 10ms intervals, and other slave ECU nodes synchronize their local clocks upon receiving the timestamps. It should be noted that the mesh management phase in this embodiment uses the OSEK NM standard, and the power-on process of all ECU nodes follows the OSEK NM network management specification. After the logical ring of all ECU nodes is established, the load-balancing master ECU node takes over network communication control. The master ECU node is typically a gateway node, and this embodiment employs certain security protection mechanisms to improve the stability of the master node.

[0057] Step S12: Obtain the transmission load reported by each slave ECU node after synchronizing its local clock, and plan the transmission time of each slave ECU node based on the transmission load to obtain a time scheduling table.

[0058] In this embodiment, after each slave ECU node obtains a timestamp and synchronizes its local clock, it reports its local transmission load to the master ECU node. The master ECU node then plans the transmission times of each slave ECU node based on the received transmission loads from all slave ECU nodes to obtain a time scheduling table. It should be noted that the transmission load here can refer to the maximum transmission load of a slave ECU node.

[0059] In a specific implementation, obtaining the transmission load reported by each slave ECU node after synchronizing its local clock includes: determining the transmission load by each slave ECU node based on the periodic frequency of its CAN message transmission, the data length of the CAN message, and the transmission rate after synchronizing its local clock; and obtaining the transmission load reported by each slave ECU node. That is, the slave ECU node calculates the maximum transmission load by statistically analyzing the periodic frequency of its CAN message transmission and by combining the data length of the CAN message with the transmission rate. The specific formula is: Maximum transmission load = Data length × Transmission rate / Periodic time; then each slave ECU node reports its local maximum transmission load to the master ECU node.

[0060] Furthermore, it should be noted that the above-mentioned planning of the transmission time points of each slave ECU node based on the transmission load to obtain a time schedule table includes: determining the currently allocable first time window and the second time window to be reserved based on the preset time interval; and planning the transmission time points of each slave ECU node within the first time window based on the transmission load and using a preset balancing algorithm to obtain a time schedule table. That is, in this embodiment, when the master ECU node plans the transmission time points of each slave ECU node according to the transmission load, it needs to determine the currently allocable first time window and the second time window to be reserved based on the preset time interval. First, it uses the preset balancing algorithm to plan the transmission time points of each slave ECU node within the first time window to obtain a time schedule table, and then sends the time schedule table to each slave ECU node. In other words, in this application, when the master ECU node initially plans the transmission time points, it does not divide the entire cycle interval, but only plans within the first time window, and also needs to reserve a portion of the time window for subsequent planning.

[0061] Step S13: Send the time schedule to each of the slave ECU nodes so that each slave ECU node can send a CAN message at the target time specified in the time schedule according to its local clock.

[0062] In this embodiment, the master ECU node sends a time schedule to each slave ECU node. Upon receiving the time schedule, each slave ECU node sends a CAN message at the target time specified in the time schedule according to its local clock. It is understood that the time schedule specifies the time point at which each slave ECU node sends a CAN message. After obtaining the time schedule, the slave ECU node retrieves its own sending time information and then sends the CAN message after its local clock reaches the corresponding sending time. In this way, the master ECU node in this application uniformly schedules the CAN message sending time of the slave ECU nodes according to their sending load, ensuring stable CAN message transmission from each slave ECU node, thereby reducing the peak load on the CAN bus and ensuring the stability and real-time performance of signal transmission.

[0063] Additionally, it should be noted that the above method also includes: determining whether the preset load balancing conditions are met; if so, updating the preset time interval and sending the local clock timestamp to each slave ECU node according to the updated time interval; wherein the updated time interval is greater than the preset time interval. As described above, after the master ECU node powers on, it periodically sends synchronization timestamps to each slave ECU node at a preset time interval, for example, 10ms. However, the time interval is not always maintained at 10ms. In this embodiment, when the network starts, the master ECU node sends synchronization timestamps at a 10ms interval. However, when the time schedule table no longer changes for a period of time or the duration reaches 1000ms (i.e., 100 times), it can be considered that the preset load balancing conditions are met. The preset time interval is then updated, and timestamps are sent for synchronization according to the updated time interval, where the updated time interval must be greater than the preset time interval. In other words, after the preset load balancing conditions are met, timestamp synchronization will be performed at larger intervals, such as a 30,000ms period. The 30,000ms period is merely a specific example provided in this application, and this application does not impose any limitations on it. It is understood that if the time schedule remains unchanged for a period of time, it can be considered that the transmission of messages from each slave ECU node has stabilized. In actual practice or experiments, after 100 consecutive synchronizations with timestamps sent at 10ms intervals and the time schedule planned, the transmission of messages from each slave ECU node usually stabilizes, and the bus load on the CAN network is balanced. Therefore, frequent small-cycle synchronization is unnecessary, achieving the goal of saving computer resources. However, timestamp synchronization is not discontinued afterward; instead, it is performed at larger intervals, such as every 30,000ms, so that the slave ECU nodes can calibrate their local clocks based on the timestamps, thereby adjusting the CAN message transmission window and effectively avoiding the accumulation of transmission errors.

[0064] As can be seen, after power-on, the master ECU node in this application sends the timestamp of its local clock to each slave ECU node at preset time intervals, so that each slave ECU node can synchronize its local clock based on the timestamp; obtains the transmission load reported by each slave ECU node after synchronizing its local clock, and plans the transmission time points of each slave ECU node based on the transmission load to obtain a time schedule table; sends the time schedule table to each slave ECU node so that each slave ECU node can send CAN messages at the target time points specified in the time schedule table according to its local clock; wherein, the step of planning the transmission time points of each slave ECU node based on the transmission load to obtain a time schedule table includes: determining the currently allocable first time window and the second time window to be reserved based on the preset time interval; and planning the transmission time points of each slave ECU node within the first time window based on the transmission load and using a preset equalization algorithm to obtain a time schedule table. Therefore, the master ECU node periodically sends its local clock timestamps to each slave ECU node so that each slave ECU node can synchronize its local clock based on the timestamps. The period interval is a preset time interval. After obtaining the timestamps and synchronizing their local clocks, each slave ECU node reports its local transmission load to the master ECU node. The master ECU node then plans the transmission times of each slave ECU node based on these transmission loads to obtain a time schedule table, which is then sent to each slave ECU node so that each slave ECU node can send CAN messages at the target time specified in the time schedule table according to its local clock. Furthermore, when planning the transmission times of each slave ECU node based on the transmission load, the master ECU node needs to determine the currently allocable first time window and the second time window to be reserved based on the preset time interval. First, it uses a preset equalization algorithm to plan the transmission times of each slave ECU node within the first time window to obtain a time schedule table, which is then sent to each slave ECU node. That is, in the initial planning of transmission times, this application does not divide the entire period interval but also reserves a portion of the time window for subsequent planning. In this way, the master ECU node in this application schedules the time for the slave ECU nodes to send CAN messages in a unified manner according to the transmission load of the slave ECU nodes, so as to ensure the stable transmission of CAN messages by each slave ECU node, thereby reducing the peak load of the CAN bus and ensuring the stability and real-time performance of signal transmission.

[0065] See Figure 2 and Figure 3 As shown, this application discloses a specific CAN network load balancing method. Compared to the previous embodiment, this embodiment further explains and optimizes the technical solution. Specifically, it includes:

[0066] Step S21: After power-on, the local clock timestamp is sent to each of the slave ECU nodes at preset time intervals so that each of the slave ECU nodes can synchronize its local clock based on the timestamp and the timestamp propagation time.

[0067] In this embodiment, during the clock synchronization phase, the bus is idle. Therefore, the clock deviation between the time stamp sent by the master ECU node and the time the time stamp is received by the slave ECU node can be considered a fixed parameter Ta, which can be regarded as the time stamp propagation time. Assuming the time stamp is T0 and the time stamp propagation time is Ta, when the slave node receives the master node's time stamp T0 and sets its own local clock T, T = T0 + Ta. The time stamp propagation time is mainly affected by the bus baud rate and the internal data link of the slave ECU node.

[0068] Step S22: Obtain the transmission load reported by each slave ECU node after synchronizing the local clock, and determine the currently allocable first time window and the second time window to be reserved based on the preset time interval.

[0069] In this embodiment, the transmission load reported by each slave ECU node after synchronizing its local clock is obtained. Assuming there are N slave ECU nodes, the transmission load is denoted as L1, L2, ..., LN. Further, the master ECU node needs to determine the currently allocable first time window and the second time window to be reserved based on a preset time interval. Assuming the preset time interval is 10ms, meaning the master ECU node uses a 10ms scheduling cycle and a 1ms minimum scheduling unit, there are a total of 10 time windows. These 10 time windows need to be further divided into the currently allocable first time window and the second time window to be reserved. In this embodiment, these 10 time windows are denoted as T1, T1, ..., T10. In one specific implementation, time windows T1 to TM (M < 10) can be used as the currently allocable first time windows, and the remaining 10-M time windows can be reserved as second time windows. Under normal circumstances, based on the experience of technicians, the first time window and the second time window are generally divided into a 7:3 ratio, that is, the first time window accounts for 70% of the entire scheduling cycle and the second time window accounts for 30% of the entire scheduling cycle. In specific cases, this can be adjusted, such as according to an 8:2 or 6:4 ratio.

[0070] Step S23: Based on the transmission load and using a preset balancing algorithm, plan the transmission time points of each slave ECU node within the first time window to obtain a time scheduling table.

[0071] In this embodiment, the master ECU node plans the transmission time of each slave ECU node based on the acquired transmission load and a preset balancing algorithm within the first time window to obtain a time scheduling table. The purpose is to ensure that the peak load of each time point within a cycle is balanced as much as possible, and to start sending CAN messages in all of them within that cycle.

[0072] As discussed above, the transmission load is L1, L2, ..., LN, and the first time window is from T1 to TM. Therefore, this problem can be abstracted as dividing N data points into M groups, with the sum of data in each group denoted as S, and finding the allocation scheme that minimizes the variance of the S sequence. Dynamic programming can be used to solve this problem in the pre-defined load balancing algorithm.

[0073] 1. Sort N numbers in non-increasing order.

[0074] 2. Create a two-dimensional array dp of size (N+1)x(M+1), where dp[i][j] represents the minimum variance when the first i numbers are divided into j groups.

[0075] 3. Initialize the boundary conditions of the dp array, that is, when i = 0 or j = 0, the value of dp[i][j] is 0.

[0076] 4. Iterate through the sorted N numbers from i=1 to N.

[0077] 5. Iterate through the number of groups from j=1 to M.

[0078] 6. For each dp[i][j], calculate all possible partition schemes and select the partition that minimizes the variance. The specific steps are as follows:

[0079] For the current number nums[i], add it to the j-th group and update the sum of the j-th group to S;

[0080] Calculate the variance of the j-th data set: variance = (sum[j] / j - nums[i])^2 / j;

[0081] Update dp[i][j] to dp[i-1][j-1]+variance, which represents the minimum variance when the first i numbers are divided into j groups;

[0082] Update the sum[j] of the j-th group to sum[j] + nums[i];

[0083] Choose the scheme that minimizes dp[i][j] in group j.

[0084] 7. The final minimum variance is dp[N][M].

[0085] According to the algorithm described above, all slave ECU nodes are allocated within time windows T1, T2, ..., TM, and the master node uses CANID_T0...CANID_T10 to publish information. For example... Figure 4 As shown, Figure 4 This application discloses a specific time scheduling representation. Figure 4 In this context, M takes the value 7, N takes the value 18, the first time window is T1 to T7, and the number of slave ECU nodes is 18. The scheduling enable of each slave ECU node in each time window is represented by bit fields 0 and 1. If it is 1, it means that the corresponding ECU node needs to send a CAN message at the time point corresponding to that time window. For example, if the time window corresponding to ECU4 is CANID_T4, then ECU4 needs to send a CAN message at T4.

[0086] Step S24: Send the time schedule to each of the slave ECU nodes so that each slave ECU node can send a CAN message at the target time specified in the time schedule according to its local clock.

[0087] In this embodiment, after sending the time schedule table to each of the slave ECU nodes so that each slave ECU node can send CAN messages at the target time point specified in the time schedule table according to its local clock, the method further includes: upon receiving a load rebalancing request from any of the slave ECU nodes, based on the current transmission load carried in the load rebalancing request, replanning the transmission time points of the slave ECU nodes within the second time window using the preset balancing algorithm to obtain an updated time schedule table; and sending the updated time schedule table to the slave ECU nodes so that the slave ECU nodes can send CAN messages at the time point specified in the updated time schedule table according to their local clock. It should be noted that after enabling CAN message transmission, the slave ECU node dynamically detects its local load and determines whether a reallocation of transmission time points is needed. If so, it sends a load rebalancing request to the master ECU node. Upon receiving a load rebalancing request from any slave ECU node, the master ECU node, based on the current transmission load carried in the request, uses the aforementioned preset balancing algorithm to replan the transmission times of the slave ECU nodes within a second time window to obtain an updated time schedule. This updated time schedule is then sent to the slave ECU nodes, enabling them to send CAN messages at the times specified in the updated schedule according to their local clocks. In other words, the master ECU node allocates a reserved time period between M and 10 to the requesting slave ECU nodes. For example, assuming Q slave ECU nodes have all sent load rebalancing requests to the master ECU node, the problem can be abstracted as dividing the Q data into 10-M groups while minimizing the data and variance of each group. In this way, by pre-reserving a second time window, this application ensures that all ECU nodes in the network begin sending messages within a single scheduling cycle, even if any slave ECU node requests a rebalancing of its transmission time.

[0088] For a more detailed explanation of step S24, please refer to the relevant content disclosed in the foregoing embodiments, which will not be repeated here.

[0089] As can be seen, in this embodiment, when the slave ECU node synchronizes its local clock based on timestamps, it also needs to consider the timestamp propagation time. When the master ECU node plans the transmission time of each slave ECU node according to the transmission load, it needs to determine the currently allocable first time window and the second time window to be reserved based on a preset time interval. First, it uses a preset load balancing algorithm to plan the transmission time of each slave ECU node within the first time window to obtain a time schedule table, and then sends the time schedule table to each slave ECU node. After a slave ECU node starts sending packets, if it determines that it needs to redistribute its transmission time, it sends a load rebalancing request to the master ECU node. At this time, the master ECU node then uses the preset load balancing algorithm to replan the transmission time of the slave ECU node within the previously reserved second time window based on the current transmission load carried in the load rebalancing request. In this way, by pre-reserving the second time window, this application can ensure that all ECU nodes in the network start sending packets within a scheduling cycle even if any slave ECU node requests a redistribution of its transmission time, thereby achieving peak load balancing at each time point within a scheduling cycle.

[0090] See Figure 5 As shown in the figure, this application discloses a CAN network load balancing method, applied to any slave ECU node, the method comprising:

[0091] Step S31: After power-on, obtain the timestamp sent by the main ECU node at preset time intervals, and synchronize the local clock based on the timestamp.

[0092] In this embodiment, after the ECU node powers on, it obtains the timestamps sent by the master ECU node at preset time intervals and synchronizes its local clock based on these timestamps. For example, if the master ECU node can send timestamps at 10ms intervals, then the slave ECU node will synchronize its local clock every 10ms interval. Furthermore, the propagation time of the timestamps on the bus must also be considered during synchronization.

[0093] Step S32: After synchronizing the local clock, the local transmission load is reported to the master ECU node so that the master ECU node can plan the transmission time of each slave ECU node based on the transmission load to obtain a time scheduling table.

[0094] In this embodiment, after the slave ECU nodes complete clock synchronization, they report their maximum transmission load to the master ECU node. Upon receiving the maximum transmission load from each slave ECU node, the master ECU node plans the transmission time of each slave ECU node based on the transmission load information to obtain a time scheduling table. That is, the master ECU node schedules the transmission time of CAN messages from the slave ECU nodes according to their transmission loads to ensure stable transmission of CAN messages from each slave ECU node, thereby reducing the peak load on the CAN bus and ensuring the stability and real-time performance of signal transmission.

[0095] It should be noted that the master ECU node plans the transmission time of each slave ECU node based on the transmission load to obtain a time scheduling table. This includes: the master ECU node determining the currently allocable first time window and the second time window to be reserved based on the preset time interval; and planning the transmission time of each slave ECU node within the first time window based on the transmission load and using a preset balancing algorithm to obtain the time scheduling table. That is, the master ECU node needs to divide the preset time interval into two time windows. When initially planning the transmission time, it does not divide the entire period interval, but only within the first time window, and also reserves a portion of the time window for subsequent planning.

[0096] Step S33: Obtain the time schedule table sent by the master ECU node, and send a CAN message at the target time point specified in the time schedule table according to the local clock.

[0097] In this embodiment, the time schedule table sent by the master ECU node is obtained, and a CAN message is sent at the target time point specified in the time schedule table according to the local clock.

[0098] Furthermore, after sending the CAN message at the target time specified in the time scheduling table according to the local clock, the process further includes: detecting the actual sending time of the local CAN message and obtaining the time deviation between the actual sending time and the target time; determining whether the time deviation exceeds a preset deviation threshold; if it does, sending a load rebalancing request carrying the local current sending load to the master ECU node so that the master ECU node can re-plan the sending time based on the load rebalancing request. It is understandable that in practice, due to CAN arbitration failure, there may be a time deviation between the actual time the CAN message is sent to the bus and the target time when the ECU triggers the sending action. That is, the slave ECU node will detect the actual sending time of the local CAN message and obtain the time deviation between the actual sending time and the target time. The time deviation is obtained by subtracting the actual sending time from the target time. When the time deviation exceeds the preset deviation threshold, a load rebalancing request carrying the local current sending load is sent to the master ECU node so that the master ECU node can re-plan the sending time of the slave ECU node based on the load rebalancing request.

[0099] As can be seen, in this embodiment, after power-on, the slave ECU node obtains the timestamps sent by the master ECU node at preset time intervals and synchronizes its local clock based on the timestamps. After synchronizing the local clock, it reports its local transmission load to the master ECU node, so that the master ECU node can plan the transmission time of each slave ECU node based on the transmission load to obtain a time schedule table. The slave ECU node obtains the time schedule table sent by the master ECU node and sends CAN messages at the target time specified in the time schedule table according to its local clock. Furthermore, after enabling message transmission, the slave ECU node also detects the actual transmission time of the local CAN message and obtains the time deviation between the actual transmission time and the target time. If the time deviation exceeds a preset deviation threshold, it sends a load rebalancing request carrying its current local transmission load to the master ECU node, so that the master ECU node can re-plan the transmission time based on the load rebalancing request. In other words, this application introduces a time synchronization mechanism and a bus load statistics and adjustment mechanism on the basis of the original network management. Through the unified scheduling of the transmission time point by the master ECU node and the active balancing of the slave ECU nodes, the probability of CAN message arbitration is reduced, the stability of data transmission is guaranteed, and the periodic stability of the network signal is improved.

[0100] See Figure 6 As shown in the figure, this application discloses a CAN network load balancing device applied to a master ECU node. The device includes:

[0101] The time synchronization module 11 is used to send the timestamp of the local clock to each slave ECU node at preset time intervals after power-on, so that each slave ECU node can synchronize its local clock based on the timestamp.

[0102] The scheduling table acquisition module 12 is used to acquire the transmission load reported by each slave ECU node after synchronizing the local clock, and to plan the transmission time of each slave ECU node based on the transmission load to obtain a time scheduling table.

[0103] The message sending module 13 is used to send the time schedule to each of the slave ECU nodes, so that each of the slave ECU nodes can send CAN messages at the target time specified in the time schedule according to the local clock.

[0104] The scheduling table acquisition module 12 is specifically used for:

[0105] Based on the preset time interval, the currently allocable first time window and the second time window to be reserved are determined;

[0106] Based on the transmission load and using a preset balancing algorithm, the transmission time points of each slave ECU node are planned within the first time window to obtain a time scheduling table.

[0107] As can be seen, after power-on, the master ECU node in this application sends the timestamp of its local clock to each slave ECU node at preset time intervals, so that each slave ECU node can synchronize its local clock based on the timestamp; obtains the transmission load reported by each slave ECU node after synchronizing its local clock, and plans the transmission time points of each slave ECU node based on the transmission load to obtain a time schedule table; sends the time schedule table to each slave ECU node so that each slave ECU node can send CAN messages at the target time points specified in the time schedule table according to its local clock; wherein, the step of planning the transmission time points of each slave ECU node based on the transmission load to obtain a time schedule table includes: determining the currently allocable first time window and the second time window to be reserved based on the preset time interval; and planning the transmission time points of each slave ECU node within the first time window based on the transmission load and using a preset equalization algorithm to obtain a time schedule table. Therefore, the master ECU node periodically sends its local clock timestamps to each slave ECU node so that each slave ECU node can synchronize its local clock based on the timestamps. The period interval is a preset time interval. After obtaining the timestamps and synchronizing their local clocks, each slave ECU node reports its local transmission load to the master ECU node. The master ECU node then plans the transmission times of each slave ECU node based on these transmission loads to obtain a time schedule table, which is then sent to each slave ECU node so that each slave ECU node can send CAN messages at the target time specified in the time schedule table according to its local clock. Furthermore, when planning the transmission times of each slave ECU node based on the transmission load, the master ECU node needs to determine the currently allocable first time window and the second time window to be reserved based on the preset time interval. First, it uses a preset equalization algorithm to plan the transmission times of each slave ECU node within the first time window to obtain a time schedule table, which is then sent to each slave ECU node. That is, in the initial planning of transmission times, this application does not divide the entire period interval but also reserves a portion of the time window for subsequent planning. In this way, the master ECU node in this application schedules the time for the slave ECU nodes to send CAN messages in a unified manner according to the transmission load of the slave ECU nodes, so as to ensure the stable transmission of CAN messages by each slave ECU node, thereby reducing the peak load of the CAN bus and ensuring the stability and real-time performance of signal transmission.

[0108] Figure 7This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Specifically, it may include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 stores a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the CAN network load balancing method performed by the electronic device disclosed in any of the foregoing embodiments.

[0109] In this embodiment, the power supply 23 is used to provide operating voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and external devices, and the communication protocol it follows can be any communication protocol applicable to the technical solution of this application, and is not specifically limited here; the input / output interface 25 is used to acquire external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs, and is not specifically limited here.

[0110] The processor 21 may include one or more processing cores, such as a quad-core processor or an octa-core processor. The processor 21 may be implemented using at least one hardware form selected from DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). The processor 21 may also include a main processor and a coprocessor. The main processor, also known as a CPU (Central Processing Unit), is used to process data in the wake-up state; the coprocessor is a low-power processor used to process data in the standby state. In some embodiments, the processor 21 may integrate a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the screen. In some embodiments, the processor 21 may also include an AI (Artificial Intelligence) processor, which is used to handle computational operations related to machine learning.

[0111] In addition, the memory 22, as a carrier for resource storage, can be a read-only memory, random access memory, disk or optical disk, etc. The resources stored on it include operating system 221, computer program 222 and data 223, etc., and the storage method can be temporary storage or permanent storage.

[0112] The operating system 221 manages and controls the various hardware devices on the electronic device 20 and the computer program 222 to enable the processor 21 to perform calculations and processing on the massive amount of data 223 in the memory 22. The operating system can be Windows, Unix, Linux, etc. The computer program 222, in addition to including a computer program capable of performing the CAN network load balancing method executed by the electronic device 20 as disclosed in any of the foregoing embodiments, may further include computer programs capable of performing other specific tasks. The data 223 may include data received by the electronic device from external devices, as well as data collected by its own input / output interface 25.

[0113] Furthermore, embodiments of this application also disclose a computer-readable storage medium storing a computer program. When the computer program is loaded and executed by a processor, it implements the method steps performed during the CAN network load balancing process disclosed in any of the foregoing embodiments.

[0114] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to in the method section.

[0115] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0116] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.

[0117] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0118] The foregoing has provided a detailed description of a CAN network load balancing method, apparatus, device, and storage medium provided by the present invention. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.

Claims

1. A load balancing method for a CAN network, characterized in that, Applied to the main ECU node, including: After power-on, the local clock timestamp is sent to each slave ECU node at preset time intervals so that each slave ECU node can synchronize its local clock based on the timestamp. The transmission load reported by each slave ECU node after synchronizing its local clock is obtained, and the transmission time of each slave ECU node is planned based on the transmission load to obtain a time scheduling table. The time schedule table is sent to each of the slave ECU nodes so that each slave ECU node can send a CAN message at the target time specified in the time schedule table according to its local clock. The step of planning the transmission time points of each slave ECU node based on the transmission load to obtain a time scheduling table includes: Based on the preset time interval, a first time window that can be allocated and a second time window that needs to be reserved are determined; the total time length of the first time window and the second time window is equal to the time length of the preset time interval; Based on the transmission load and using a preset balancing algorithm, the transmission time points of each slave ECU node are planned within the first time window to obtain a time scheduling table. After sending the time schedule to each of the slave ECU nodes, so that each slave ECU node sends a CAN message at the target time specified in the time schedule according to its local clock, the process further includes: Upon receiving a load rebalancing request from any of the slave ECU nodes, based on the current transmission load carried in the load rebalancing request, the transmission time of the slave ECU node is replanned within the second time window using the preset balancing algorithm to obtain an updated time schedule table; the updated time schedule table is sent to the slave ECU node so that the slave ECU node can send CAN messages at the time specified in the updated time schedule table according to its local clock.

2. The CAN network load balancing method according to claim 1, characterized in that, The step of sending the local clock timestamp to each of the slave ECU nodes at preset time intervals, so that each of the slave ECU nodes can synchronize its local clock based on the timestamp, includes: The local clock timestamp is sent to each of the slave ECU nodes at preset time intervals so that each slave ECU node can synchronize its local clock based on the timestamp and the timestamp propagation time.

3. The CAN network load balancing method according to claim 1, characterized in that, The step of obtaining the transmission load reported by each of the slave ECU nodes after synchronizing its local clock includes: After synchronizing their local clocks, each ECU node determines its transmission load based on the frequency of its CAN message transmission, the data length of the CAN message, and the transmission rate. Obtain the transmission load reported by each ECU node.

4. The CAN network load balancing method according to claim 1, characterized in that, Also includes: Determine whether the current condition meets the preset load balancing criteria. If it does, update the preset time interval and send the timestamp of the local clock to each slave ECU node according to the updated time interval; wherein the updated time interval is greater than the preset time interval.

5. A load balancing method for a CAN network, characterized in that, Applicable to any slave ECU node, including: After power-on, the system acquires the timestamps sent by the main ECU node at preset time intervals and synchronizes the local clock based on the timestamps. After synchronizing the local clock, the local transmission load is reported to the master ECU node so that the master ECU node can plan the transmission time of each slave ECU node based on the transmission load to obtain a time scheduling table. Obtain the time schedule table sent by the master ECU node, and send a CAN message at the target time point specified in the time schedule table according to the local clock; The master ECU node plans the transmission time of each slave ECU node based on the transmission load to obtain a time scheduling table, including: The master ECU node determines the currently allocable first time window and the second time window to be reserved based on the preset time interval, and plans the transmission time points of each slave ECU node within the first time window based on the transmission load and using a preset balancing algorithm to obtain a time scheduling table; the total time length of the first time window and the second time window is equal to the time length of the preset time interval; After sending the CAN message at the target time specified in the time schedule table according to the local clock, the process further includes: When the preset conditions are met, a load rebalancing request carrying the local current transmission load is sent to the master ECU node, so that the master ECU node can use the preset balancing algorithm to re-plan the transmission time of the slave ECU node within the second time window to obtain an updated time scheduling table. The updated time schedule table sent by the master ECU node is obtained, and a CAN message is sent at the time specified in the updated time schedule table according to the local clock.

6. The CAN network load balancing method according to claim 5, characterized in that, After sending the CAN message at the target time specified in the time schedule table according to the local clock, the process further includes: Detect the actual transmission time of the CAN message sent locally, and obtain the time deviation between the actual transmission time and the target time. If the time deviation exceeds a preset deviation threshold, a load rebalancing request carrying the local current transmission load is sent to the master ECU node so that the master ECU node can re-plan the transmission time based on the load rebalancing request.

7. A CAN network load balancing device, characterized in that, Applied to the main ECU node, including: The time synchronization module is used to send the timestamp of the local clock to each slave ECU node at preset time intervals after power-on, so that each slave ECU node can synchronize its local clock based on the timestamp. The scheduling table acquisition module is used to acquire the transmission load reported by each slave ECU node after synchronizing the local clock, and to plan the transmission time of each slave ECU node based on the transmission load to obtain the time scheduling table. The message sending module is used to send the time schedule to each of the slave ECU nodes, so that each slave ECU node can send a CAN message at the target time specified in the time schedule according to its local clock. The scheduling table acquisition module is specifically used for: Based on the preset time interval, a first time window that can be allocated and a second time window that needs to be reserved are determined; the total time length of the first time window and the second time window is equal to the time length of the preset time interval; Based on the transmission load and using a preset balancing algorithm, the transmission time points of each slave ECU node are planned within the first time window to obtain a time scheduling table. After sending the time schedule table to each of the slave ECU nodes so that each slave ECU node sends a CAN message at the target time point specified in the time schedule table according to its local clock, the device is further configured to, upon receiving a load rebalancing request from any of the slave ECU nodes, re-plan the transmission time points of the slave ECU nodes within the second time window based on the current transmission load carried in the load rebalancing request, using the preset balancing algorithm to obtain an updated time schedule table; and send the updated time schedule table to the slave ECU nodes so that the slave ECU nodes send CAN messages at the time point specified in the updated time schedule table according to their local clock.

8. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor for executing the computer program to implement the steps of the CAN network load balancing method as described in any one of claims 1 to 4.

9. A computer-readable storage medium, characterized in that, Used to store a computer program; wherein, when the computer program is executed by a processor, it implements the steps of the CAN network load balancing method as described in any one of claims 1 to 4.

Citation Information

Patent Citations

  • Distributed node information monitoring method and system, and application

    CN109672731A

  • Control system, clock synchronization method, controller, node device, and vehicle

    CN112514289A