FRAME COLLISION RATE CALCULATION METHOD FOR FRAME ON CAN BUS, AND CAN BUS RESOURCE MINIMIZATION METHOD
20250088465 ยท 2025-03-13
Assignee
Inventors
- Hui Ma (Shenzhen, CN)
- Jianhua Lei (Shenzhen, CN)
- Zhihua Guo (Shenzhen, CN)
- FAN LI (Shenzhen, CN)
- Geng Qin (Shenzhen, CN)
- Haiyang Li (Shenzhen, CN)
Cpc classification
International classification
Abstract
A frame collision rate calculation method for a frame on a CAN bus, and a CAN bus resource minimization method are provided. The CAN bus resource minimization method includes: S1, setting an initial CAN bus communication rate; S2, according to the preset rate in step S1 and an Erlang B formula in the queuing theory, calculating a frame collision rate of each priority; S3, determining whether the frame collision rate of each priority calculated in step S2 exceeds an allowable frame collision rate upper limit; if so, increasing the CAN bus communication rate, and returning to step S2; and if not, decreasing the CAN bus communication rate, and returning to step S2; and S4, outputting a minimum communication rate corresponding to the frame collision rate of a frame of each priority that does not exceed the allowable frame collision rate upper limit.
Claims
1. A frame collision rate calculation method for a frame on a CAN bus, comprising: calculating the frame collision rate of the frame, based on an Erlang B formula in the queuing theory according to an CAN bus communication rate, a sending frequency and a frame length of the frame.
2. The frame collision rate calculation method for the frame on the CAN bus according to claim 1, wherein frames on the CAN bus comprises multiple priorities, and the frame collision rate of the frame of each priority is calculated in the descending order of the priorities, wherein the frame collision rate of the frame of the highest priority is calculated directly using the Erlang B formula; while the frame collision rate of the frame of each of the remaining priorities is calculated using the Erlang B formula in combination with a cumulative traffic load and an overflow traffic load associated with the respective priority.
3. The frame collision rate calculation method for the frame on the CAN bus according to claim 2, wherein the frame collision rate Bp[i] of the frame of each priority is calculated as follows:
4. The frame collision rate calculation method for the frame on the CAN bus according to claim 3, wherein the traffic load A[i] of the priority i relative to the CAN bus, the accumulated traffic load L_S[i] of the priority i, and the overflow traffic load A_L[i] from a higher priority to the priority i are calculated respectively as follows:
5. A CAN bus resource minimization method, comprising: S1. setting an initial CAN bus communication rate; S2. at the CAN bus communication rate in step S1 and on the basis of an Erlang B formula in the queuing theory, calculating a frame collision rate of a frame of each priority, the running of which on a CAN bus is planned; S3. determining whether the frame collision rate of the frame of each priority calculated in step S2 exceeds an allowable frame collision rate upper limit associated with the respective priority; when the frame collision rate calculated in step S2 exceed the allowable frame collision rate upper limit, increasing the CAN bus communication rate in step S1, and returning to step S2 for continued iteration; when the frame collision rate calculated in step S2 does not exceed the allowable frame collision rate upper limit, decreasing the CAN bus communication rate in step S1, and returning to step S2 for continued iteration; and S4. outputting a minimum communication rate corresponding to the frame collision rate of the frame of each priority that does not exceed the allowable frame collision rate upper limit associated with the respective priority.
6. The CAN bus resource minimization method according to claim 5, wherein a fixed value is given as the initial CAN bus communication rate, in the step S1.
7. The CAN bus resource minimization method according to claim 5, wherein in the step S1, the initial CAN bus communication rate is calculated by the following formula:
8. The CAN bus resource minimization method according to claim 5, wherein the step S2 comprises: at the CAN bus communication rate in step S1 and on the basis of an Erlang B formula in the queuing theory, calculating the frame collision rate of the frame of each priority in the descending order of priorities, wherein the frame collision rate of the frame of the highest priority is calculated directly using the Erlang B formula, while the frame collision rate of the frame of each of the remaining priorities is calculated using the Erlang B formula in combination with a cumulative traffic load and an overflow traffic load associated with the respective priority.
9. The CAN bus resource minimization method according to claim 8, wherein the frame collision rate Bp[i] of the frame of priority i is calculated as follows:
10. The CAN bus resource minimization method according to claim 9, wherein the traffic load A[i] of the priority i relative to the CAN bus, the accumulated traffic load L_S[i] of the priority i, and the overflow traffic load A_L[i] from a higher priority to the priority i are calculated respectively as follows:
11. The CAN bus resource minimization method according to claim 5, wherein the increasing or decreasing of the CAN bus communication rate in the step S3 is performed by a stepwise method and/or a binary search method.
12. A computer-readable storage medium with a computer program stored thereon, wherein the computer program, when executed by a processor, can implement a CAN bus resource minimization method, wherein the CAN bus resource minimization method comprises: S1. setting an initial CAN bus communication rate; S2. at the CAN bus communication rate in step S1 and on the basis of an Erlang B formula in the queuing theory, calculating a frame collision rate of a frame of each priority, the running of which on a CAN bus is planned; S3. determining whether the frame collision rate of the frame of each priority calculated in step S2 exceeds an allowable frame collision rate upper limit associated with the respective priority; when the frame collision rate calculated in step S2 exceed the allowable frame collision rate upper limit, increasing the CAN bus communication rate in step S1, and returning to step S2 for continued iteration; when the frame collision rate calculated in step S2 does not exceed the allowable frame collision rate upper limit, decreasing the CAN bus communication rate in step S1, and returning to step S2 for continued iteration; and S4. outputting a minimum communication rate corresponding to the frame collision rate of the frame of each priority that does not exceed the allowable frame collision rate upper limit associated with the respective priority.
13. The computer-readable storage medium according to claim 12, wherein a fixed value is given as the initial CAN bus communication rate, in the step S1.
14. The computer-readable storage medium according to claim 12, wherein in the step S1, the initial CAN bus communication rate is calculated by the following formula:
15. The computer-readable storage medium according to claim 12, wherein the step S2 comprises: at the CAN bus communication rate in step S1 and on the basis of an Erlang B formula in the queuing theory, calculating the frame collision rate of the frame of each priority in the descending order of priorities, wherein the frame collision rate of the frame of the highest priority is calculated directly using the Erlang B formula, while the frame collision rate of the frame of each of the remaining priorities is calculated using the Erlang B formula in combination with a cumulative traffic load and an overflow traffic load associated with the respective priority.
16. The computer-readable storage medium according to claim 15, wherein the frame collision rate Bp[i] of the frame of priority i is calculated as follows:
17. The computer-readable storage medium according to claim 16, wherein the traffic load A[i] of the priority i relative to the CAN bus, the accumulated traffic load L_S[i] of the priority i, and the overflow traffic load A_L[i] from a higher priority to the priority i are calculated respectively as follows:
18. The computer-readable storage medium according to claim 12, wherein the increasing or decreasing of the CAN bus communication rate in the step S3 is performed by a stepwise method and/or a binary search method.
Description
BRIEF DESCRIPTION OF THE DRAWINGS
[0026]
[0027]
[0028]
DETAILED DESCRIPTION
[0029] The embodiments of the present invention will be described in detail below. It shall be emphasized that the following description is exemplary only and is not intended to limit the scope and application of the present invention.
[0030] The terms first and second are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly indicating the quantity of the indicated technical features. Therefore, features defined by first and second may explicitly or implicitly include one or more said features. In the description of the embodiments of the present invention, multiple means two or more, unless explicitly and specifically defined otherwise.
[0031] When designing and developing products using the CAN bus, the configuration of the CAN bus resources must be planned first. Currently, designers mostly refer to empirical values accumulated in the past. For example, in order to reduce the probability of frame collision events on the bus, the load rate of the CAN bus is generally set below 30%. The load rate can be calculated simply by the number of nodes connected to the bus, the sending frequency of each node and the frame length. A priority mechanism is introduced into the CAN bus, in which each priority competes for the transmission resources of the bus through a non-destructive arbitration mechanism. The CAN bus protocol currently may support at most 8 priorities. The protocol defines that the lower the value of the flag bit of a bit is, the higher the priority of the bit will be. That is, 0x00 has the highest priority, while 0x07 has the lowest priority. If data transmission to the bus is performed simultaneously by high and low priorities, then the frame of the high priority automatically obtains the transmission resources, while the frame of the low priority withdraws from arbitration. The frame of the low priority performs retransmission when the bus resources are idle according to the automatic retransmission mechanism. As a result, a frame collision event occurs for the frame of the low priority. In specific operation scenarios, designers may pay particular attention to the frame collision rate of the frame of a certain priority. However, the frame collision rates of frames of different priorities have a non-linear relationship and cannot be obtained through simple calculations.
[0032] In view of the current difficulties in resource configuration planning in the CAN bus development stage, the present invention provides an optimized design method for the CAN bus. First, an algorithm is provided that can accurately calculate the frame collision rate of the frame of each priority. This algorithm uses the Erlang B formula in the queuing theory and it can accurately calculate the frame collision rate of the frame of each priority in a descending order of priorities. Thus, the resource configuration of the CAN bus can be optimized to minimize the bus resources. The method specifically comprises: calculating the frame collision rate of the frame of each priority under a given bus communication rate and frame sending frequency, then comparing the calculated frame collision rate with the preset upper limit of the allowed frame collision rate of the frame of each priority; if the allowed frame collision rate upper limit is exceeded, then increasing the bus bandwidth (i.e., increasing the communication rate); if the allowed frame collision rate upper limit is not exceeded, then decreasing the communication rate; then continuing to calculate the frame collision rate of the frame of each priority at the new communication rate, and comparing the calculated frame collision rate with the allowed frame collision rate upper limit. This cycle continues until the minimum communication rate is calculated at which the frame collision rate of the frame of each priority does not exceed the corresponding allowed frame collision rate upper limit. The bus bandwidth (communication rate) at this point is the minimum bus bandwidth at which the allowed frame collision rate upper limit is not exceeded under the condition of the fixed sending frequency and frame length, thereby achieving optimization of bus resources.
[0033] As shown in
[0035] A smaller or larger initial communication rate B_x of the CAN bus is given, the value of which may start from 0, and then the cycle is continued to calculate the minimum communication rate that meets the conditions through determination. However, this method is computationally intensive and the calculation speed is slow. In order to reduce the amount of calculation and improve the calculation efficiency, this embodiment uses the following formula to calculate the initial communication rate of the CAN bus:
[0038] Usually, three parameters, namely the frame arrival rate , the service rate (1/ is the time required for the service) and the number of servers k, need to be known for the Erlang B formula, that is: Bp=Erlang B(A, k). A=/, and k is the number of servers. In the present application, when the Erlang B formula is applied to the CAN bus to calculate the frame collision rate, the frames of all the priorities run on a CAN bus, so the number of servers k is normalized, i.e., the CAN bus is regarded as one server, k=1. L is the sending frequency of a certain priority, which corresponds to in the Erlang B formula. S is the frame length of the frame of a certain priority, B represents the current CAN bus communication rate, then S/B is the time required for the CAN bus to transmit a frame of a certain priority, which corresponds to 1/ in the Erlang B formula. Therefore, the Erlang B formula may be rewritten as:
[0039] The frame collision rate Bp[i] of the frame of each priority i is calculated as follows:
wherein, i=0 represents the highest priority, i=1, 2, . . . , p1 represents the remaining priorities in the descending order, the number of priorities planned to run on the CAN bus is p; A[i] represents the traffic load of the priority i relative to the CAN bus, k=1, L_S[i] represents the accumulated traffic load of the priority i, and A_L[i] represents the overflow traffic load from a higher priority to the priority i, wherein the traffic load refers to the ratio of the traffic aggregation of each priority to the transmission rate of the CAN bus.
[0040] A[i] is calculated as follows:
wherein L[i] and S[i] respectively represent the sending frequency and the frame length of the frame of the priority i, and B represents the current CAN bus communication rate.
[0041] The cumulative traffic load L_S[i] is calculated as follows:
L_S[i]=AU[j]=.sub.0.sup.iA[j]=0,1, . . . ,i.
[0042] The overflow traffic load A_L[i] is calculated as follows:
[0044] The CAN bus communication rate may be increased/decreased in the stepwise manner, and the fixed step size may be adjusted according to the actual situation. For example, the communication rate (i.e., bus bandwidth) is increased/decreased at a fixed step size of 100 bit/s or 1000 bit/s. A smaller fixed step size will give more accurate results, but it will increase the number of iterations of the calculation and the calculation time. On the contrary, a larger fixed step size will reduce the accuracy of the calculation results, but it increases the calculation speed. The selection of a suitable fixed step size depends on the past accumulated experience of designers.
[0045] In some other embodiments, the CAN bus communication rate may also be increased/decreased by using binary search. For example, a larger bus communication rate and a smaller bus communication rate are obtained through two or more cycles; at a smaller communication rate (Data1), the frame collision rate of the frame of all the priorities does not exceed the frame collision rate upper limit of the frame of the priority; and at a larger communication rate (Data2), the frame collision rate of the frame of at least one priority exceeds the frame collision rate upper limit of the frame of the priority. Then the communication rate Data3 of the next cycle may be obtained by binary search between [Data1, Data2]. If the frame collision rate of the frame of all the priorities does not exceed the frame collision rate upper limit of the frame of the priority at the communication rate Data3, then the communication rate Data4 of the next cycle is obtained by binary search between [Data1, Data3]. If the frame collision rate of the frame of at least one priority exceeds the frame collision rate upper limit of the frame of the priority at the communication rate Data3, then the communication rate Data4 of the next cycle is obtained by binary search between [Data3, Data2]. The above cycle is continued until the minimum communication rate at which the frame collision rate upper limit of the frame of each priority is not exceeded is found out. As compared to the stepwise search, the binary search can reduce the amount of calculation and greatly speed up the calculation in some cases.
[0046] In some other embodiments, the CAN bus communication rate may also be increased/decreased by combining the stepwise method and binary search method. [0047] S4. outputting a minimum communication rate corresponding to the frame collision rate of the frame of each priority that does not exceed the allowable frame collision rate upper limit associated with the respective priority, so as to complete optimization.
[0048] In the prior art, there is no specific algorithm for the frame collision rate, so it is impossible to know the frame collision rate under specific circumstances (including the CAN bus communication rate, the sending frequency of the frame of each priority, the frame length of each priority, and the number of priorities), and thus the bus resources cannot be minimized. In the present invention, an algorithm for calculating the frame collision rate based on the Erlang B formula in the queuing theory is provided, and the bus resources are optimized based on the calculated frame collision rate, so that the minimum bus resources required to ensure that the frame collision rate does not exceed the allowed frame collision rate upper limit when the sending frequency and the frame length are fixed can be found out, thereby realizing optimal configuration of bus resources.
[0049] A lower CAN bus communication rate means a lower bus bandwidth and less requirements on devices, and at the same time, the lower CAN bus communication rate reduces the probability of being affected by electromagnetic interference generated by other devices and increases the communication reliability. In the present invention, the required minimum bus resources (communication rate) is accurately calculated based on the sending frequency of the frame of each priority and the preset upper limit of the frame collision rate of the frame of each priority, thereby achieving the purpose of flexible resource configuration and optimized resource utilization.
[0050] The present invention is applied in the development stage of products using the CAN communication bus, and relates to a design method of the CAN bus. Particularly, in the case of large bus load and simultaneous transmission of frames of multiple priorities, the design efficiency is improved and the bus resource utilization is optimized, so that users of the CAN bus can realize the optimal configuration of the bus resources in the development stage according to different usage scenarios, and CAN bus resources are saved.
Embodiment 1
[0051] In a lithium battery energy storage product, an inverter, an IoT communication module and four battery packs are connected together through the CAN bus. These three kinds of devices send data to the CAN bus periodically or irregularly (triggered by events).
[0052] The priority of sending frames is set as follows: if it is an alarm information frame or an event-triggered query information frame, then the frame length is set to 128 bits and the frame is set with a high priority (0X02); and if it is a periodic broadcast data frame, then the frame length is set to 256 bits and the frame is set with a low priority (0X06). The design index for the frame collision rate of the frame of the high priority is 3%, while the design index of the frame collision rate of the frame of the low priority is 10%.
[0053] Table 1 below shows the content type, the sending frequency and the frame length of the data sent by the inverter module to the CAN bus:
TABLE-US-00001 TABLE 1 Sending Frame frequency length Content (frames/s) (bit) Priority Parts sent periodically Inverter type 1 256 0X06 Time information 1 256 0X06 Device alarm/fault 2 256 0X06 information Photovoltaic power 2 256 0X06 generation information Detailed information of 2 256 0X06 power grid Load information 2.5 256 0X06 Inverter information 2 256 0X06 Detailed information of 1 256 0X06 the electric generator Parts triggered by events Energy line state 1 128 0X02 Device model 0.4 128 0X02 PV connection type 2 128 0X02 System state 2 128 0X02 Working hours statistics 1 128 0X02 Historical records 1 128 0X02 Sum of annual average 1 128 0X02 power generation capacity Sum of power generation 2.5 128 0X02 capacity in a certain year
[0054] Table 2 below shows the content type, the sending frequency and the frame length of the data sent by the IoT communication module to the CAN bus:
TABLE-US-00002 TABLE 2 Parts sent periodically Sending Frame frequency length Content (frames/s) (bit) Priority Periodical 2.5 256 0X06 data
[0055] Table 3 below shows the content type, the sending frequency and the frame length of the data sent by the battery pack module to the CAN bus:
TABLE-US-00003 TABLE 3 Sending Frame frequency length Content (frames/s) (bit) Priority Parts sent periodically Pack basic information 2 4 256 0X06 Parts triggered by events Pack expansion 3 4 128 0X02 information Pack fault information 5 4 128 0X02 About Pack 1.5 4 128 0X02
[0056] Based on the data given in the foregoing tables, the implementation method of the embodiment of the present invention is given below.
[0057] In this embodiment, there are only two priorities, namely 0X02 and 0X06, wherein 0X02 is a high priority and 0X06 is a low priority, and the traffic aggregation of each priority is calculated as follows:
[0058] The high priority: 128(1+0.4+2+2+1+1+1+2.5+34+54+1.54)=12848.9=6259.2 bit/s
[0059] The low priority: 256(1+1+2+2+2+2.5+2+1+2.5+2x4)=25624=6144 bit/s [0060] S1. setting an initial CAN bus communication rate, i.e., a smaller/larger initial communication rate B_x of the CAN bus is given, the value of which may start from 0, and then the cycle is continued to calculate the minimum communication rate that meets the conditions through determination. However, this method is computationally intensive and the calculation speed is slow. In order to reduce the amount of calculation and improve the calculation efficiency, this embodiment uses the following formula to calculate the initial communication rate of the CAN bus:
wherein B_x is the initial CAN bus communication rate, L[0], S[0], and Bp_T[0] respectively represent the sending frequency, the frame length, and the allowable frame collision rate upper limit of the frame of the highest priority.
[0061] In this embodiment, there are only two priorities, namely 0X02 and 0X06, wherein 0X02 is a high priority and 0X06 is a low priority. Therefore, this embodiment uses the design index of the frame collision rate of the frame of the high priority 0X02<3% to calculate the initial communication rate.
wherein, i=0 represents the highest priority, i=1, 2, . . . , p1 represents the remaining priorities in the descending order, the number of priorities planned to run on the CAN bus is p; A[i] represents the traffic load of the priority i relative to the CAN bus, k=1, L_S[i] represents the accumulated traffic load of the priority i, and A_L[i] represents the overflow traffic load from a higher priority to the priority i. The traffic load refers to the ratio of the traffic aggregation of each priority to the transmission rate of the CAN bus.
[0063] Event-triggered transmission refers to transmission according to instructions of users. The user clicks the query instruction at a certain moment, and the query information frame sent by the user is sent through the CAN bus. The sending frequency is completely determined by the user and it is random. It is possible that there is no query instruction at all in a day (24 hours), or there may be multiple query instructions in a certain period of time (within 10 minutes). The more the query instructions are, the greater the load traffic will be. By considering randomly triggered information frames as being sent periodically, then the traffic aggregation of the high priority is calculated in the situation with the largest load traffic, and the situation with the largest load traffic may be regarded as the worst (or the most extreme) situation. When calculating the traffic aggregation of the high priority, it is assumed that it is in the worst situation, then the traffic aggregation of the high priority is calculated as follows:128(1+0.4+2+2+1+1+1+2.5+34+54+1.54)=12848.9=6259.2 bit/s
[0064] The traffic aggregation of the low priority (0X06) is calculated as follows: 256(1+1+2+2+2+2.5+2+1+2.5+24)=25624=6144 bit/s
[0065] In the calculation formula of the frame collision rate Bp[i], the calculation formula of the traffic load A[i] of each priority is as follows:
[0066] In this embodiment, first, the initial communication rate of 202380.8 bit/s calculated in the step S1 is adopted as B, then the traffic load of the frame of each priority is calculated as follows:
[0067] The frame collision rate of the frame of the high priority is directly calculated using the Erlang B formula as follows:
[0068] For the frame collision rate of the frame of other priorities, it is necessary to first calculate the cumulative traffic load and the overflow traffic load, and the calculation formula and specific calculation results thereof are as follows.
[0069] The calculation formula of the cumulative traffic load L_S[i] is as follows:
L_S[i]=.sub.0.sup.iA[j]; j=0,1, . . . ,i;
Then L_S[1]=.sub.0.sup.iA[j]=A[0]+A[1]=0.0309278+0.0303586=0.0612864.
[0070] The calculation formula of the overflow traffic load A_L[i] is as follows:
[0071] Finally, the frame collision rate of the low priority is calculated as follows:
[0073] The CAN bus communication rate may be increased/decreased in the stepwise manner, e.g., with a fixed step size of 100 bit/s or 1000 bit/s; or it may be implemented by binary search, or by a combination of stepwise and binary searches.
[0074] In this embodiment, Bp[0]=3% and Bp[1]=8.7%, which do not exceed the allowed frame collision rate of 3% and 10%, and thus the CAN bus communication rate of 202380.8 bit/s in the step S1 is again decreased to 200 k bit/s.
[0075] According to the communication rate of 200 k bit/s, the calculated frame collision rates of the two priorities are as shown in Table 4 below:
TABLE-US-00004 TABLE 4 Frame collision rates of two priorities at the communication rate of 200 k bit/s CAN bus Traffic Frame communication aggregation collision rate (bit/s) Priority (bit/s) rate 200,000 0x02 6259.2 3.03% 0x06 6144 8.70%
[0076] According to the design index, the high priority does not meet the design index, and the low priority meets the design index, so the design index is still not met as a whole. Therefore, a value is selected between [200000 bit/s, 202380.8 bit/s] for calculation again. For example, 201190.4 bit/s is selected by binary search for calculation, and after calculation, it is found that the high priority still does not meet the design index.
[0077] Finally, through continuous iteration and search, a minimum communication rate of 202380.8 bit/s that meets the design index can be obtained through calculation. At this communication rate, the frame collision rates of the two priorities are as shown in Table 5 below:
TABLE-US-00005 TABLE 5 Frame collision rates of two priorities at the minimum communication rate CAN bus Traffic Frame communication load collision rate (bit/s) Priority (bit/s) rate 202380.8 0x02 6259.2 3.00% 0x06 6144 8.70% [0078] S4. outputting a minimum communication rate corresponding to the frame collision rate of the frame of each priority that does not exceed the allowable frame collision rate upper limit associated with the respective priority, so as to complete optimization.
[0079] Usually, 1000 bit/s is taken as the minimum unit for the communication rate, so the minimum communication rate of 202380.8 bit/s is output as 203 k bit/s.
Embodiment 2
[0080] Other conditions of this embodiment are the same as those of Embodiment 1, except that the initial communication rate of the CAN bus is set to 250 k bit/s.
[0081] When the CAN bus communication rate and the transmission traffic of each priority are fixed, the frame collision rate of a specific priority is calculated. The frame collision rate of the frame of the highest priority is directly calculated using the Erlang B formula, and the frame collision rate of the frame of other priorities is calculated using the Erlang B formula in combination with the cumulative traffic load and the overflow traffic load of the priority. The frame collision rates of the two priorities are calculated respectively as shown in Table 6 below:
TABLE-US-00006 TABLE 6 Frame collision rates of two priorities at the communication rate of 250 k bit/s CAN bus Traffic Frame communication aggregation collision rate (bit/s) Priority (bit/s) rate 250,000 0x02 6259.2 2.45% 0x06 6144 7.06%
[0082] According to the design index, the frame collision rate of the frame of the high priority 0 (0x02) needs to be controlled below 3%, and the frame collision rate of the frame of the low priority 1 (0x06) needs to be controlled below 10%. The above results meet the design index, but the value is too high to meet the minimum communication rate requirements of the output CAN bus. Thus, the value of the CAN bus communication rate is re-selected to be 150 k bit/s.
[0083] When the value of the CAN bus communication rate is 150 k bit/s, the frame collision rates of the two priorities are as shown in Table 7 below:
TABLE-US-00007 TABLE 7 Frame collision rates of two priorities at the communication rate of 150 k bit/s CAN bus Traffic Frame communication aggregation collision rate (bit/s) Priority (bit/s) rate 150,000 0x02 6259.2 4.01% 0x06 6144 11.35%
[0084] According to the design index, it is obvious that the above results do not meet the design index, so the CAN bus communication rate is adjusted again. 200 k bit/s between [150 k bit/s, 250 k bit/s] may be selected by binary search for calculation again. The frame collision rates of the two priorities are the same as those in Table 4.
[0085] According to the design index, the frame collision rate of the frame of the high priority is 3.03%, which does not meet the design index; while the frame collision rate of the frame of the low priority is 8.70%, which meets the design index. The design index is still not met as a whole, so binary search may still be continuously performed so as to find out the minimum communication rate that meets the design index.
[0086] Finally, the minimum CAN bus resources that meet the design index can be obtained after the calculation, as shown in Table 5 above. At this time, the required CAN bus communication rate is 202380.8 bit/s. The purpose of minimizing CAN bus resources is achieved.
[0087] In the present invention, by adopting the Erlang B formula in the queuing theory, and based on data of the fixed sending frequency, the frame length and the given communication rate, the frame collision rate of the frame of each priority is accurately calculated in the descending order of priorities, then the calculated frame collision rate is compared with the preset allowed upper limit of the frame collision rate to determine whether it exceeds the allowed upper limit of the frame collision rate. If it exceeds the allowed upper limit of the frame collision rate, then the communication rate (i.e., the bus bandwidth) is further increased; and if it does not exceed the allowed upper limit of the frame collision rate, then the communication rate is decreased; and then the frame collision rate is recalculated until the minimum communication rate corresponding to not exceeding the frame collision rate upper limit allowed by the frame of each priority is acquired, so that the minimum CAN bus communication rate is calculated and resource configuration optimization of the CAN bus is realized. As can be seen from the Embodiment 2, by using the calculation formula provided in the present invention to calculate the initial communication rate, the calculation amount can be greatly reduced and the calculation efficiency can be improved.
[0088] As shall be appreciated by those skilled in the art, the embodiments of the present invention may be provided as methods, systems, or computer program products. For example, the present invention may also provide a readable storage medium on which a computer program is stored, and the computer program, when executed by a processor, can implement the steps of the CAN bus resource minimization method in the aforementioned embodiments. Thus, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, a disk storage, a CD-ROM, an optical storage, etc.) having computer-usable program codes included therein.
[0089] The present invention is described with reference to flowchart diagrams and/or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present invention. It shall be appreciated that, each process and/or block in the flowchart diagrams and/or block diagrams, and combinations of processes and/or blocks in the flowchart diagrams and/or block diagrams may be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, a special purpose computer, an embedded processor, or other programmable data processing devices to produce a machine, such that the instructions executed by the processor of the computer or other programmable data processing devices produce a device for realizing the functions specified in one or more processes of the flowchart diagrams and/or one or more blocks of the block diagrams.
[0090] These computer program instructions may also be stored in a computer-readable storage which can guide a computer or other programmable data processing devices to operate in a particular manner, such that the instructions stored in the computer-readable storage produce an article of manufacture including the instruction means, and the instructions means implements the functions specified in one or more processes of the flowchart diagrams and/or one or more blocks of the block diagrams.
[0091] These computer program instructions may also be loaded onto a computer or other programmable data processing devices, so that a series of operating steps are performed on the computer or other programmable devices to produce computer-implemented processing, and thus instructions executed on the computer or other programmable devices provide steps for implementing the functions specified in one or more processes of the flowchart diagrams and/or one or more blocks of the block diagrams.
[0092] What described above is further detailed description of the present invention with reference to specific/preferred embodiments, and it should not be concluded that the specific embodiments of the present invention are only limited to these descriptions. For those of ordinary skill in the art to which the present invention belongs, several substitutions or modifications to the described embodiments can be made without departing from the concept of the present invention, and all these substitutions or modifications should be regarded as falling within the scope claimed in the present invention. In the description of this specification, descriptions made with reference to terms of one embodiment, some embodiments, preferred embodiments, examples, specific examples, or some examples mean that specific features, structures, materials or characteristics described in combination with the embodiment or the example are included in at least one embodiment or example of the present invention. In this specification, the schematic expressions of the above terms are not necessarily directed to the same embodiment or example. Furthermore, the specific features, structures, materials or characteristics described may be combined in a suitable manner in any one or more embodiments or examples. Different embodiments or examples and the features of different embodiments or examples described in this specification may be incorporated and combined by those skilled in the art without conflicting with each other. Although the embodiments and the advantages of the present invention have been described in detail, it shall be appreciated that, various changes, substitutions and alterations can be made herein without departing from the scope claimed in the patent application.