Method for acquiring fast signal by XCP of CAN bus

By building a high-speed sampling buffer on the CAN bus and using XCP to set calibration, dynamically collect and store signals, the problem of bandwidth limitation of traditional CAN bus is solved, high-speed XCP data acquisition is realized, and the acquisition rate and data accuracy are improved.

CN119937365APending Publication Date: 2025-05-06浙江创驱智能科技有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411851418.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-16
Publication Date
2025-05-06

AI Technical Summary

Technical Problem

The traditional CAN bus is limited by bandwidth during XCP data acquisition, which is difficult to meet the requirements of high-frequency sampling, limiting the accuracy and real-timeness of data acquisition.

Method used

By building a high-speed sampling buffer, using XCP to set the calibration identification variable address and type, dynamically collect signals and store them in the buffer, and send data to the host according to the low-speed sampling period when the buffer is full.

Benefits of technology

Without increasing hardware costs, high-speed XCP data acquisition on the low-speed CAN bus is realized, which improves the acquisition rate and ensures clear distinction and consistency of data segments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119937365A_ABST
    Figure CN119937365A_ABST
Patent Text Reader

Abstract

The invention discloses a method for acquiring a fast signal by an XCP of a CAN bus. The method comprises the following steps: constructing a high-speed sampling buffer area for storing a specific observation variable; setting a first calibration quantity used for identifying a variable address and a second calibration quantity used for identifying a variable type through the XCP; acquiring a sampling signal according to a high-speed sampling period, performing conversion processing on the acquired sampling signal according to the first calibration quantity and the second calibration quantity, generating a specific observation quantity, and putting the specific observation quantity into the high-speed sampling buffer area for storage; and when the high-speed sampling buffer area is full or not, acquiring a specific observed quantity from the high-voltage sampling buffer area according to a low-speed sampling period of the XCP, putting the acquired specific observed quantity into an ODT linked list of the XCP, and packaging and sending the specific observed quantity to a host through the XCP. According to the method, any observed quantity can be dynamically acquired at a high speed, and problems in practical application can be more effectively analyzed and solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the technical field of automobile control, and in particular to a method for XCP of a CAN bus to collect fast signals. Background Art

[0002] In the field of automotive control, engineers need to obtain and calibrate various parameters on the vehicle to achieve the best control effect. The XCP protocol (Universal Calibration Protocol) provides a standardized solution for this demand. However, limited by the bandwidth of the traditional CAN bus, especially for the 500kBps baud rate CAN communication commonly used in passenger cars, the theoretical minimum time to transmit a frame of DTO (data object sent by ECU to XCP Master in the XCP protocol) is 212 microseconds. However, since the XCP protocol requires that DTO data transmission be completed before the end of the next sampling cycle, such as Figure 1 As shown in the figure, and taking into account the bit interval and arbitration process in CAN message transmission, the maximum data acquisition frequency that can be achieved in practice is 3kHz.

[0003] The traditional XCP data collection process is as follows Figure 2 As shown. By using the command (ADD_DAQ) to define the data acquisition table, including the variable name, address, data length and sampling period to be collected, the ECU will periodically collect the specified variables, package them and send them to the host through CAN and other communication methods. Due to the limitation of CAN bandwidth, the acquisition cycle usually cannot be too short, so it is difficult to meet the needs of high-speed data acquisition scenarios, such as motor controller applications. For motor controllers, the PWM interrupt frequency is usually around 10kHz. The traditional XCP data acquisition method is difficult to keep up with the changes in this high-frequency signal, and it is impossible to accurately collect the changes in key parameters such as three-phase current at each PWM interrupt. This bandwidth limitation makes it difficult for traditional solutions to meet high-frequency sampling requirements, limiting the accuracy and real-time performance of data acquisition.

[0004] In order to solve the above problems, the following are the commonly used solutions, as follows:

[0005] Solution 1: To address the problem of insufficient bandwidth, Bosch launched a new generation of CAN protocol, CAN FD, in 2011. CAN FD has a longer data segment, and its data segment transmission rate can reach up to 5MHz. In addition, the XCP protocol based on the Ethernet transport layer can also effectively solve the problem of bandwidth limitation, and its transmission rate easily exceeds 3MHz.

