Method for calculating the frame collision rate of frames on a CAN bus and method for minimizing CAN bus resources.
Patent Information
- Authority / Receiving Office
- JP · JP
- Patent Type
- Patents
- Current Assignee / Owner
- SHENZHEN POWEROAK NEWENER CO LTD
- Filing Date
- 2023-05-19
- Publication Date
- 2026-08-04
AI Technical Summary
【0022】 従来技術と比較して、本発明の技術方案は以下の有益な効果を有する。
Smart Images

Figure 0007900515000044 
Figure 0007900515000045 
Figure 0007900515000046
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data transmission technology, and particularly to a method for calculating the frame collision rate of frames on a CAN bus and a method for minimizing CAN bus resources.
Background Art
[0002] In the automotive industry, various electronic control systems have been developed in response to the requirements of safety, comfort, convenience, low power consumption, and low cost. Since the requirements for the data types and reliability used in the communication between these systems are different, they are often composed of multiple buses, and accordingly the number of harnesses also increases. In order to meet the needs of "reducing the number of harnesses" and "performing high-speed communication of a large amount of data via multiple LANs", the Bosch Group, a German electric trading company, developed a CAN communication protocol for automobiles in 1986.
[0003] CAN, whose full name is Controller Area Network, is a data protocol bus proposed by the Bosch Group in Germany in 1985, and is now widely used in the fields of distributed real-time control such as automotive electronics and industrial automation. Compared to general communication buses, CAN bus data communication offers remarkable reliability, real-time capabilities, and flexibility. Due to its superior performance and unique design, the CAN bus is becoming increasingly important. It is most widely used in the automotive sector, and several of the world's leading automakers have adopted the CAN bus to enable data communication between the in-vehicle control systems and each sensing and executing device. At the same time, due to the characteristics of the CAN bus itself, its scope of application is no longer limited to the automotive industry, and it is being hailed as a computer LAN for automation fields, expanding into fields such as automatic control, aerospace, navigation, process industry, machinery industry, spinning machinery, agricultural machinery, robotics, NC machine tools, medical devices, and sensors. Its emergence provides strong technical support for distributed control systems to achieve real-time and reliable data communication between each node. CAN has already become an international standard and is considered one of the most promising fieldbuses.
[0004] CAN bus frames allow data segments up to 8 bytes, employing a short frame structure, resulting in short transmission times and a low probability of interference. However, as the bus load increases, frame collision events on the bus become unavoidable. To improve reliability, when developing product protocols using the CAN bus, it is common to prevent frame collision events by sending periodic frames or adding random latency to transmitted frames. However, this undoubtedly reduces communication efficiency and leads to wasted communication resources.
[0005] Furthermore, the information disclosed in the above section on background technology is solely for the purpose of understanding the background of this application and therefore may include information that does not constitute prior art known to those skilled in the art. [Overview of the project]
[0006] The object of the present invention is to overcome the shortcomings of the prior art, which cannot calculate the frame collision rate and further cannot optimize bus resources, and to provide a method for calculating the frame collision rate of frames on a CAN bus and a method for minimizing CAN bus resources.
[0007] To achieve the above objective, the present invention employs the following technical solution.
[0008] A method for calculating the frame collision rate on a CAN bus, obtained by calculating the frame collision rate of frames based on Erlang B equation in queuing theory, using the CAN bus communication rate, frame transmission frequency, and frame length.
[0009] In some embodiments, frames on the CAN bus have multiple priorities, and the frame collision rate of frames of each priority is calculated in descending order of priority. Here, the frame collision rate of the highest priority frame is calculated directly using the Erlang B formula, and the frame collision rates of the remaining priority frames are calculated using a combination of the Erlang B formula and the cumulative flow load and overflow flow load of that priority.
[0010] In some embodiments, the frame collision rate Bp[i] for each priority frame is calculated as follows: JPEG0007900515000001.jpg24128 Here, i=0 represents the highest priority, i=1,2,...,p-1 represents the remaining priorities which decrease sequentially, the number of priorities operating systematically on the CAN bus is p, A[i] represents the flow load of priority i on the CAN bus, k=1, L_S[i] represents the cumulative flow load of priority i, and A_L[i] represents the overflow flow load where higher priorities overflow to priority i.
[0011] In some embodiments, the flow load A[i] of priority i on the CAN bus, the cumulative flow load L_S[i] of priority i, and the overflow flow load A_L[i], where higher priority flows over to priority i, are calculated as follows: JPEG0007900515000002.jpg48126 Here, L[i] and S[i] represent the transmission frequency and frame length of priority i frames, respectively, and B represents the current CAN bus communication rate.
[0012] The following steps, namely, S1, set the initial CAN bus communication rate. S2, at the CAN bus communication rate of step S1, calculate the frame collision rate of each priority frame operating systematically on the CAN bus based on Erlang B equation in queuing theory. In step S3, it is determined whether the frame collision rate of each priority frame calculated in step S2 exceeds the upper limit of the frame collision rate allowed for that priority frame. If it exceeds the upper limit, the CAN bus communication rate in step S1 is increased and the cycle proceeds to step S2 to continue. If it does not exceed the upper limit, the CAN bus communication rate in step S1 is decreased and the cycle proceeds to step S2 to continue. S4, A method for minimizing CAN bus resources, which includes outputting a minimum communication rate that ensures the upper limit of the allowable frame collision rate for each priority frame is not exceeded, thereby completing the optimization.
[0013] In some embodiments, in step S1, a fixed value is given as the initial CAN bus communication rate.
[0014] In some embodiments, the initial CAN bus communication rate is calculated in step S1 using the following formula. JPEG0007900515000003.jpg1051 Here, B_x is the initial CAN bus communication rate, and L[0], S[0], and Bp_T[0] represent the transmission frequency, frame length, and upper limit of the allowable frame collision rate for the highest priority frame, respectively.
[0015] In some embodiments, step S2 includes calculating the frame collision rate for each priority frame in descending order of priority, based on Erlang B equation in queuing theory, at the CAN bus communication rate of step S1, where the frame collision rate for the highest priority frame is calculated directly using Erlang B equation, and the frame collision rates for the remaining priority frames are calculated using a combination of Erlang B equation and the cumulative flow load and overflow flow load of the frame of that priority.
[0016] In some embodiments, the frame collision rate Bp[i] for each priority frame is calculated as follows: JPEG0007900515000004.jpg24128 Here, i=0 represents the highest priority, i=1,2,...,p-1 represents the remaining priorities which decrease sequentially, the number of priorities operating systematically on the CAN bus is p, A[i] represents the flow load of priority i on the CAN bus, k=1, L_S[i] represents the cumulative flow load of priority i, and A_L[i] represents the overflow flow load where higher priorities overflow to priority i.
[0017] In some embodiments, the method for calculating A[i] is as follows: JPEG0007900515000005.jpg927 Here, L[i] and S[i] represent the transmission frequency and frame length of priority i frames, respectively, and B represents the current CAN bus communication rate.
[0018] In some embodiments, the method for calculating L_S[i] is as follows: JPEG0007900515000006.jpg1181
[0019] In some embodiments, the method for calculating A_L[i] is as follows: JPEG0007900515000007.jpg11123
[0020] In some embodiments, the method for increasing or decreasing the CAN bus communication rate in step S3 is a step method and / or binary search.
[0021] The present invention further provides a computer-readable storage medium in which a computer program is stored, and which can realize a method for minimizing the CAN bus resources when the computer program is executed by a processor.
[0022] Compared to conventional technology, the present invention has the following beneficial effects.
[0023] Conventional technologies lack a specific algorithm for calculating frame collision rates, making it impossible to know the frame collision rate for specific cases (including CAN bus communication rate, transmission frequency of frames of each priority, frame length of each priority, and number of priorities), and thus minimizing bus resources. The present invention provides an algorithm for calculating frame collision rates based on Erlang B equation in queuing theory, and after calculating the frame collision rate, it optimizes bus resources to find the minimum required bus resources that satisfy the condition that the frame collision rate does not exceed the upper limit of the allowable frame collision rate when the transmission frequency and frame length are fixed, thereby achieving optimized allocation of bus resources.
[0024] A relatively low CAN bus communication rate means that the bus bandwidth is relatively low, the requirements for components are small, and at the same time the probability of being affected by electromagnetic interference from other components is reduced, which means that the communication reliability increases. The present invention accurately calculates the required minimum bus resources (communication rate) from the preset upper limits of the transmission frequencies of frames of each priority and the frame collision rates of frames of each priority, and achieves the purposes of flexible resource allocation and optimization of resource use.
[0025] The present invention is applied to the development stage of products adopting a CAN communication bus, and relates to a design method of the CAN bus. In particular, when the bus load is large and frames of multiple priorities are transmitted simultaneously, the design efficiency is improved, the utilization rate of bus resources is optimized, and the CAN bus user can realize the optimal allocation of bus resources at the development stage according to different usage scenarios, and the CAN bus resources can be saved.
Brief Description of the Drawings
[0026] [Figure 1] It is a flowchart of a method for minimizing CAN bus resources according to an embodiment of the present invention. [Figure 2] It is a flowchart of a method for calculating the frame collision rate of frames of each priority according to an embodiment of the present invention. [Figure 3] It is a flowchart of a method for calculating the minimum required communication rate of a CAN bus according to an embodiment of the present invention.
Modes for Carrying Out the Invention
[0027] Hereinafter, embodiments of the present invention will be described in detail. It is emphasized that the following description is merely exemplary and does not limit the scope of the present invention and its application.
[0028] The terms “first” and “second” are used solely for descriptive purposes and should not be understood as indicating or implying relative importance or implicitly referring to the number of technical features being referred to. Thus, features designated as “first” or “second” may explicitly or implicitly include one or more such features. In the descriptions of embodiments of the present invention, “multiple” means two or more unless otherwise clearly and specifically limited.
[0029] When designing and developing a product using the CAN bus, it is first necessary to plan the allocation of CAN bus resources. Currently, designers often refer to accumulated experience from the past. For example, to reduce the probability of frame collision events occurring on the bus, the CAN bus load rate is generally kept below 30%. The load rate can be easily calculated from the number of nodes connecting the bus, the transmission frequency of each node, and the frame length. The CAN bus incorporates a priority mechanism, and each priority competes for the bus's transmission resources through a non-destructive arbitration mechanism. The CAN bus protocol can currently support up to eight priorities. The protocol defines that the smaller the value of the bit's flag bit, the higher the priority the bit has. That is, 0x00 has the highest priority, and 0x07 has the lowest priority. When high-priority and low-priority frames transmit data to the bus simultaneously, the high-priority frame automatically acquires the transmission resources, the low-priority frame exits arbitration, and the low-priority frame is retransmitted again during a free time for bus resources by the automatic retransmission mechanism. In this way, a frame collision event occurs for the low-priority frame. In certain business scenarios, designers may need to pay particular attention to the frame collision rate of frames of a certain priority, but the frame collision rates of frames with different priorities are non-linear and cannot be determined by simple calculations.
[0030] Considering the difficulties in resource allocation planning during the current CAN bus development phase, this invention provides an optimized design method for CAN buses. First, it provides an algorithm that can accurately calculate the frame collision rate for each priority frame. This algorithm uses Erlang B equation from queuing theory to accurately calculate the frame collision rate for each priority frame in order of priority, and further optimizes the resource allocation of the CAN bus, thereby minimizing bus resources. Specifically, the system calculates the frame collision rate for each priority frame with a given bus communication rate and frame transmission frequency. This is then compared to a preset upper limit of the allowable frame collision rate for each priority frame. If the calculated frame collision rate exceeds the upper limit, the bus bandwidth is increased (i.e., the communication rate is increased). If the calculated frame collision rate does not exceed the upper limit, the communication rate is decreased. The system then continues to calculate the frame collision rate for each priority frame with the new communication rate and compares it to the upper limit of the allowable frame collision rate. This cycle is repeated until the minimum communication rate is obtained in which the calculated frame collision rate for each priority frame does not exceed the corresponding upper limit of the allowable frame collision rate. The bus bandwidth (communication rate) at this point is the minimum bus bandwidth that satisfies the requirement of not exceeding the upper limit of the allowable frame collision rate when the transmission frequency and frame length are fixed, thus optimizing bus resources.
[0031] As shown in Figures 1 and 3, the specific steps of the method for minimizing CAN bus resources according to an embodiment of the present invention are as follows.
[0032] S1 sets the initial CAN bus communication rate.
[0033] This method involves giving a relatively small or relatively large initial communication rate B_x for the CAN bus, allowing this fixed value to range from 0, and then calculating the minimum communication rate that satisfies the conditions through cycle judgment. However, this method is computationally intensive and slow. Therefore, in order to reduce the computational complexity and improve computational efficiency, this embodiment calculates the initial communication rate of the CAN bus using the following formula. JPEG0007900515000008.jpg1051 Here, B_x is the initial CAN bus communication rate, and L[0], S[0], and Bp_T[0] represent the transmission frequency, frame length, and upper limit of the allowable frame collision rate for the highest priority frame, respectively.
[0034] In step S2, when the CAN bus communication rate and the transmission flow rate for each priority are fixed, the frame collision rate for each priority frame can be calculated and obtained. As shown in Figure 2, the specific process is as follows: In step S1, at the CAN bus communication rate, the frame collision rate for each priority frame operating systematically on the CAN bus is calculated based on Erlang B's equation in queuing theory. Here, the frame collision rate for the highest priority frame is calculated directly using Erlang B's equation, and the frame collision rates for the remaining priority frames are calculated using a combination of Erlang B's equation and the cumulative flow load and overflow flow load for that priority.
[0035] Generally, for the Erlang B formula, three parameters are needed: the frame arrival rate λ, the service rate μ (where 1 / μ is the time required for service), and the number of servers k, i.e., Bp = Erlang B(A,k), where A = λ / μ and k is the number of servers. In this application, when applying the Erlang B formula to a CAN bus to calculate the frame collision rate, since all priority frames operate on a single CAN bus, the number of servers k is normalized, i.e., the CAN bus is treated as one server, k=1, L is the transmission frequency of a certain priority, corresponding to λ in the Erlang B formula, S is the frame length of a frame of a certain priority, and B represents the current CAN bus communication rate. Then S / B is the time required for the CAN bus to transmit one frame of a certain priority, corresponding to 1 / μ in the Erlang B formula. Therefore, the Erlang B formula is: It can be rewritten as JPEG0007900515000009.jpg1040.
[0036] The frame collision rate Bp[i] for each priority i frame is calculated as follows: JPEG0007900515000010.jpg24128 Here, i=0 represents the highest priority, i=1,2,...,p-1 represents the remaining priorities which decrease sequentially, and the number of priorities that operate systematically on the CAN bus is p, A[i] represents the flow load of frames of priority i on the CAN bus, k=1, L_S[i] represents the cumulative flow load of frames of priority i, and A_L[i] represents the overflow flow load where higher priorities overflow to priority i, where flow load means the ratio of the sum of the flow rates of each priority to the transmission rate of the CAN bus.
[0037] Here, the method for calculating A[i] is as follows: JPEG0007900515000011.jpg927 Here, L[i] and S[i] represent the transmission frequency and frame length of priority i frames, respectively, B represents the current CAN bus communication rate, and the calculation method for the cumulative flow load L_S[i] is as follows. The calculation method for the overflow flow load A_L[i] in JPEG0007900515000012.jpg1179 is as follows: JPEG0007900515000013.jpg11120
[0038] In step S3, it is determined whether the frame collision rate of each priority frame calculated in step S2 exceeds the upper limit of the frame collision rate that is permissible for that priority frame. If it exceeds the upper limit, the CAN bus communication rate in step S1 is increased and the process proceeds to step S2 to continue the cycle. If it does not exceed the upper limit, the CAN bus communication rate in step S1 is decreased and the process proceeds to step S2 to continue the cycle.
[0039] Here, the method for increasing / decreasing the CAN bus communication rate may be a step method, and the fixed step size can be adjusted according to the actual situation. For example, the communication rate (i.e., bus bandwidth) can be increased / decreased with a fixed step size of 100 bits / s or 1000 bits / s. A relatively small fixed step size yields more accurate results but increases the number of calculation iterations and calculation time. Conversely, a relatively large fixed step size reduces the accuracy of the calculation results but improves the calculation speed. Selecting a relatively appropriate fixed step size depends on the designer's accumulated experience.
[0040] In some other embodiments, the method for increasing / decreasing the CAN bus communication rate may employ binary search. For example, a relatively large bus communication rate and a relatively small bus communication rate are obtained in two or more cycles, where at the relatively small communication rate (Data1), the frame collision rate of all priority frames does not exceed the upper limit for the frame collision rate of that priority, and at the relatively large communication rate (Data2), the frame collision rate of at least one priority frame exceeds the upper limit for the frame collision rate of that priority. Then, the communication rate Data3 for the next cycle can be determined by a binary search between [Data1,Data2]. If the frame collision rate of all priority frames at communication rate Data3 does not exceed the upper limit for the frame collision rate of that priority, then the communication rate Data4 for the next cycle will be determined by a binary search between [Data1,Data3]. If the frame collision rate of at least one priority frame at communication rate Data3 exceeds the upper limit for the frame collision rate of that priority, then the communication rate Data4 for the next cycle will be determined by a binary search between [Data3,Data2]. The above cycle is repeated until the minimum communication rate that does not exceed the upper limit of the frame collision rate for each priority frame is found. Compared to the step method, using binary search can, in some cases, reduce the amount of computation and significantly increase the computation speed.
[0041] In some other embodiments, the method for increasing / decreasing the CAN bus communication rate can also be a combination of stepping and binary search.
[0042] S4 completes the optimization by outputting the minimum communication rate that ensures the frame collision rate does not exceed the upper limit of the allowable frame collision rate for each priority frame.
[0043] Example 1: A single lithium-ion battery energy storage product consists of one inverter, one IoT communication module, and four battery packs connected via a CAN bus. These three devices transmit data to the CAN bus periodically or irregularly (event-triggered).
[0044] The settings for transmission frame priority are as follows: Alarm information frames or event trigger query information frames have a frame length of 128 bits and are set to high priority (0X02), while periodic broadcast data frames have a frame length of 256 bits and are set to low priority (0X06). The design index for frame collision rate for high-priority frames is ≤3%, and the design index for frame collision rate for low-priority frames is ≤10%.
[0045] Table 1 below shows the types of data, transmission frequency, and frame length that the inverter module (Inverter) sends to the CAN bus.
[0046] Table 1 JPEG0007900515000014.jpg94146
[0047] Table 2 below shows the types of data, transmission frequency, and frame length that the IoT communication module sends to the CAN bus.
[0048] Table 2 JPEG0007900515000015.jpg15128
[0049] Table 3 below shows the types of data, transmission frequency, and frame length that the battery pack module (Pack) sends to the CAN bus.
[0050] Table 3 JPEG0007900515000016.jpg37131
[0051] The following describes how to implement the embodiments of the present invention based on the data shown in the table above.
[0052] In this embodiment, there are only two priority levels, 0X02 and 0X06, where 0X02 is the high priority and 0X06 is the low priority. The sum of the flow rates for each priority level is calculated as follows. High priority: JPEG0007900515000017.jpg5146bit / s Low priority: JPEG0007900515000018.jpg5128bit / s
[0053] S1 sets the initial CAN bus communication rate, that is, it gives a relatively small / relatively large initial CAN bus communication rate B_x, this fixed value can take values from 0, and the minimum communication rate that satisfies the conditions is calculated by cycle judgment. However, this method is computationally intensive and slow, so in order to reduce the amount of computation and improve computational efficiency, this embodiment calculates the initial CAN bus communication rate using the following formula. JPEG0007900515000019.jpg1051 Here, B_x is the initial CAN bus communication rate, and L[0], S[0], and Bp_T[0] represent the highest priority transmission frequency, frame length, and upper limit of the allowable frame collision rate, respectively.
[0054] In this embodiment, there are only two priorities, 0X02 and 0X06, where 0X02 is the high priority and 0X06 is the low priority. Therefore, in this embodiment, the initial communication rate is calculated using a design index of frame collision rate ≤ 3% for high-priority 0X02 frames. JPEG0007900515000020.jpg34128
[0055] S2, when the CAN bus communication rate and the transmission flow rate for each priority are fixed, the frame collision rate for each priority can be calculated and obtained. The frame collision rate Bp[i] for frame i of each priority is calculated as follows. JPEG0007900515000021.jpg24128 Here, i=0 represents the highest priority, i=1,2,...,p-1 represents the remaining priorities which decrease sequentially, the number of priorities operating systematically on the CAN bus is p, A[i] represents the flow load of priority i on the CAN bus, k=1, L_S[i] represents the cumulative flow load of priority i, and A_L[i] represents the overflow flow load where higher priorities overflow to priority i. Here, flow load means the ratio of the sum of the flow rates of each priority to the transmission rate of the CAN bus.
[0056] Event-triggered transmission is based on user commands; when a user clicks a query command at a certain time, the query information frame sent by the user is transmitted via the CAN bus. The transmission frequency is entirely determined by the user and is random; there may be no query commands at all within a day (24 hours), or there may be multiple query commands within a certain time period (10 minutes). The more query commands there are, the greater the load flow. If randomly triggered information frames are considered as periodic transmissions, the sum of high-priority flow is calculated when the load flow is at its maximum, and this maximum load flow can be considered the worst-case (or most extreme) scenario. When calculating the sum of high-priority flow, assuming the worst-case scenario, the sum of high-priority flow is calculated as follows: JPEG0007900515000022.jpg5146bit / s
[0057] The total flow rate for low priority (0X06) is calculated as follows: JPEG0007900515000023.jpg5128bit / s
[0058] In the formula for calculating the frame collision rate Bp[i], the formulas for calculating the flow load A[i] for each priority level are as follows: JPEG0007900515000024.jpg927
[0059] In this embodiment, first, B uses the initial communication rate of 202380.8 bits / s calculated in step S1, and then the flow load of each priority frame is calculated as follows. A[0]=6259.2 / 202380.8=0.0309278 A[1] = 6144 / 202380.8 = 0.0303586
[0060] The frame collision rate for high-priority frames is calculated directly using the Erlang B formula as follows: JPEG0007900515000025.jpg1066
[0061] For frame collision rates of other priority frames, it is necessary to first calculate the cumulative flow load and overflow flow load, and the formulas and specific calculation results for these are as follows.
[0062] The formula for calculating the cumulative flow load L_S[i] is as follows: JPEG0007900515000026.jpg1179 Then, The filename is JPEG0007900515000027.jpg7128.
[0063] The formula for calculating the overflow flow load A_L[i] is as follows: JPEG0007900515000028.jpg11121 Then, The filename is JPEG0007900515000029.jpg7128.
[0064] Finally, the low-priority frame collision rate was calculated and is as follows: JPEG0007900515000030.jpg5180
[0065] In step S3, it is determined whether the frame collision rate of each priority frame calculated in step S2 exceeds the upper limit of the frame collision rate that is permissible for that priority frame. If it exceeds the upper limit, the CAN bus communication rate in step S1 is increased and the process proceeds to step S2 to continue the cycle. If it does not exceed the upper limit, the CAN bus communication rate in step S1 is decreased and the process proceeds to step S2 to continue the cycle.
[0066] The method for increasing / decreasing the CAN bus communication rate may be a step method, for example, with a fixed step size of 100 bits / s or 1000 bits / s, and the method may be a binary search, or a combination of a step method and a binary search.
[0067] In this embodiment, Bp[0] = 3% and Bp[1] = 8.7%, which do not exceed the allowable frame collision rates of 3% and 10%, respectively. Therefore, the CAN bus communication rate in step S1, 202380.8 bit / s, is further reduced to 200 kbit / s.
[0068] The frame collision rates for two priority levels, calculated at a communication rate of 200 kbit / s, are shown in the following four tables.
[0069] Table 4 Frame collision rates for two priority levels when the communication rate is 200 kbit / s JPEG0007900515000031.jpg15153
[0070] Based on the design metrics, the high-priority option did not meet the design metrics, the low-priority option did, and the overall design metrics were still not met. Therefore, a value was selected between [200000 bits / s, 202380.8 bits / s] and the calculation was performed again. For example, using binary search, 201190.4 bits / s was selected and the calculation was performed. The result showed that the high-priority option still did not meet the design metrics.
[0071] Finally, by continuously cycling through the search, the minimum communication rate that satisfies the design criteria was calculated to be 202380.8 bit / s, and the frame collision rates for the two priority levels at this communication rate are shown in Table 5 below.
[0072] Table 5 Frame collision rates for two priority levels at minimum communication rate JPEG0007900515000032.jpg15153
[0073] S4 completes the optimization by outputting the minimum communication rate that ensures the frame collision rate does not exceed the upper limit of the allowable frame collision rate for each priority frame.
[0074] Generally, the minimum communication rate is 1000 bits / s, so the minimum communication rate of 202380.8 bits / s is output at 203 kbit / s.
[0075] Example 2 The other conditions in this embodiment are the same as in Embodiment 1, the only difference being that the initial communication rate of the CAN bus is set to 250 kbit / s.
[0076] When the CAN bus communication rate and the transmission flow rate for each priority are fixed, the frame collision rate for a specific priority is calculated and obtained. The frame collision rate for the highest priority frame is calculated directly using the Erlang B formula, and the frame collision rates for the remaining priority frames are calculated using a combination of the Erlang B formula and the cumulative flow load and overflow flow load for that priority. The frame collision rates for two priority levels are calculated separately and are shown in Table 6 below.
[0077] Table 6 Frame collision rates for two priority levels when the communication rate is 250 kbit / s JPEG0007900515000033.jpg15153
[0078] Based on the design specifications, the frame collision rate for high-priority 0 (0x02) frames must be controlled to 3% or less, and the frame collision rate for low-priority 1 (0x06) frames must be controlled to 10% or less. The above results satisfy the design specifications, but the possible values are too high, so the requirement to output the minimum communication rate of the CAN bus is not met. Therefore, the value of the CAN bus communication rate is newly set to 150 kbit / s.
[0079] Table 7 below shows the frame collision rates for two priority levels when the CAN bus rate is 150 kbit / s.
[0080] Table 7 Frame collision rates for two priority levels when the communication rate is 100 kbit / s JPEG0007900515000034.jpg15153
[0081] Based on the design metrics, it is clear that the above results do not meet the design metrics, so the CAN bus communication rate is readjusted, and using binary search, a value of 200 kbit / s between [150 kbit / s, 250 kbit / s] can be selected and recalculated, and the frame collision rates for the two priority values are the same as those in Table 4.
[0082] Based on the design metrics, the frame collision rate for high-priority frames is 3.03%, which does not meet the design metrics, while the frame collision rate for low-priority frames is 8.70%, which does meet the design metrics. Overall, the design metrics are still not met, so by continuously using binary search, we can find the minimum communication rate that satisfies the design metrics.
[0083] Finally, by calculation, the minimum CAN bus resources that satisfy the design specifications can be obtained, as shown in Table 5 above. The required CAN bus communication rate at this time is 202380.8 bits / s. The objective of minimizing CAN bus resources is achieved.
[0084] This invention uses the Erlang B equation in queuing theory to accurately calculate the frame collision rate for each priority frame in order of priority, based on data such as a fixed transmission frequency, frame length, and given communication rate. This is then compared to a preset upper limit of the allowable frame collision rate to determine whether it exceeds the upper limit. If it exceeds the upper limit, the communication rate (i.e., bus bandwidth) is increased; if it does not exceed the upper limit, the communication rate is decreased. The process then returns to calculating the frame collision rate and recalculates it until the minimum communication rate corresponding to not exceeding the upper limit of the allowable frame collision rate for each priority frame is obtained. This calculates the minimum CAN bus communication rate and optimizes the resource allocation of the CAN bus. From Example 2, it was found that calculating the initial communication rate using the calculation formula provided by this invention can significantly reduce the amount of computation and improve computational efficiency.
[0085] As those skilled in the art will understand, embodiments of the present invention may be provided as methods, systems, or computer program products. For example, the present invention may further provide a readable storage medium on which a computer program is stored, which, when the computer program is executed by a processor, can realize the steps of the method of minimizing CAN bus resources of the above embodiments. Thus, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Furthermore, the present invention may take the form of a computer program product implemented on one or more computer-readable storage media (including, but not limited to, magnetic disk memory, CD-ROM, optical memory, etc.) containing computer-readable program code.
[0086] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems) and computer program products based on embodiments of the present invention. It should be understood that computer program commands can realize each flow and / or block in the flowchart and / or block diagram, as well as combinations of flows and / or blocks in the flowchart and / or block diagram. These computer program commands may be provided to a processor of a general-purpose computer, a dedicated computer, an embedded processor, or other programmable data processing device to generate a machine, thereby generating a device for realizing a specified function in one or more flows in the flowchart and / or one or more blocks in the block diagram.
[0087] These computer program commands may be stored in computer-readable memory that can instruct a computer or other programmable data processing device to operate in a specific manner, thereby generating a product that includes a command device, which implements the functionality of designations in one or more flows in a flowchart and / or one or more blocks in a block diagram.
[0088] These computer program commands may be loaded onto a computer or other programmable data processing device, thereby generating a series of operational steps on the computer or other programmable device to generate the processing that the computer performs, and so the commands executed on the computer or other programmable device provide steps to perform a specified function in one or more flows in a flowchart and / or one or more blocks in a block diagram.
[0089] The foregoing further describes the present invention based on specific / preferred embodiments, and it is not considered that the specific implementation of the present invention is limited to these descriptions. A person skilled in the art will be able to make several substitutions or modifications to these described embodiments without departing from the design of the present invention, and these substitutions or modifications should be considered to fall within the scope of protection of the present invention. In this specification, reference terms such as “one embodiment,” “several embodiments,” “preferred embodiment,” “example,” “specific example,” or “several examples” mean that the specific features, structures, materials, or properties described based on this embodiment or example are included in at least one embodiment or example of the present invention. In this specification, exemplary expressions for the above terms do not necessarily have to refer to the same embodiment or example. The specific features, structures, materials, or properties described may be combined in an appropriate manner in any one or more embodiments or examples. A person skilled in the art can integrate or combine different embodiments or examples and features of different embodiments or examples described herein, provided they do not conflict with each other. While embodiments and advantages of the present invention have been described in detail, it should be understood that various changes, substitutions, and modifications can be made herein without departing from the scope of protection of the patent application.
Claims
1. A method for calculating the frame collision rate of frames on a CAN bus, wherein the calculation method is applied to a machine, the machine comprises a processor, and the calculation method is executed by the processor. A method for calculating the frame collision rate of frames on a CAN bus, comprising calculating the frame collision rate of frames based on the Erlang B equation in queuing theory from the CAN bus communication rate, frame transmission frequency, and frame length, wherein frames on the CAN bus have multiple priorities, the frame collision rate of the frame with the highest priority is calculated using the Erlang B equation, and the frame collision rates of the remaining priority frames are calculated using a combination of the Erlang B equation and the cumulative flow load and overflow flow load of the respective priority.
2. A method for calculating the frame collision rate of frames on a CAN bus according to claim 1, characterized by calculating the frame collision rate of each priority frame in order of decreasing priority.
3. The frame collision rate Bp[i] for each priority frame is calculated as follows: A method for calculating the frame collision rate of frames on a CAN bus according to claim 2, characterized in that, here, i = 0 represents the highest priority, i = 1, 2, ..., p-1 represents the remaining priorities that decrease sequentially, the number of priorities operating systematically on the CAN bus is p, A[i] represents the flow load of priority i on the CAN bus, k = 1, L_S[i] represents the cumulative flow load of priority i, and A_L[i] represents the overflow flow load where higher priorities overflow to priority i.
4. The flow load A[i] for priority i on the CAN bus, the cumulative flow load L_S[i] for priority i, and the overflow flow load A_L[i] when higher priority flows over to priority i are calculated as follows: A method for calculating the frame collision rate of frames on a CAN bus according to claim 3, characterized in that, here, L[i] and S[i] represent the transmission frequency and frame length of a frame with priority i, respectively, and B represents the current CAN bus communication rate.
5. A method for minimizing CAN bus resources, wherein the method is applied to a machine, the machine comprises a processor, and the method is performed by the processor. The following steps, namely, S1. Set the initial CAN bus communication rate, In step S2, the frame collision rate for each priority frame operating systematically on the CAN bus is calculated based on the Erlang B equation in queuing theory at the CAN bus communication rate of step S1. Here, the frame collision rate for the highest priority frame is calculated using the Erlang B equation, and the frame collision rates for the remaining priority frames are calculated using a combination of the Erlang B equation and the cumulative flow load and overflow flow load for that priority. In step S3, it is determined whether the frame collision rate of each priority frame calculated in step S2 exceeds the upper limit of the frame collision rate that is permissible for that priority frame. If it exceeds the upper limit, the CAN bus communication rate in step S1 is increased and the process proceeds to step S2 to continue the cycle. If it does not exceed the upper limit, the CAN bus communication rate in step S1 is decreased and the process proceeds to step S2 to continue the cycle. A method for minimizing CAN bus resources, characterized by including S4, outputting a minimum communication rate that does not exceed the upper limit of the frame collision rate allowed for each priority frame, thereby completing the optimization.
6. The method for minimizing CAN bus resources according to claim 5, characterized in that in step S1, a fixed value is provided as the initial CAN bus communication rate.
7. In step S1, the initial CAN bus communication rate is calculated using the following formula: The method for minimizing CAN bus resources according to claim 5, characterized in that, here, B_x is the initial CAN bus communication rate, and L[0], S[0], and Bp_T[0] represent the transmission frequency, frame length, and upper limit of the allowable frame collision rate of the highest priority frame, respectively.
8. The method for minimizing CAN bus resources according to claim 5, characterized in that step S2 includes calculating the frame collision rate of each priority frame in descending order of priority based on the Erlang B equation in queuing theory, at the CAN bus communication rate of step S1.
9. The frame collision rate Bp[i] for each priority frame is calculated as follows: A method for minimizing CAN bus resources according to claim 8, characterized in that, here, i = 0 represents the highest priority, i = 1, 2, ..., p-1 represents the remaining priorities that decrease sequentially, the number of priorities operating systematically on the CAN bus is p, A[i] represents the flow load of priority i on the CAN bus, k = 1, L_S[i] represents the cumulative flow load of priority i, and A_L[i] represents the overflow flow load where higher priorities overflow to priority i.
10. The flow load A[i] for priority i on the CAN bus, the cumulative flow load L_S[i] for priority i, and the overflow flow load A_L[i] when higher priority flows over to priority i are calculated as follows: A method for minimizing CAN bus resources according to claim 9, characterized in that, here, L[i] and S[i] represent the transmission frequency and frame length of priority i frames, respectively, and B represents the current CAN bus communication rate.
11. The method for minimizing CAN bus resources according to claim 5, characterized in that the method for increasing or decreasing the CAN bus communication rate in step S3 is a step method and / or a binary search.
12. A computer-readable storage medium in which a computer program is stored, characterized in that when the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 11 can be realized.
13. A machine comprising a processor, wherein the processor is used to perform the method described in any one of claims 1 to 11.