A method and device for controlling CAN signals of automobile controller
By grouping and two-dimensional array processing of IDs in automotive CAN signal control, a nested loop is generated, which solves the problem of period stability and frame loss when sending IDs in different periods, and achieves accurate sending of data frames and improved interface calling efficiency. .
Patent Information
- Application Number
- CN202310480462.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-04-28
- Publication Date
- 2024-09-03
- Estimated Expiration
- 2043-04-28
AI Technical Summary
In automotive CAN signal control, the existing technology is difficult to ensure the stability of the data transmission cycle and avoid frame loss when multiple IDs are sent in different cycles, especially when the load rate is lower than the ideal load rate.
By grouping all IDs, the number of small cycles in each group is calculated, and a two-dimensional array and nested loop are generated, and the data frames are merged to generate the total number of signals within the minimum sending interval to avoid channel blocking.
It effectively avoids data loss, ensures the accuracy of the sending cycle of each ID, reduces the time consumption of interface calls, and satisfies the accurate control of IDs in different cycles.
Smart Images

Figure CN116774623B
Abstract
Description
Technical Field
[0001] The present application relates to the field of automobile CAN signal detection and control, and in particular to a method and device for controlling CAN signals of an automobile controller. Background Art
[0002] Taking the mainstream automotive CAN signal controller test product (CAN box) Zhou Ligong (ZLG) USB-CANFD-200U on the market as an example, its communication baud rate is set to 800KBPS, and when the CAN type of 8-byte data frame is set to send, the amount of CAN data per frame is 124BIT. The theoretical data throughput rate is 800*1000÷124=6451 frames, and the ideal data throughput is 60% of the theoretical throughput, that is, 3870 frames, that is, 38 frames of data can be sent every 10ms under ideal conditions.
[0003] In CAN signal control applications, the host computer software usually needs to control the CAN box to send a large number of data frames with different IDs to the CAN bus, and often send them periodically. The sending cycle of data frames with different IDs may be different. Other controller products receive their own data frames from the CAN bus by querying the ID.
[0004] The host computer software uses 30 ID data as a group, for example, 30 frames of data are sent at a time, and when calling the ZLG transmission function interface (ZCAN_Transmit) to send data, the test found that the calling time of the interface is ≥10ms and the time consumption fluctuates. After repackaging the sending function, the interface calling time can be stably reduced to less than 10ms.
[0005] When testing automotive controller products, the host computer needs to simulate other controller products to send CAN data frames through the CAN box (for example, the minimum ID cycle is 10ms, and the maximum ID cycle is 1000ms). Therefore, the host computer needs to send multiple channels and multiple frames of CAN data at the same time. If the number of IDs that need to be forwarded in any CAN communication exceeds 30, the time consumption of calling the sending function interface will cause CAN data frame sending cycle errors or even frame loss (blocking the data sending of the host computer software, and some data cannot be sent normally from the host computer).
[0006] For example, take 2730fps as an example, where each cycle is assigned 15 IDs (10ms, 20ms, 50ms, 100ms
[0007] ,500ms), a total of 75 IDs. At this time, if the traditional sending method is used, a maximum of 75 frames need to be sent at the same time. The call time of ZLG's data sending interface will be much longer than 10ms, which will cause control cycle errors in IDs with a period of 10ms, 20ms, and 50ms.
[0008] The data transmission function interface (ZCAN_Transmit) of CAN box such as ZLG has a time fluctuation when transmitting 30 IDs simultaneously, and the time consumption is ≥10ms, which leads to the problem of ID transmission cycle control error. For example, the first 10ms sends 30 IDs with a 10ms cycle, and the interface call takes 12ms. When the ID is sent again in the second 10ms, the interface is blocked for 2ms, which will cause the ID of the second 10ms cycle to have a cycle error of more than 2ms, and the cycle error rate is greater than 20%. Therefore, when the fifth cycle is reached, the blockage will accumulate for more than 10ms, resulting in the loss of one frame of data with an ID of 10ms cycle; similarly, IDs with cycles of 20ms, 50ms, 100ms, 500ms, and 1000ms will lose one frame of data in the 10th, 25th, 50th, 250th, and 500th 10ms, respectively.
[0009] In summary, there is an urgent need to solve the problem of sending multiple IDs in different cycles. When the total load rate is lower than the ideal load rate, it is necessary to ensure that the sending cycle of the sent data is stable and there is no frame loss. Summary of the invention
[0010] In view of this, the present invention provides a method for controlling CAN signals of an automobile controller, characterized in that:
[0011] Group all IDs according to the transmission period to obtain multiple groups of IDs;
[0012] According to the transmission period of multiple groups of IDs, the number of small periods of each different group is calculated;
[0013] Group multiple groups of IDs twice according to the number of small cycles to obtain two-dimensional array elements;
[0014] Generate nested loops based on the two-dimensional array elements and the number of small cycles;
[0015] Merge the two-dimensional array elements in the same emission interval according to the nested loop to generate a two-dimensional array;
[0016] According to the two-dimensional array, the CAN data signal is sent to the controller of the vehicle at the transmission interval.
[0017] It should be noted that the control software needs to send a batch of control signals to the corresponding car controller.
[0018] The control signals (with different identity information - different IDs) are grouped and then sent at different signal sending cycles to avoid channel blocking caused by concentrated sending.
[0019] It should also be noted that the data table A is generated by using the ID according to the sending cycle as the vertical axis and the corresponding identity information as the horizontal axis, so as to clearly display the sending cycle of all IDs, because each ID has different identity information and carries different signal information or control commands.
[0020] It should be noted that the number of small cycles N = packet ID sending cycle / minimum sending interval.
[0021] It should be noted that a two-dimensional array is generated based on a data table and a nested loop; because all IDs have been grouped, and then merged to generate data table A. Through data table A, the information of all IDs, including the sending cycle, can be clearly seen. For different IDs that have been grouped, secondary grouping is performed according to the number of small cycles in each group to obtain different two-dimensional array elements. Through the two-dimensional array elements, according to the minimum time interval and according to the number of small cycles, the nested cycles for different groups are obtained. The complete nested loop is obtained by merging the nested cycles of all different groups. At the same time, the cumulative summation of the array elements of different groups in the same time interval is performed to obtain the total number of signals that need to occur in each minimum sending interval. Whether the total number of signals exceeds a certain limit value, resulting in signal blocking, is the technical problem that the present application needs to solve.
[0022] It should be noted that the CAN data signal is sent to the controller of the car according to the nested loop and the two-dimensional array. The two-dimensional array is obtained through the previous step, and then according to the nested loop and the two-dimensional array, the host computer software sends a CAN signal with different identity information to the controller of the car.
[0023] It should be noted here that according to the nested loop and the two-dimensional array, the CAN data signal is sent to the controller of the car at the minimum sending interval. According to the nested loop, the CAN digital control signal is finally sent to the car controller at the minimum sending interval; at the same time, the order and number of digital control signals are calculated by the two-dimensional array to obtain the sum of all signals with different group IDs in a single sending interval for sending.
[0024] Correspondingly, the present invention also provides an application device of the CAN signal control method of an automobile controller, which
[0025] The features include:
[0026] An ID grouping module is used to group all IDs according to the transmission period to obtain multiple groups of IDs;
[0027] A small cycle calculation module is used to calculate the number of small cycles of each different group according to the transmission cycle of multiple groups of IDs;
[0028] A two-dimensional array element generation module is used to perform secondary grouping of multiple ID groups according to the number of small cycles to obtain two-dimensional array elements;
[0029] A nested loop generation module is used to generate nested loops based on two-dimensional array elements and the number of small cycles;
[0030] A two-dimensional array generation module, used for merging two-dimensional array elements within the same emission interval according to a nested loop to generate a two-dimensional array;
[0031] The data signal sending module is used to send the CAN data signal to the controller of the vehicle according to the two-dimensional array and at a transmission interval.
[0032] Technical effect description: The present invention groups all different IDs to obtain IDs of different groups, and calculates the number of small cycles of each different group.
[0033] The present invention groups all different IDs, and performs secondary grouping according to the number of small cycles in each group for the grouped different IDs, thereby obtaining different two-dimensional array elements. The two-dimensional array elements are arranged according to the minimum time interval and the number of small cycles, thereby obtaining nested cycles for different groups. The nested cycles of all different groups are merged to obtain a complete nested loop. At the same time, the array elements of different groups in the same time interval are accumulated and summed, thereby obtaining the total number of signals that need to occur in each minimum sending interval.
[0034] Improved, the steps of generating nested loops include:
[0035] Determine the minimum sending interval Ts;
[0036] Arranging the two-dimensional array elements according to the number of small cycles and the sending interval period to form nested periods of different groups;
[0037] merging the nested cycles of the different groups;
[0038] Generates nested loops.
[0039] Correspondingly, the nested loop generation module includes:
[0040] A sending interval unit, used to determine a minimum sending interval Ts;
[0041] A nesting cycle generating unit, used for arranging the two-dimensional array elements according to the number of small cycles and the sending interval cycle to form nesting cycles of different groups;
[0042] A group merging unit, used for merging the nested cycles of different groups;
[0043] The nested loop generation unit is used to generate nested loops. Technical effect description: By setting the minimum period Tmin and the maximum period Tmax of sending data frames, all IDs to be sent are grouped and merged into data group A. The data Ai of each group of data in data group A and its corresponding sending interval time Ti are divided into Ni data groups with Tmin as the common divisor to obtain the small cycle number Nt=Ti / Tmin of data group Ai.
[0044] Improved, the step of generating a two-dimensional array comprises:
[0045] By confirming that the minimum period and the maximum period are Tmin and Tmax respectively, the number of cycles with a sending period of Tn is calculated as N;
[0046] By taking the remainder m from N*Tn / Tmax, the remainder is used to index the mth row of the two-dimensional array B:
[0047] Bnm; after the interval Tn, the remainder m' of (N+1)*Tn / Tmax is used to index the two-dimensional array B
[0048] The m'th row of the array is 1, and we get Bnm';
[0049] By taking all interval times from 2 intervals Tn to N-1 intervals Tn;
[0050] Get all arrays Bni from Bn0 to Bn(n-1);
[0051] Take all the sending cycles of Tn from Tmin to Tmax;
[0052] Merge to generate a two-dimensional array table.
[0053] Correspondingly, the two-dimensional array generation module includes:
[0054] The cycle calculation unit is used to calculate the minimum cycle and the maximum cycle according to Tmin and Tmax respectively.
[0055] Calculate the number of cycles with a sending period of Tn as N;
[0056] The coordinate generation unit uses the remainder m of N*Tn / Tmax to index the mth row array of the two-dimensional array B as Bnm; after the interval Tn, the remainder m' of (N+1)*Tn / Tmax is used to index the m'th row array of the two-dimensional array B as 1, and obtains Bnm';
[0057] The time interval selection unit is selected by taking all the interval times from 2 intervals Tn to N-1 intervals Tn;
[0058] A two-dimensional array generation unit is used to obtain all arrays Bni from Bn2 to Bn(n-1);
[0059] A transmission cycle selection unit, used for taking all transmission cycles of Tn from Tmin to Tmax;
[0060] A two-dimensional array table generation unit generates a two-dimensional array table by merging.
[0061] An embodiment is provided, when the maximum period Tmax=1000ms, Tmin=10ms, and Tn=10ms, the number of periods is N=Tmax / Tn=100, so the remainder m=N*Tn / Tmax=100*10 / 1000-1 remainder 0.
[0062] After an interval of 10ms, m'=(N+1)*Tn / Tmax=101*10 / 1000-1 remainder 1.
[0063] Another example is provided. When Tn=20ms and N=50, the calculation formula becomes N*Tn / Tmax=50*20 / 1000=1 plus 0.
[0064] After an interval of 20ms, (N+1)*Tn / Tmax=51*20 / 1000=1 remainder 20.
[0065] After an interval of 20ms, (N+2)*Tn / Tmax=52*20 / 1000=1 remainder 40.
[0066] Improved, the steps of calculating the number of cycles N with a sending period of Tn are:
[0067] N=Tmax / Tn, where Tn is the ID sending period.
[0068] In an improved method, the m-th row array of the two-dimensional array B is indexed to 0 by using the remainder, so as to send the ID data to be sent in the m-th row array through the repackaged sending function of ZLG.
[0069] The present invention also provides an electronic device, comprising a memory and a processor, wherein the memory stores a computer program product.
[0070] The computer program is executed in the processor to implement any of the above methods. The electronic device may be a mobile terminal or a web terminal.
[0071] The present invention also provides a storage medium storing a computer program, wherein the computer program can implement any of the above methods when executed in a processor.
[0072] The present invention provides an application device of a CAN signal control method for an automobile controller. The present invention groups all different IDs, and performs secondary grouping according to the number of small cycles in each group for the different grouped IDs, thereby obtaining different two-dimensional array elements. The two-dimensional array elements are arranged according to the minimum time interval and the number of small cycles, thereby obtaining nested cycles for different groups. The nested cycles of all different groups are merged to obtain a complete nested loop. At the same time, the array elements of different groups in the same time interval are accumulated and summed, thereby obtaining the total number of signals that need to occur in each minimum sending interval.
[0073] According to the nested loop and two-dimensional array, CAN data signals are sent to the car controller at the minimum sending interval. According to the nested loop, the CAN numerical control signal is finally sent to the car controller at the minimum sending interval; at the same time, the order and number of the numerical control signal are calculated by the two-dimensional array to calculate the sum of all signals with different group IDs in a single sending interval. The original data sending mode is changed, and the new nested cycle generates a re-encapsulation of the sending function to obtain a new data sending function. Finally, the data is sent regularly according to the nested loop, so that the upper computer software can avoid sending data frames at the same time, effectively avoiding data loss. BRIEF DESCRIPTION OF THE DRAWINGS
[0074] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0075] Figure 1 A schematic diagram of a structure of signal transmission between a host computer and a vehicle controller provided in an embodiment;
[0076] Figure 2 A flowchart of a method for controlling CAN signals of an automobile controller provided by an embodiment;
[0077] Figure 3 An embodiment provides a pair Figure 2 Flow chart of the improved method of the method in the figure;
[0078] Figure 4 An embodiment provides a pair Figure 2 Flow chart of the improved method of the method in the figure;
[0079] Figure 5 Correspondence provided for an embodiment Figure 2 The device architecture diagram of the method;
[0080] Figure 6 for Figure 3 The architecture diagram of the nested loop generation module in ;
[0081] Figure 7 for Figure 4 The architecture diagram of the two-dimensional array generation module in Figure 2;
[0082] Figure 8 This is the ID nested loop timing diagram in Table 1;
[0083] Fig. 9 This is the traditional sending timing diagram. DETAILED DESCRIPTION
[0084] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0085] Embodiment 1
[0086] refer to Figure 1 , Figure 2 The present invention provides a method for controlling CAN signals of an automobile controller, which is characterized by comprising the steps of:
[0087] S1. Group all IDs according to the transmission period to obtain multiple groups of IDs;
[0088] S2. Calculate the number of small periods of each different group according to the transmission period of multiple groups of IDs;
[0089] S3, grouping the multiple ID groups according to the number of small cycles to obtain two-dimensional array elements;
[0090] S4, generating a nested loop according to the two-dimensional array elements and the number of small cycles;
[0091] S5, merging the two-dimensional array elements within the same emission interval according to the nested loop to generate a two-dimensional array;
[0092] S6. Send a CAN data signal to the controller of the vehicle according to the two-dimensional array and at a transmission interval.
[0093] It should be noted that the host computer software sends control signals to various controllers of the car through the CAN bus. The present invention is based on the host computer software sending different (different identity information ID) control signals to the corresponding controllers of the car.
[0094] An embodiment is provided to generate a data table A according to multiple groups of IDs, and the data table A is shown in Table-1.
[0095] Embodiment 2
[0096] See also Figure 5 The present invention provides an application device of a CAN signal control method for an automobile controller, characterized in that it includes:
[0097] ID grouping module 1, used for grouping all IDs according to the transmission period to obtain multiple groups of IDs;
[0098] A small cycle calculation module 2 is used to calculate the number of small cycles of each different group according to the transmission cycle of multiple groups of IDs;
[0099] A two-dimensional array element generation module 3 is used to perform secondary grouping of multiple ID groups according to the number of small cycles to obtain two-dimensional array elements;
[0100] A nested loop generation module 4 is used to generate a nested loop according to the two-dimensional array elements and the number of small cycles;
[0101] A two-dimensional array generation module 5, used for merging two-dimensional array elements within the same emission interval according to a nested loop to generate a two-dimensional array;
[0102] The data signal sending module 6 is used to send the CAN data signal to the controller of the vehicle according to the two-dimensional array and at a transmission interval.
[0103] Embodiment three:
[0104] See also Figure 3 , the steps to generate nested loops include:
[0105] S40, determining a minimum sending interval Ts;
[0106] S41, arranging the two-dimensional array elements according to the number of small cycles and the sending interval period to form nested periods of the different groups;
[0107] S42, merging the nested cycles of the different groups;
[0108] S43. Generate a nested loop.
[0109] Embodiment 4:
[0110] See also Figure 6 , the nested loop generation module includes:
[0111] A sending interval unit 40, used to determine a minimum sending interval Ts;
[0112] A nesting period generating unit 41, configured to arrange the two-dimensional array elements according to the number of small periods and the sending interval period to form nesting periods of the different groups;
[0113] A group merging unit 42, configured to merge the nesting periods of the different groups;
[0114] The nested loop generating unit 43 is used to generate a nested loop.
[0115] Embodiment five:
[0116] See also Figure 4 , the step of generating a two-dimensional array comprises:
[0117] S50, by confirming that the minimum period and the maximum period are Tmin and Tmax respectively, calculating the cycle period of the sending period Tn as N;
[0118] S51. Take the remainder m from N*Tn / Tmax and use the remainder to index the mth row of the two-dimensional array B.
[0119] The group is Bnm; after the interval Tn, by using the remainder m' of (N+1)*Tn / Tmax, the remainder is used to index the m'th row of the two-dimensional array B as 1, and Bnm' is obtained;
[0120] S52, by taking all interval times from 2 intervals Tn to N-1 intervals Tn;
[0121] S53, obtain all arrays Bni from Bn0 to Bn(n-1);
[0122] S54, take all sending cycles of Tn from Tmin to Tmax;
[0123] S55, merge and generate a two-dimensional array table.
[0124] Embodiment six:
[0125] See also Figure 7 , the two-dimensional array generation module includes:
[0126] The cycle calculation unit 50 is used to calculate the minimum cycle and the maximum cycle based on Tmin and Tmax.
[0127] and Tmax, calculate the number of cycles with a sending period of Tn as N;
[0128] The coordinate generating unit 51 uses the remainder m of N*Tn / Tmax to index the mth row array of the two-dimensional array B as Bnm; after an interval of Tn, uses the remainder m' of (N+1)*Tn / Tmax to index the m'th row array of the two-dimensional array B as 1, and obtains Bnm';
[0129] The time interval selection unit 52 selects all the interval times from 2 intervals Tn to N-1 intervals Tn;
[0130] The two-dimensional array generation unit 53 obtains all arrays Bni from Bn2 to Bn(n-1);
[0131] A transmission cycle selection unit 54, used to select all transmission cycles Tn from Tmin to Tmax;
[0132] The two-dimensional array table generating unit 55 generates a two-dimensional array table by merging.
[0133] An embodiment is provided, when the maximum period Tmax=1000ms, Tmin=10ms, and Tn=10ms, the number of periods is N=Tmax / Tn=100, so the remainder m=N*Tn / Tmax=100*10 / 1000-1 remainder 0.
[0134] After an interval of 10ms, m'=(N+1)*Tn / Tmax=101*10 / 1000-1 remainder 1.
[0135] Another example is provided. When Tn=20ms and N=50, the calculation formula becomes N*Tn / Tmax=50*20 / 1000=1 plus 0.
[0136] After an interval of 20ms, (N+1)*Tn / Tmax=51*20 / 1000=1 remainder 20.
[0137] After another 20ms interval, (N+2)*Tn / Tmax=52*20 / 1000=1 remainder 40.
[0138] It should be noted here that by using N*Tn / Tmax to take the remainder m, the remainder is used to index the mth row array of the two-dimensional array B as Bnm, and after a time interval Tn, the remainder m' is taken by the calculation formula N*Tn / Tmax, and the remainder m' is used to index the m'th row array of the two-dimensional array B as Bnm'. The interval time is from the first interval Tn to the N-1 interval Tn, so all arrays Bni from Bn0 to Bn(n-1) are obtained.
[0139] This part is based on all arrays obtained within the same sending period Tn.
[0140] Because the transmission period of the control signal of different IDs is from Tmin to Tmax, then all the transmission periods from Tmin to Tmax are counted to obtain a two-dimensional array of corresponding transmission periods.
[0141] Merge all two-dimensional arrays to get a two-dimensional array table (or matrix data).
[0142] In the above embodiment, when Tn=10ms, remainder m=N*Tn / Tmax=100*10 / 1000-1+0.
[0143] After an interval of 10ms, m'=(N+1)*Tn / Tmax=101*10 / 1000-1 remainder 1.
[0144] The remainder can be from 0 to 99, because the number of cycles of Tn=10ms in 1000ms is 100.
[0145] In another embodiment, when Tn=20ms, N=50, the calculation formula becomes N*Tn / Tmax=50*20 / 1000=1 plus 0.
[0146] After an interval of 20ms, (N+1)*Tn / Tmax=51*20 / 1000=1 remainder 20.
[0147] After an interval of 20ms, (N+2)*Tn / Tmax=52*20 / 1000=1 remainder 40.
[0148] The remainders range from 0, 20, 40, 60, 80... all the way to 980.
[0149] The time is from Tmin to Tmax, and all two-dimensional arrays are obtained.
[0150] The two-dimensional array obtained above is distributed according to the nested loop and data table to obtain the data sent every 10ms, so the generated matrix data table is as follows Figure 8 The nested cycle shown.
[0151] Improved, the steps of calculating the number of cycles N with a sending period of Tn are:
[0152] N=Tmax / Tn, where Tn is the ID sending period.
[0153] In an improved method, the m-th row array of the two-dimensional array B is indexed to 0 by using the remainder, so as to send the ID data to be sent in the m-th row array through the repackaged sending function of ZLG.
[0154] Embodiment seven:
[0155] Table 1-CAN send ID allocation example table is shown as follows:
[0156] cycle ID1 ID2 ID3 ID4 ID5 ID6 ID7 ID8 ID9 ID10 ID11 ID12 ID13 ID14 ID15 10ms 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 20ms 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 50ms 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 100ms 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 500ms 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714
[0157] Distribute 75 IDs in 10ms, 20ms, 50ms, 100ms, and 500ms, with 15 IDs in each cycle, and merge the IDs with the same cycle to form a two-dimensional array A. Take Tmin=10ms as the interval and Tmax=1000ms as the cycle period.
[0158] The ID grouping method corresponding to Table 1 is:
[0159] 1. 10ms periodic ID, needs to be sent every 10ms
[0160] 2. 20ms period ID, divided into 2 groups, small period number N=2
[0161] B[0]={200,201,202,203,204,205,206,207}
[0162] B[1]={208,209,210,211,212,213,214}
[0163] 3. 50ms cycle ID, divided into 5 groups, the number of small cycles N=5
[0164] B[0]={500,501,502}
[0165] B[1]={503,504,505}
[0166] B[2]={506,507,508}
[0167] B[3]={509,510,511}
[0168] B[4]={512,513,514}
[0169] 4. 100ms period ID, divided into 10 groups, the number of small periods N=10
[0170] B[0]={600}
[0171] B[1]={601,602}
[0172] B[2]={603}
[0173] B[3]={604,605}
[0174] B[4]={606}
[0175] B[5]={607,608}
[0176] B[6]={609}
[0177] B[7]={610,611}
[0178] B[8]={612}
[0179] B[9]={613,614}
[0180] 4. 500ms cycle ID, divided into 50 groups, the number of small cycles N=50
[0181] B[0]-B
[14] each takes an ID, and the rest are empty.
[0182] like Figure 8 As shown:
[0183] The number of IDs to be sent in the first 10ms = N10+N20+N50+N60+N70, which equals 28, meets the requirement that the ZLG sending function interface call is less than 10ms.
[0184] It should be noted that, in this embodiment, the interval period finally selected is 10 ms, which is the same as the minimum transmission period (10 ms).
[0185] In the first interval period of 10ms, according to the nested loop and the coordinate value of the two-dimensional array, the number of signals sent in the first interval period of 10ms is obtained, and the calculation can be obtained that ID=N10+N20+N50+N60
[0186] +N70 equals 28.
[0187] It is also necessary to explain how to calculate the number of signals in the nth time interval. This is also based on the nested cycles. The coordinates of the nth column are obtained, and then the coordinate values in the two-dimensional number are found through the coordinates. The final number of signals is obtained by adding the values of all transmission cycles.
[0188] In this embodiment, when 75 IDs are sent at 2730fps, the traditional maximum number of IDs to be sent at the same time (Table 1) is optimized to an average of 28 IDs per 10ms, and the sending cycle of each ID is accurate, so that the ID data is not lost.
[0189] thus:
[0190] 1. Meet the ZLG sending function (ZCAN_Transmit) interface call, send ID ≤ 30 at the same time, the interface call takes ≤ 10ms.
[0191] 2. Since the ZCAN_Transmit interface call is ≤10ms, the problem of periodic data transmission congestion is completely solved, thereby meeting the accurate control of ID cycles of all different cycles.
[0192] 3. As a result, the ID cycle control is accurate, thus avoiding the problem of CAN data frame loss.
[0193] Embodiment 8
[0194] Distribute 85 IDs in 10ms, 20ms, 50ms, 100ms, and 500ms, with 15 IDs in each cycle (25 IDs in 500ms), and merge IDs with the same cycle to form a two-dimensional array A. Take Tmin=10ms as the interval and Tmax=1000ms as the cycle period.
[0195] The ID grouping method corresponding to Table 1 is:
[0196] 1. 10ms periodic ID, needs to be sent every 10ms
[0197] 2. 20ms period ID, divided into 2 groups, small period number N=2
[0198] B[0]={200,201,202,203,204,205,206,207}
[0199] B[1]={208,209,210,211,212,213,214}
[0200] 3. 50ms cycle ID, divided into 5 groups, the number of small cycles N=5
[0201] B[0]={500,501,502}
[0202] B[1]={503,504,505}
[0203] B[2]={506,507,508}
[0204] B[3]={509,510,511}
[0205] B[4]={512,513,514}
[0206] 4. 100ms period ID, divided into 10 groups, the number of small periods N=10
[0207] B[0]={600}
[0208] B[1]={601,602}
[0209] B[2]={603}
[0210] B[3]={604,605}
[0211] B[4]={606}
[0212] B[5]={607,608}
[0213] B[6]={609}
[0214] B[7]={610,611}
[0215] B[8]={612}
[0216] B[9]={613,614}
[0217] 4. 500ms cycle ID, divided into 50 groups, the number of small cycles N=50
[0218] B[0]-B
[24] each takes an ID, and the rest are empty.
[0219] Similarly, you can refer to Figure 8 , the number of IDs to be sent in the first 10ms = N10+N20+N50+N60+N70 is equal to 28, which meets the requirement that the ZLG sending function interface call is less than 10ms.
[0220] Also in this embodiment, when 85 IDs are sent at 2730fps, the traditional maximum number of 85 IDs to be sent at the same time is optimized to an average of 28 IDs every 10ms, and the sending cycle of each ID is guaranteed to be accurate, so that the ID data does not lose frames.
[0221] Embodiment 9
[0222] The 95 IDs are distributed in 10ms, 20ms, 50ms, 100ms, and 500ms, with 15 IDs in each cycle (35 IDs are allocated for 500ms), and the IDs with the same cycle are merged to form a two-dimensional array A. The interval is Tmin=10ms and the cycle period is Tmax=1000ms.
[0223] 500ms period ID, divided into 50 groups, number of small periods N=50
[0224] B[0]-B
[34] each takes an ID, and the rest are empty.
[0225] Similarly, you can refer to Figure 8 , the number of IDs to be sent in the first 10ms = N10+N20+N50+N60+N70 is equal to 28, which meets the requirement that the ZLG sending function interface call is less than 10ms.
[0226] Also in this embodiment, when 95 IDs are sent at 2730fps, the traditional maximum number of 95 IDs to be sent at the same time is optimized to an average of 28 IDs every 10ms, and the sending cycle of each ID is guaranteed to be accurate, so that the ID data does not lose frames.
[0227] The present invention also provides an electronic device, comprising a memory and a processor, wherein the memory stores a computer program product.
[0228] The computer program is executed in the processor to implement any of the above methods. The electronic device may be a mobile terminal or a web terminal.
[0229] The present invention also provides a storage medium storing a computer program, wherein the computer program can implement any of the above methods when executed in a processor.
[0230] The present invention avoids data loss caused by sending data frames at the same time within a certain time by setting a nested cycle. Different small cycles and large cycles are generated according to the ID cycle, and the ID is evenly divided, the ID is grouped, and a nested loop is generated. A nested data group A is generated according to the nested cycle, and data is merged according to the index of the nested data group A. Finally, data is sent regularly according to the nested loop, so that it is possible to avoid sending data frames at the same time, effectively avoiding data loss.
[0231] The above disclosure is only the preferred embodiment of the present application, which certainly cannot be used to limit the scope of rights of the present application. Therefore, equivalent changes made according to the claims of the present application are still within the scope covered by the present application.
Claims
1. A method for controlling CAN signals of an automobile controller, characterized in that: Includes steps: Group all IDs according to the transmission period to obtain multiple groups of IDs; According to the transmission periods of the multiple groups of IDs, the number of small periods of each different group is calculated; The multiple groups of IDs are grouped twice according to the number of small cycles to obtain two-dimensional array elements; Generate a nested loop according to the two-dimensional array elements and the number of small cycles; Merging the two-dimensional array elements within the same emission interval according to the nested loop to generate a two-dimensional array; Sending a CAN data signal to a controller of the vehicle according to the two-dimensional array and at the transmission interval; The step of generating a two-dimensional array comprises: By confirming that the minimum period and the maximum period are Tmin and Tmax respectively, the number of cycles with a sending period of Tn is calculated as N; By taking the remainder m of N*Tn / Tmax, the remainder is used to index the mth row array of the two-dimensional array B as Bnm; after interval Tn, by taking the remainder m' of (N+1)*Tn / Tmax, the remainder is used to index the m'th row array of the two-dimensional array B as 1, and Bnm' is obtained; By taking all interval times from 2 intervals Tn to N-1 intervals Tn; Get all arrays Bni from Bn0 to Bn(n-1); Take all the sending cycles of Tn from Tmin to Tmax; Merge to generate a two-dimensional array table.
2. The CAN signal control method according to claim 1, characterized in that: The steps of generating a nested loop include: Determine the minimum sending interval Ts; Arranging the two-dimensional array elements according to the number of small cycles and the sending interval period to form nested periods of the different groups; merging the nested cycles of the different groups; Generates nested loops.
3. The CAN signal control method according to claim 2, characterized in that: The steps for calculating the number of cycles N with a sending period of Tn are: N=Tmax / Tn, where Tn is the ID sending period.
4. The CAN signal control method according to claim 2, characterized in that: The m-th row array of the two-dimensional array B is indexed by the remainder as 0, so as to send the ID data to be sent in the m-th row array through the repackaged sending function of ZLG.
5. An application device of a CAN signal control method for an automobile controller, characterized in that: include: An ID grouping module is used to group all IDs according to the transmission period to obtain multiple groups of IDs; A small cycle calculation module, used to calculate the number of small cycles of each different group according to the transmission cycle of the multiple groups of IDs; A two-dimensional array element generation module, used for performing secondary grouping of the multiple groups of IDs according to the number of small cycles to obtain two-dimensional array elements; A nested loop generation module, used for generating a nested loop according to the two-dimensional array elements and the number of small cycles; A two-dimensional array generation module, used for merging the two-dimensional array elements within the same emission interval according to the nested loop to generate a two-dimensional array; A data signal sending module, used for sending a CAN data signal to a controller of the vehicle according to the two-dimensional array and at the transmission interval; The step of generating a two-dimensional array comprises: By confirming that the minimum period and the maximum period are Tmin and Tmax respectively, the number of cycles with a sending period of Tn is calculated as N; By taking the remainder m of N*Tn / Tmax, the remainder is used to index the mth row array of the two-dimensional array B as Bnm; after interval Tn, by taking the remainder m' of (N+1)*Tn / Tmax, the remainder is used to index the m'th row array of the two-dimensional array B as 1, and Bnm' is obtained; By taking all interval times from 2 intervals Tn to N-1 intervals Tn; Get all arrays Bni from Bn0 to Bn(n-1); Take all the sending cycles of Tn from Tmin to Tmax; Merge to generate a two-dimensional array table.
6. The device according to claim 5, characterized in that The nested loop generation module comprises: A sending interval unit, used to determine a minimum sending interval Ts; A nesting period generating unit, used for arranging the two-dimensional array elements according to the number of small periods and the sending interval period to form nesting periods of the different groups; A group merging unit, used for merging the nesting periods of the different groups; The nested loop generation unit is used to generate nested loops.
7. The device according to claim 5, characterized in that The two-dimensional array generation module comprises: The cycle calculation unit is used to calculate the minimum cycle and the maximum cycle according to Tmin and Tmax respectively. Calculate the number of cycles with a sending period of Tn as N; The coordinate generation unit uses the remainder m of N*Tn / Tmax to index the mth row array of the two-dimensional array B as Bnm; after the interval Tn, the remainder m' of (N+1)*10 / 1000 is used to index the m'th row array of the two-dimensional array B as 1, and obtains Bnm'; The time interval selection unit is selected by taking all the interval times from 2 intervals Tn to N-1 intervals Tn; A two-dimensional array generation unit is used to obtain all arrays Bni from Bn2 to Bn(n-1); A transmission cycle selection unit, used for taking all transmission cycles of Tn from Tmin to Tmax; A two-dimensional array table generation unit generates a two-dimensional array table by merging.
8. An electronic device comprising a memory and a processor, wherein the memory stores a computer program, wherein: The computer program is executed in the processor to implement any one of the methods described in claims 1-4.
9. A computer-readable storage medium storing a computer program, characterized in that: The computer program is executed in a processor to implement any one of the methods described in claims 1-4.
Citation Information
Patent Citations
Calculation method of CAN bus load rate
CN106992879A
System and method for testing CAN message transmission period of local area network of vehicle controller
CN109696900A
Data transmission method, sending device and receiving device
CN113810471A
CAN FD bus communication method and device and electronic equipment
CN114826816A
Deterministic hardware system for communication between at least one sender and at least one receiver, which is configured to statically and periodically schedule the data frames, and a method for managing the reception of data frames
US20210320781A1