[0006] The main drawback of this solution is that neither of these two solutions is currently the mainstream communication method for ECUs. To support CAN FD, the entire vehicle network must be fully upgraded to CAN FD, and the CAN devices and XCP Master software need to be upgraded accordingly to support XCP on CAN FD. In addition, Ethernet interfaces are usually not configured in the power domain, chassis domain, and body domain of the car, which also brings additional challenges to its widespread application.

[0007] Solution 2: Vector VX1000 series is a high-performance measurement and calibration tool launched by Vector Informatik specifically for the development, calibration and testing of automotive electronic control units (ECUs). This series of tools can efficiently collect, measure and calibrate ECU data and is suitable for various complex automotive electronic systems.

[0008] The main drawback of this solution is that the hardware and software of the Vector VX1000 series are high-end tools and are relatively expensive. In addition, VX1000 needs to use different adapter modules for different processor architectures (such as Infineon, NXP, STMicroelectronics, Renesas, etc.) and connect to the processor through the debugging and programming interface. Usually, the debugging interface can only be connected after the ECU cover is opened, which brings great limitations in application, especially in mass production and regular operation environments.

[0009] Therefore, the applicant has found a solution to the above-mentioned problem through beneficial exploration and research, and the technical solution to be introduced below is produced in this context. Summary of the invention

[0010] The technical problem to be solved by the present invention is to provide a method for collecting fast signals by XCP of a CAN bus in view of the deficiencies of the prior art.

[0011] The technical problem to be solved by the present invention can be achieved by adopting the following technical solutions:

[0012] A method for collecting fast signals by XCP of a CAN bus, comprising:

[0013] Construct a high-speed sampling buffer for storing specific observation variables;

[0014] Set the first scalar value for identifying the variable address and the second scalar value for identifying the variable type through XCP;

[0015] Acquire a sampling signal according to a high-speed sampling period, convert the acquired sampling signal according to the first calibration amount and the second calibration amount, and generate a specific observation amount and store it in the high-speed sampling buffer; and

[0016] When the high-speed sampling buffer is full, a specific observation value is obtained from the high-voltage sampling buffer according to the low-speed sampling period of XCP, and the obtained specific observation value is put into the ODT linked list of XCP, and then packaged and sent to the host through XCP.

[0017] In a preferred embodiment of the present invention, the method of acquiring a sampling signal according to a high-speed sampling period, performing type conversion processing on the acquired sampling signal according to the first calibration amount and the second calibration amount, and generating a specific observation amount and storing it in the high-speed sampling buffer includes:

[0018] Check whether the high-speed sampling buffer is full;

[0019] If the high-speed sampling buffer is full, the data ready flag is set to indicate that the data is ready;

[0020] If the high-speed sampling buffer is not full, check whether XCP has completed the process of obtaining specific observations from the high-speed sampling buffer and sending them;

[0021] If XCP is sending data, stop sampling;

[0022] If XCP completes sending data, the sampled signal is classified and processed according to the second calibration quantity, and a value of the corresponding type is extracted from the sampled signal through the first calibration quantity, and then a specific observation value is generated after being forcibly converted into a type consistent with the specific observation value, and finally the generated specific observation value is placed in the high-speed sampling buffer.

[0023] Due to the adoption of the above technical solution, the beneficial effect of the present invention is that: without increasing the hardware cost, the present invention realizes high-speed XCP data acquisition on the low-speed CAN bus. By decomposing an observation into two calibration quantities of variable type and variable address and a specific observation, dynamic and high-speed acquisition of any observation is realized, and the present invention helps to more effectively analyze and solve problems in practical applications. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] In order to more clearly illustrate the embodiments of the present invention 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 invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0025] Figure 1 It is a schematic diagram of the traditional XCP data collection and transmission process.

[0026] Figure 2 It is a schematic diagram of traditional XCP data collection.

[0027] Figure 3 It is a flow chart of the method for XCP collecting fast signals of the CAN bus of the present invention.

[0028] Figure 4 It is a flow chart of putting specific observation quantities into a high-speed sampling buffer in the present invention.

[0029] Figure 5 It is a flow chart of taking out a specific observation quantity from a high-speed sampling buffer in the present invention.

[0030] Figure 6 It is a timing diagram of the CAN bus of the present invention performing XCP high-speed sampling.

[0031] Figure 7 Schematic diagram of the high-speed XCP sampling rate method of the present invention.

[0032] Figure 8 It is a variable decomposition diagram of high-speed data sampling of the present invention. DETAILED DESCRIPTION

[0033] In order to make the technical means, creative features, objectives and effects achieved by the present invention easy to understand, the present invention is further explained below with reference to specific diagrams.

[0034] See also Figure 3 , the figure shows a method for XCP acquisition of fast signals of CAN bus, including the following steps:

[0035] Step S10, constructing a high-speed sampling buffer for storing specific observation variables.

[0036] Step S20: Setting a first scalar value for identifying a variable address and a second scalar value for identifying a variable type through XCP.

[0037] Step S30, acquiring a sampling signal according to a high-speed sampling period, converting and processing the acquired sampling signal according to a first calibration value and a second calibration value, and generating a specific observation value and storing it in a high-speed sampling buffer.

[0038] Step S40, when the high-speed sampling buffer is full, obtain the specific observation value from the high-voltage sampling buffer according to the low-speed sampling cycle of XCP, put the obtained specific observation value into the ODT linked list of XCP, and then send it to the host through XCP packaging. In step S40, the method of obtaining the specific observation value from the high-speed sampling buffer includes but is not limited to the assignment method, direct reading, etc.

[0039] In step S30, see Figure 4 , acquiring a sampling signal according to a high-speed sampling period, performing type conversion processing on the acquired sampling signal according to a first calibration quantity and a second calibration quantity, and generating a specific observation quantity and putting it into a high-speed sampling buffer for storage, including the following steps:

[0040] Step S31, check whether the high-speed sampling buffer is full, if the high-speed sampling buffer is full, go to step S32, otherwise go to step S33;

[0041] Step S32, setting the data preparation flag Filling_OK to TRUE, indicating that the data is ready;

[0042] Step S33, checking whether XCP has completed the process of acquiring and sending specific observations from the high-speed sampling buffer, that is, checking whether the TX_OK flag is TRUE. If not, it indicates that XCP is sending data, and then sampling is stopped; if so, it indicates that XCP has completed sending data, and then enters step S34; the specific observations are put into the high-speed sampling buffer and taken out from the high-speed sampling buffer alternately, so that the high-speed sampling data observed on the XCP will present a constant value in a certain period of time, which is convenient for distinguishing data fragments;

[0043] Step S34, classify the sampled signal according to the second calibration value, such as boolean, int, unsigned int and float, and extract the corresponding type of value from the sampled signal through the first calibration value, and then force it to be converted into a type consistent with the specific observation value to generate a specific observation value, and finally put the generated specific observation value into the high-speed sampling buffer.

[0044] The period of taking data out of the high-speed buffer for a specific observation (Watch_Var) should be consistent with the XCP acquisition period for the specific observation, such as Figure 5 As shown, the specific steps are as follows:

[0045] 1) Check if the data preparation flag Filling_OK is TRUE, and make sure that the data in the high-speed sampling buffer is not completely sent. If the condition is not met, set the XCP data transmission completion flag TX_OK to TRUE;

[0046] 2) If the judgment result is TRUE, the XCP data unsent completion flag TX_OK is set to FALSE, and it is prohibited to continue to put the specific observation into the high-speed sampling buffer;

[0047] 3) Extract data from the high-speed sampling buffer in sequence to obtain specific observation quantities.

[0048] This ensures efficient alternation of data collection and transmission, improves the collection rate, and ensures clear distinction and consistency of data segments.

[0049] The method for collecting fast signals of the XCP of the CAN bus of the present invention is to separate the data collection and data transmission steps and call them asynchronously. Figure 6 The high-speed sampling function is triggered by the high-speed interrupt inside the ECU (such as the PWM interrupt of the motor controller, the typical value is 100us interrupt). The function will pack the specific observations that need to be monitored and store them in the high-speed sampling buffer. When the high-speed sampling buffer is full, the specific observations are taken out from the high-speed sampling buffer in turn according to the low-speed sampling period of XCP (for example, 2ms or 10ms sampling). XCP periodically collects these specific observations and packs them and sends them to the host.

[0050] In this way, the collected high-speed signal is presented in the form of fragments, and the time length of the fragment depends on the high-speed sampling period and the size of the buffer. Therefore, this method is not limited by the CAN bandwidth and can significantly increase the sampling rate, such as Figure 7 shown.

[0051] In order to realize flexible switching of observation quantities during high-speed sampling and avoid re-updating and downloading programs, the present invention proposes a method of adding two calibration quantities and one observation quantity, such as Figure 8 The specific functions are as follows:

[0052] 1) The first calibration quantity, which is used to identify the variable address Watch_Choose: defined as an enumeration type, containing the variable names of all observations, and the enumeration value represents the variable address of the high-speed observation;

[0053] 2) The second calibrator is used to identify the variable type Watch_Type: defined as an enumeration type, representing basic data types such as boolean, int, unsigned int, and float;

[0054] 3) Specific observation Watch_Var, which is used to identify the variable that needs to be observed.

[0055] In the present invention, XCP does not directly observe the variables to be observed, but rather observes the specific observation quantity Watch_Var. The interrupt service program converts the variables to be observed into floating-point numbers through type conversion and puts them into the high-speed buffer; the tasks with the same cycle as XCP sequentially take out the specific observation quantity Watch_Var from the high-speed buffer, and XCP periodically collects the value of the specific observation quantity Watch_Var and packages it to the host. A high-speed observation quantity is decomposed into two calibration quantities and one specific observation quantity, such as Figure 8 By switching the first calibration quantity Watch_Choose and the second calibration quantity Watch_Type, and observing through the specific observation quantity Watch_Var, XCP can dynamically collect any observation quantity at high speed during runtime, realizing flexible and efficient data collection.

[0056] The above shows and describes the basic principles and main features of the present invention and the advantages of the present invention. It should be understood by those skilled in the art that the present invention is not limited to the above embodiments. The above embodiments and descriptions are only for explaining the principles of the present invention. Without departing from the spirit and scope of the present invention, the present invention may have various changes and improvements, which fall within the scope of the present invention to be protected. The scope of protection of the present invention is defined by the attached claims and their equivalents.

Claims

1. A method for collecting fast signals using XCP of a CAN bus, characterized in that: include: Construct a high-speed sampling buffer for storing specific observation variables; Set the first scalar value for identifying the variable address and the second scalar value for identifying the variable type through XCP; Acquire a sampling signal according to a high-speed sampling period, convert the acquired sampling signal according to the first calibration amount and the second calibration amount, and generate a specific observation amount and store it in the high-speed sampling buffer; and When the high-speed sampling buffer is full, a specific observation value is obtained from the high-voltage sampling buffer according to the low-speed sampling period of XCP, and the obtained specific observation value is put into the ODT linked list of XCP, and then packaged and sent to the host through XCP.

2. The method for collecting fast signals by XCP of CAN bus as claimed in claim 1, characterized in that: The method of acquiring a sampling signal according to a high-speed sampling period, performing type conversion processing on the acquired sampling signal according to the first calibration amount and the second calibration amount, and generating a specific observation amount and putting it into the high-speed sampling buffer for storage includes: Check whether the high-speed sampling buffer is full; If the high-speed sampling buffer is full, the data ready flag is set to indicate that the data is ready; If the high-speed sampling buffer is not full, check whether XCP has completed the process of obtaining specific observations from the high-speed sampling buffer and sending them; If XCP is sending data, stop sampling; If XCP completes sending data, the sampled signal is classified and processed according to the second calibration quantity, and a value of the corresponding type is extracted from the sampled signal through the first calibration quantity, and then a specific observation value is generated after being forcibly converted into a type consistent with the specific observation value, and finally the generated specific observation value is placed in the high-speed sampling buffer.