Sensor signal simulation method and device, electronic equipment and storage medium
By implementing the sensor signal simulation method on a microcontroller, the problem of difficulty in accurately simulated SPC signals in the prior art is solved, and high signal accuracy and automated control are achieved, thereby reducing the testing cost.
Patent Information
- Application Number
- CN202411832136.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-12
- Publication Date
- 2025-03-25
AI Technical Summary
In bench testing, it is difficult for the prior art to accurately simulate SPC signals. Real sensors cannot guarantee the accuracy of the signal, and cannot create the desired output waveform, and cannot automatically control the output signals. Using SPC emulation boards has high cost and mismatch interfaces, so automated control cannot be achieved.
By implementing the sensor signal simulation method on a microcontroller, the trigger command of the target controller and the data to be transmitted by the upper computer through the CAN transceiver module are received, the target data is selected and processed based on the SENT protocol format, the simulated SENT segment signal is generated, and the target controller is sent to the target controller.
It realizes a high consistency between the simulation signal and the real sensor signal in format and timing, improves the accuracy and reliability of the test, avoids the defects of using real sensors or SPC simulation boards, and reduces the testing cost.
Smart Images

Figure CN119690043A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of sensor simulation technology, and in particular to a sensor signal simulation method, device, electronic device and storage medium. Background Art
[0002] With the development of automobile electrification, the electromagnetic environment of automotive electronic components has become relatively harsh. The sensors used in vehicles are more sensitive to the electromagnetic environment. In order to enable the on-board controller to detect the working status of the sensor more accurately, the signal output type of many sensor chips has also changed from analog signals to digital signals. Taking the torque angle sensor used in the electric steering gear as an example, the SPC (Short PWM Code) signal it outputs has specific and strict transmission rules, so that it can accurately and controllably transmit information to the controller of the electric steering gear.
[0003] However, in bench testing, if you want to simulate SPC signals, you must strictly follow the transmission rules to generate the corresponding signals. At present, real sensors are mostly used in testing, but real sensors cannot guarantee the accuracy of the signals, cannot produce the expected output waveform, and cannot automatically control the output signals. In addition, if an SPC simulation board is used, the cost is high, and since the interface is not a CAN interface, the output signal cannot be automatically controlled. Summary of the invention
[0004] In view of the above problems, embodiments of the present application provide a sensor signal simulation method, device, electronic device and storage medium to overcome the above problems or at least partially solve the above problems.
[0005] In a first aspect, an embodiment of the present application provides a sensor signal simulation method, which is applied to a single-chip microcomputer, wherein the single-chip microcomputer is connected to a target controller and a host computer in a test bench, and the single-chip microcomputer is used to simulate a SENT segment in an SPC signal sent by a target sensor to the target controller, and the method includes:
[0006] Receive a trigger instruction sent by a target controller in the test bench, and data to be transmitted sent by a host computer in the test bench through a CAN transceiver module; wherein the data to be transmitted includes data in multiple formats;
[0007] According to the trigger instruction, select target data from data in multiple formats included in the data to be transmitted;
[0008] Based on the SENT protocol format corresponding to the target sensor, the target data is processed to obtain a simulated SENT segment signal;
[0009] The simulated SENT segment signal is sent to the target controller.
[0010] In a second aspect, an embodiment of the present application further provides a sensor signal simulation device, which is applied to a single chip microcomputer, the single chip microcomputer is connected to a target controller and a host computer in a test bench, and the single chip microcomputer is used to simulate the SENT segment in the SPC signal sent by the target sensor to the target controller, and the device includes:
[0011] A receiving module, used to receive a trigger instruction sent by a target controller in a test bench, and data to be transmitted sent by a host computer in the test bench through a CAN transceiver module; wherein the data to be transmitted includes data in multiple formats;
[0012] A data selection module, used to select target data from data of multiple formats included in the data to be transmitted according to the trigger instruction;
[0013] A data processing module, used for processing the target data based on the SENT protocol format corresponding to the target sensor to obtain a simulated SENT segment signal;
[0014] The first sending module is used to send the simulated SENT segment signal to the target controller.
[0015] In a third aspect, an embodiment of the present application further provides an electronic device, which includes a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the computer program implements the above-mentioned sensor signal simulation method when executed by the processor.
[0016] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the above-mentioned sensor signal simulation method is implemented.
[0017] The embodiments of the present application include at least the following technical effects:
[0018] The technical solution of the embodiment of the present application, by receiving the trigger instruction sent by the target controller in the test bench and the data to be transmitted including multiple formats sent by the host computer in the test bench through the CAN transceiver module, and according to the trigger instruction, the target data is selected from the data of multiple formats included in the data to be transmitted, and the data is screened by the trigger instruction, so that the single-chip microcomputer can flexibly adapt to different test requirements, accurately obtain the data related to the current simulation task, improve the adaptability and pertinence of the entire simulation system, so that the tester can adjust the format of the data to be transmitted through the host computer, so as to adapt to different test scenarios. Based on the SENT protocol format corresponding to the target sensor, the target data is processed to obtain the simulated SENT segment signal, ensuring the high consistency of the simulated signal and the real sensor signal in format and timing, so that the performance of the target controller in the real sensor environment can be more accurately evaluated, and the accuracy and reliability of the test can be improved. By using a single-chip microcomputer to simulate the sensor signal, the problem of not being able to guarantee the accuracy of the signal, not being able to manufacture the expected output waveform, and not being able to automatically control the output signal when using a real sensor for testing is avoided. Since no real sensor or SPC simulation board is required, the test cost can also be reduced. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] 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 are briefly introduced below.
[0020] Figure 1 It is one of the flow charts of the sensor signal simulation method provided in the embodiment of the present application;
[0021] Figure 2 It is a schematic diagram of the SPC signal format;
[0022] Figure 3 It is a schematic diagram of the SENT segment signal;
[0023] Figure 4 This is the second flow chart of the sensor signal simulation method provided in the embodiment of the present application;
[0024] Figure 5 is a structural schematic diagram of a sensor signal simulation device provided in an embodiment of the present application;
[0025] Figure 6 A block diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0026] 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 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.
[0027] It should be understood that the references to "one embodiment" or "an embodiment" throughout the specification mean that the specific features, structures, or characteristics associated with the embodiment are included in at least one embodiment of the present application. Therefore, the references to "in one embodiment" or "in an embodiment" appearing throughout the specification do not necessarily refer to the same embodiment. In addition, these specific features, structures, or characteristics may be combined in any suitable manner in one or more embodiments.
[0028] In the various embodiments of the present application, it should be understood that the size of the serial numbers of the following processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0029] In the prior art, in bench testing, if you want to simulate SPC signals, you must strictly follow its transmission rules to generate corresponding signals. At present, real sensors are mostly used in testing, but real sensors cannot guarantee the accuracy of signals, cannot produce the expected output waveform, and cannot automatically control the output signal. In addition, if an SPC simulation board is used, the cost is high, and since the interface is not a CAN interface, the output signal cannot be automatically controlled.
[0030] Based on this, the present application provides a sensor signal simulation method, device, electronic device and storage medium. In the test bench, by using a single-chip microcomputer to simulate the sensor signal, the problem of being unable to guarantee the accuracy of the signal, unable to produce the expected output waveform and unable to automatically control the output signal when using a real sensor for testing is avoided. Since no real sensor or SPC simulation board is required, the test cost can also be reduced.
[0031] like Figure 1 As shown, an embodiment of the present application provides a sensor signal simulation method, which is applied to a single-chip microcomputer, the single-chip microcomputer is connected to a target controller and a host computer in a test bench, and the single-chip microcomputer is used to simulate the SENT segment in the SPC signal sent by the target sensor to the target controller. The method includes:
[0032] Step 101, receiving a trigger instruction sent by a target controller in a test bench, and receiving data to be transmitted sent by a host computer in the test bench through a CAN transceiver module; wherein the data to be transmitted includes data in multiple formats.
[0033] The sensor signal simulation method provided in the embodiment of the present application is applied to a single-chip microcomputer, which is connected to the target controller in the test bench and the host computer. This connection architecture is the hardware basis of the entire signal simulation process. The test bench is a comprehensive test platform in related test fields such as automotive electronics. The target controller is usually the core control unit in the system under test, and the host computer is used to control and configure the entire test process and provide a rich source of test data. For example, the target sensor can be a torque angle sensor, and the target controller can be a controller in an electric steering gear.
[0034] Specifically, at least one IO port in the single-chip microcomputer is configured as an input mode for receiving a trigger instruction sent by the controller, and correspondingly, at least one IO port in the single-chip microcomputer is configured as an output mode for sending a corresponding SENT segment signal to the controller. In addition, there may be multiple transmission channels between the single-chip microcomputer and the target controller, and each transmission channel is composed of an IO port configured as an input mode and an IO port configured as an output mode. The number of specific transmission channels is determined by the actual needs of the target controller in the test bench, and this application does not make specific limitations. For example, there are usually four transmission channels between the torque angle sensor and the controller of the electric steering gear. This application is introduced by taking the signal simulation in one of the transmission channels as an example. When there are multiple transmission channels, it is necessary to distinguish different transmission channels and simulate the corresponding sensor signals respectively.
[0035] In a test bench, it is usually necessary to perform the test under some special working conditions, but the real sensor is operated by a person, and it is difficult to obtain the data required under these special working conditions. The embodiment of the present application can simulate the SENT segment in the SPC signal sent by the target sensor to the target controller through a single chip microcomputer.
[0036] like Figure 2 As shown, the SPC signal includes a trigger segment, a synchronization segment, and a SENT segment, wherein the SENT segment further includes a status segment, a first data segment, a second data segment, a third data segment, a check segment, and ends with an end frame. The trigger segment is when the controller pulls down the voltage of the signal line and maintains it for a certain period of time. The sensor identifies the triggered ID based on the length of time and matches Status, Data1, Data2, Data3, and CRC based on the ID; the synchronization segment is a fixed 56 time period, the purpose of which is to test the length of a single time period, and the length of a single time period is the total length of the synchronization segment divided by 56; the status segment is the sensor state, which is used to determine the current working state of the sensor.
[0037] First, the MCU receives the trigger instruction sent by the target controller, that is, the trigger segment in the SPC signal is triggered by the target controller. The trigger instruction is the key signal to start the signal simulation process, which instructs the MCU to start subsequent data processing operations.
[0038] At the same time, the single-chip microcomputer receives the data to be transmitted sent by the host computer through the CAN transceiver module. The data to be transmitted is the data pre-set by the host computer for a certain test condition. Among them, the data to be transmitted can include data in multiple formats. For example, the real torque angle sensor can sense the torque applied by the driver on the steering wheel and the angle of the steering shaft in real time, and provide key input information for the control system of the electric steering gear, so that the system can accurately control the operation of the steering motor based on this information and achieve appropriate steering assistance or steering action. Then, the data to be transmitted corresponding to the torque angle sensor includes two formats, one is torque data and the other is angle data.
[0039] In addition, the host computer transmits the data to be transmitted through the CAN transceiver module. The CAN communication rate can reach 0.25ms per time, while the frequency required by the sensor's SPC signal is generally 1ms. The CAN communication rate is higher than the required rate of the SPC signal, so that the simulated signal can be output at a high frequency, and then the required waveform can be transmitted to the target controller through the SPC signal without distortion, meeting specific working conditions.
[0040] Step 102: According to the trigger instruction, select target data from data in multiple formats included in the data to be transmitted.
[0041] After receiving the trigger instruction and the data to be transmitted, the target data can be selected from the data to be transmitted in various formats according to the trigger instruction. The trigger instruction may include a signal ID, and different signal IDs correspond to data in different formats. For example, the signal ID in the trigger instruction issued by the controller in the electric steering gear can be 0 or 1, where 0 corresponds to torque data and 1 corresponds to angle data. When the signal ID is 0, the torque data in the data to be transmitted is determined as the target data. When the signal ID is 1, the angle data in the data to be transmitted is determined as the target data.
[0042] Data screening based on trigger instructions can enable the microcontroller to flexibly adapt to different test requirements and accurately obtain data related to the current simulation task, thereby improving the adaptability and pertinence of the entire simulation system.
[0043] Step 103: Based on the SENT protocol format corresponding to the target sensor, the target data is processed to obtain a simulated SENT segment signal.
[0044] After determining the target data, the target data is processed based on the SENT protocol format corresponding to the target sensor. The SENT protocol has its own specific specifications in sensor signal transmission, including data encoding method, timing requirements, etc. The MCU needs to reorganize and encode the target data according to the format specified by the SENT protocol. For example, the SENT protocol requires that the data be divided into nibbles (4 bits) of a specific length for transmission, and a specific time interval is set between each nibble, and the transmission time of the data is indicated by the change of a single edge of the signal (such as a rising edge or a falling edge). Based on these requirements in the SENT protocol format, the MCU needs to convert the target data into a signal form that conforms to the SENT protocol, thereby obtaining a simulated SENT segment signal. This step ensures that the simulated signal is highly consistent with the SENT segment in the real SPC signal in terms of format and timing, so that the subsequent target controller can receive and process the simulated signal as if it were a real sensor signal.
[0045] Step 104: Send the simulated SENT segment signal to the target controller.
[0046] After obtaining the simulated SENT segment signal, the simulated SENT segment signal is sent to the target controller. Therefore, relevant tests can be performed on the target controller in the test bench environment. For example, after receiving the simulated SENT segment signal corresponding to the torque angle sensor simulated by the single-chip microcomputer, the controller in the electric steering gear can make corresponding control decisions based on the signal. By observing the reaction of the controller in the electric steering gear after receiving the simulated signal, its control performance under various working conditions can be evaluated, potential design defects or software vulnerabilities can be discovered, and a basis can be provided for system optimization and improvement.
[0047] In the embodiment of the present application, a trigger instruction is received from a target controller in a test bench and data to be transmitted including data in multiple formats sent by a host computer in the test bench through a CAN transceiver module, and according to the trigger instruction, target data is selected from data in multiple formats included in the data to be transmitted, and data is screened through the trigger instruction, so that the single-chip microcomputer can flexibly adapt to different test requirements and accurately obtain data related to the current simulation task, thereby improving the adaptability and pertinence of the entire simulation system, so that the tester can adjust the format of the data to be transmitted through the host computer to adapt to different test scenarios.
[0048] In addition, based on the SENT protocol format corresponding to the target sensor, the target data is processed to obtain the simulated SENT segment signal, ensuring the high consistency of the simulated signal with the real sensor signal in format and timing, so that the performance of the target controller in the real sensor environment can be more accurately evaluated, and the accuracy and reliability of the test are improved. By using a single-chip microcomputer to simulate the sensor signal, the problems of being unable to guarantee the accuracy of the signal, unable to create the expected output waveform, and unable to automatically control the output signal when using a real sensor for testing are avoided. Since no real sensor or SPC simulation board is required, the test cost can also be reduced.
[0049] In an optional embodiment of the present application, receiving a trigger instruction sent by a target controller in a test bench includes:
[0050] Detecting the level signal outputted from the target controller to the single chip microcomputer according to a preset frequency;
[0051] When it is detected that the level signal switches from a high level to a low level, timing is started, and when the level signal switches from a low level to a high level, timing is ended to obtain the duration of the low level;
[0052] When the duration of the low level is within a preset duration range, it is determined that the trigger instruction is received.
[0053] In the specific implementation process, the target controller is connected to the IO port configured as input mode in the single-chip microcomputer. Through the IO port, the target controller can send a trigger instruction to the single-chip microcomputer when it needs to obtain sensor data, so that the single-chip microcomputer performs signal simulation and feeds back to the target controller.
[0054] The timing module corresponding to the MCU will detect the level signal output by the target controller to the MCU at a preset frequency. This preset frequency is determined based on specific test requirements and system operating characteristics. For example, in some automotive electronic system test scenarios with high real-time requirements, a relatively high detection frequency may be set, such as once every 2.5us.
[0055] By performing detection according to the preset frequency, preparations can be made for subsequent determination of whether a trigger instruction has arrived.
[0056] When the MCU detects that the level signal changes from high level to low level, the timing function is immediately started, and this moment marks the start of the possible trigger process. The timing process continues until the level signal changes from low level to high level again, at which time the timing is stopped, and the obtained time length is the duration of the low level. This timing operation is performed by the timing module inside the MCU. The timing module has high-precision timing capabilities and can accurately record the time span that the level is in the low level state.
[0057] The preset duration range is a time interval determined in advance according to test requirements and system communication protocols, or a time interval consisting of multiple discontinuous time intervals. When the obtained low level duration falls within this preset duration range, it can be determined that a trigger instruction has been received, and then the signal simulation operation needs to be performed according to the trigger instruction.
[0058] In the above implementation scheme of the present application, accurate reception of trigger instructions is a prerequisite for the orderly development of the entire test process. The trigger instructions are determined by detecting changes in the level signal and combining the comparison of the low level duration with the preset duration range, ensuring that only the signal corresponding to the level change duration that meets the requirements is identified as a valid trigger instruction. This allows the entire test process to proceed in an orderly manner according to the preset steps, thereby improving the test efficiency and the reliability of the test results.
[0059] In an optional embodiment of the present application, after determining that the trigger instruction is received, the method further includes:
[0060] Obtaining the correspondence between the signal identifier and the duration range;
[0061] According to the corresponding relationship, a target signal identifier corresponding to the low level duration is determined.
[0062] Specifically, the correspondence between the predefined signal identifier and the duration range can be stored in the memory of the single-chip microcomputer. For example, the purpose of the trigger instruction issued by the controller in the electric steering gear can be to request torque data or to request angle data. In order to distinguish different requirements, the controller of the electric steering gear can issue trigger instructions corresponding to different low-level durations so that the single-chip microcomputer can determine whether the simulated data is torque data or angle data. Different low-level durations correspond to different signal identifiers. For example, the signal identifier corresponding to 22.5us-30us is 0; the signal identifier corresponding to 47.5us-57.5us is 1. Correspondingly, different signal identifiers correspond to different data. For example, 0 corresponds to torque data and 1 corresponds to angle data.
[0063] Then, when it is determined that a trigger instruction has been received and the duration of the low level has been obtained, the microcontroller will search for a target signal identifier that matches it in the stored correspondence. The target signal identifier determines the specific operation to be performed next or the specific sensor signal to be simulated.
[0064] In the above example, once it is determined that the target signal identifier is 1, the microcontroller knows that it needs to select the angle data from the received data to be transmitted, and process the angle data according to the SENT protocol format to generate the corresponding simulated SENT segment signal and send it to the target controller.
[0065] The above implementation scheme of the present application can distinguish a variety of different trigger instructions by using different low-level durations through the correspondence between the signal identifier and the duration range, thereby increasing the flexibility and scalability of the system. Accurately determining the target signal identifier according to the low-level duration provides a clear direction for subsequent operations, enables accurate execution of corresponding tasks, and improves the accuracy and reliability of the test results.
[0066] In an optional embodiment of the present application, selecting target data from data of multiple formats included in the data to be transmitted according to the trigger instruction includes:
[0067] Obtaining a target signal identifier corresponding to the trigger instruction;
[0068] Obtaining the correspondence between signal identifiers and data formats;
[0069] According to the corresponding relationship, target data corresponding to the target signal identifier is determined.
[0070] Specifically, after the corresponding target signal identifier is determined according to the predetermined correspondence between the low level duration range and the signal identifier, the correspondence between the signal identifier and the data format is further obtained, which can also be predetermined and stored in the memory of the single chip computer. For example, for a torque angle sensor, the corresponding data format includes torque data and angle data.
[0071] After obtaining the target signal identifier and the correspondence between the signal identifier and the data format, the microcontroller will search and match the received data to be transmitted in multiple formats based on the correspondence to determine the target data.
[0072] The above implementation scheme of the present application selects the target data through the target signal identifier and the correspondence between the signal identifier and the data format, avoiding the situation of blindly searching or misselecting data among a large number of data to be transmitted, and can accurately pick out the data related to the current trigger instruction. In addition, since the correspondence between the signal identifier and the data format can be flexibly configured according to different sensors and different test requirements, the system can adapt well to various data sources and format changes.
[0073] In an optional embodiment of the present application, the simulated SENT segment signal includes a status segment, a first data segment, a second data segment, a third data segment, and a check segment in sequence, and each segment is composed of a low level segment and a high level segment, wherein the low level segment corresponds to a preset duration; based on the SENT protocol format corresponding to the target sensor, the target data is processed to obtain a simulated SENT segment signal, including:
[0074] According to the target data, determine a first duration corresponding to the high level segment in the first data segment, a second duration corresponding to the high level segment in the second data segment, and a third duration corresponding to the high level segment in the third data segment;
[0075] Determine a state value according to the target data, and determine a fourth duration corresponding to a high level segment in the state segment according to the state value;
[0076] Calculating a check value corresponding to the target data by a preset check algorithm, and determining a fifth duration corresponding to the high level segment in the check segment according to the check value;
[0077] According to the first duration, the second duration, the third duration, the fourth duration, the fifth duration and the preset duration, determine the moments corresponding to the starting point and the ending point of the high level segment in each segment of the simulated SENT segment signal.
[0078] Specifically, different segments carry different information in the SENT protocol format, and the duration corresponding to the high-level segment is closely related to the specific content of the target data. The low-level segment mainly plays a segmentation role, generally a fixed number of clock cycles. The high-level segment consists of an initial number of clock cycles and a target number of clock cycles, where the target number corresponding to each segment is determined by the information it carries. Then, the number of clock cycles corresponding to the duration of the high-level segment is the sum of the initial number and the target number.
[0079] Among them, for the first data segment, the second data segment and the third data segment, the corresponding target quantities should be determined respectively according to the characteristics of the target data contained therein and the encoding rules, and then the corresponding durations should be determined respectively.
[0080] The target data often contains relevant information about the current state of the target sensor. The state value can be determined by parsing and judging this information. For example, the target data may contain specific binary digits that are used to identify whether the sensor is in normal working condition, whether there is a fault alarm, etc. For example, 00 represents valid, 01 is a recoverable fault, 10 is a serious fault, and 11 is a reserved bit. Different state values correspond to different target quantities, and then the duration of the corresponding segment can be determined, that is, the fourth duration.
[0081] Common preset check algorithms include parity check, cyclic redundancy check (CRC), etc. Taking the CRC algorithm as an example, the target data is regarded as a coefficient sequence of a polynomial. Through a specific polynomial division operation, this data polynomial is divided by the generating polynomial, and the final remainder is the check value. The generation process of this check value is strictly carried out in accordance with the preset check algorithm rules, and the purpose is to detect whether there is an error in the data during transmission. After the check value is determined, the target number is determined, and then the fifth duration is determined. Different check algorithms and check result representation methods may correspond to different duration requirements.
[0082] After obtaining the duration of each segment included in the SENT segment, such as Figure 3 As shown, the initial time for the entire simulated SENT segment signal to start transmission can be set as time 0, the preset duration is T, the first duration is T1, the second duration is T1, the third duration is T3, the fourth duration is T4, and the fifth duration is T5.
[0083] The state segment starts at time 0, the low level segment of the state segment lasts for T time, the start time t1 of the high level segment of the state segment is time T, and the end time t2 is time (T+T1).
[0084] The low level segment of the first data segment lasts for a duration of T, the start time t1 of the high level segment of the first data segment is (2T+T1), and the end time t2 is (2T+T1+T2). The low level segment of the second data segment lasts for a duration of T, the start time t1 of the high level segment of the second data segment is (3T+T1+T2), and the end time t2 is (3T+T1+T2+T3).
[0085] The low level segment of the third data segment lasts for T time, the starting time t1 of the high level segment of the fourth data segment is (4T+T1+T2+T3), and the ending time t2 is (4T+T1+T2+T3+T4).
[0086] The low level segment of the check segment lasts for T time, the start time t1 of the high level segment of the check segment is (5T+T1+T2+T3+T4), and the end time t2 is (5T+T1+T2+T3+T4+T5).
[0087] The start time t11 of the end frame is (6T+T1+T2+T3+T4+T5).
[0088] That is to say, according to the sequence of each segment, by continuously accumulating the duration and the preset duration, the specific time corresponding to the starting point and the ending point of each high-level segment is gradually determined, thereby constructing a complete simulated SENT segment signal in the time dimension. The precise structure, clearly planning the start and end of each part of the entire simulated SENT segment signal on the time axis, strictly complies with the timing requirements of the SENT protocol format.
[0089] The above implementation scheme of the present application determines the duration of each segment in detail according to the target data, and determines the start and end time of each segment in combination with the preset duration of the separation segment, so that the generated simulated SENT segment signal can accurately match the SENT protocol format corresponding to the target sensor in time. The sensor signal transmission process can be truly simulated in the test environment, allowing the target controller to process the simulated signal in the same way as the real sensor signal is processed in the actual working scenario, thereby improving the effectiveness and accuracy of the test.
[0090] In an optional embodiment of the present application, after determining the target signal identifier corresponding to the low level duration, the method further includes:
[0091] The target signal identifier is sent to the host computer.
[0092] In the specific implementation process, after determining the duration of the low level corresponding to the current trigger instruction and then determining the corresponding target identifier, the target identifier is also sent to the host computer through the CAN transceiver module to facilitate subsequent data preparation.
[0093] It should be noted that when the target sensor's collected data has multiple formats, the target controller generally follows a pattern when requesting the target sensor's collected data. For example, when the electric steering machine's controller requests the torque angle sensor's collected data, it generally requests the torque data and the angle data in sequence.
[0094] Based on this, the single-chip microcomputer can send the target signal identifier corresponding to the current trigger instruction to the host computer, so that the host computer can infer the data format requested by the next target controller, that is, the signal identifier, based on the target signal identifier and the rule of the target controller's request data, and then give priority to sending the data corresponding to the inferred signal identifier to the single-chip microcomputer. For example, if the target signal identifier currently sent represents the torque data of the torque angle sensor, according to the above rule, the host computer can infer that the signal identifier corresponding to the angle data will most likely be requested next time.
[0095] In the above implementation scheme of the present application, the target signal identifier is sent to the host computer through the single-chip microcomputer, so that the host computer can better cooperate with the single-chip microcomputer and the target controller based on the specific situation of the current trigger. Since the host computer infers the data of the next request based on the identifier and sends it first, the time for the single-chip microcomputer to wait for data and the delay for the target controller to obtain data are reduced.
[0096] In an optional embodiment of the present application, before sending the simulated SENT segment signal to the target controller, the method further includes:
[0097] Get the interval between the time when the trigger command is received and the current time;
[0098] When the interval duration reaches a preset duration threshold, a step of sending the simulated SENT segment signal to the target controller is executed.
[0099] In the specific implementation process, when the trigger instruction is received, the time value will be recorded by the internal timing module of the microcontroller. Afterwards, before sending the simulated SENT segment signal, the current time will be obtained again. Then, by calculating the difference between the two times, the interval length can be obtained.
[0100] The preset duration threshold is predetermined according to the format requirements of the SPC signal. Specifically, there is a synchronization segment between the trigger segment and the SENT segment, and the synchronization segment is usually of a fixed duration, so the preset duration threshold is the synchronization segment duration.
[0101] When the calculated interval duration reaches the preset duration threshold, it indicates that the SENT segment signal agreed in the SPC signal format needs to start sending.
[0102] The above implementation scheme of the present application ensures that the target controller receives the simulated SENT segment signal at the appropriate time point by setting a preset duration threshold and determining the timing of sending the SENT signal based on the interval duration, thereby improving the orderliness and accuracy of the signal processing by the target controller.
[0103] The overall implementation process of the embodiment of the present application is introduced below. Figure 4 As shown, the sensor signal simulation device provided by the present application is applied to a test bench, specifically to a single-chip microcomputer in the test bench, so that the single-chip microcomputer can simulate the SENT segment in the SPC signal sent by the target sensor to the target controller. Specifically, the following steps are included:
[0104] Process 1, waiting for trigger: every 2.5us, enter the timer interrupt to read the IP status and obtain the trigger ID. Specifically, configure the IO port of the microcontroller to input mode, read the level status of the IO port according to the timer interrupt triggered every 2.5us, count, and count the low level time of the target controller trigger, thereby calculating the trigger ID value. See Table 1 for the trigger ID and low level time.
[0105] Table 1
[0106]
[0107] Among them, the unit time of 2.5us can be used as a preferred embodiment, and its value is determined according to the clock cycle, machine cycle, instruction cycle of the simulated single-chip microcomputer and controller processor, and the application of the typical communication of mainstream sensors. Finally, the following are satisfied: ① Ensure that the interrupt service function is executed within the unit time; ② Satisfy the error judgment of the trigger time, that is, low level time MAX-low level time MIN> unit time.
[0108] Process 2: The CAN transceiver module receives the data request information. Specifically, the ID value obtained in process 1 is used to match the data to be sent, and the original value of the data to be sent is obtained by obtaining the latest data corresponding to the ID received by the CAN receiving module. The CRC data is calculated based on the original value of the data obtained to complete the data assembly.
[0109] Process 3, data formation: After obtaining the trigger ID, read the CAN message corresponding to the latest ID and calculate the transmitted CRC value to complete the data formation. Specifically, the MCU will receive the CAN message signal and classify it according to the ID received by each channel: torque signal of channel 1, angle signal of channel 1, torque signal of channel 2, angle signal of channel 2, torque signal of channel 3, angle signal of channel 3, torque signal of channel 4, angle signal of channel 4. According to the trigger ID of each channel in process 1, select each channel to use the angle signal or torque signal, and perform CRC calculation according to the CRC calculation principle. After the calculation is completed, the data is formed and sent.
[0110] Process 4: The CAN transceiver module sends data feedback information. Specifically, after the data formation is completed, the ID required by each channel is sent by the microcontroller through the CAN message to facilitate subsequent data preparation.
[0111] Process 5, waiting for sending time: After completing data formation, wait for the waiting time required by the SPC format to send data. Specifically, wait for the required time according to the SPC signal format. In this process, the timer interrupt uses 2.5us time to trigger the calculation time, and jumps to process 6 after reaching the timing threshold.
[0112] Process 6, SENT part sending: After the waiting time is completed, the SENT part is sent. Specifically, according to the format of the SENT protocol, the 2.5us timer interrupt is used to start the SENT phase of the 4 channels respectively. When the counter reaches Figure 3 When the 4 channels have completed sending, they return to process 1 and wait for a new round of ID triggering. Figure 3 The time point for inverting the SENT segment IO is from t1 to t11.
[0113] The implementation steps are as follows:
[0114] 1. Calculate the specific values from t1 to t11 for each ID based on the data to be sent; each channel has an 11-byte array with specific values from t1 to t11.
[0115] 2. For each ID, an 11-byte array is created to record the specific values from t1 to t11.
[0116] 3. When sending to the SENT segment, count each channel separately, and when the counter reaches the tx moment (tx is the moment from t1 to t11), IO is inverted to achieve Figure 3 Effect.
[0117] The sensor signal simulation method provided in the embodiment of the present application is introduced above. The sensor signal simulation device provided in the embodiment of the present application will be introduced below with reference to the accompanying drawings.
[0118] like Figure 5 As shown, an embodiment of the present invention further provides a sensor signal simulation device, which is applied to a single chip microcomputer, the single chip microcomputer is connected to a target controller and a host computer in a test bench, the single chip microcomputer is used to simulate the SENT segment in the SPC signal sent by the target sensor to the target controller, and the device includes:
[0119] The receiving module 501 is used to receive the trigger instruction sent by the target controller in the test bench, and the data to be transmitted sent by the host computer in the test bench through the CAN transceiver module; wherein the data to be transmitted includes data in multiple formats;
[0120] A data selection module 502, configured to select target data from data of multiple formats included in the data to be transmitted according to the trigger instruction;
[0121] A data processing module 503 is used to process the target data based on the SENT protocol format corresponding to the target sensor to obtain a simulated SENT segment signal;
[0122] The first sending module 504 is used to send the simulated SENT segment signal to the target controller.
[0123] Optionally, the receiving module includes:
[0124] A detection module, used for detecting the level signal outputted from the target controller to the single chip microcomputer according to a preset frequency;
[0125] A timing module, used to start timing when detecting that the level signal switches from a high level to a low level, and to end timing when the level signal switches from a low level to a high level, so as to obtain a duration of the low level;
[0126] When the duration of the low level is within a preset duration range, it is determined that the trigger instruction is received.
[0127] Optionally, after determining that the trigger instruction is received, the device further includes:
[0128] A first acquisition module, used to acquire a correspondence between a signal identifier and a duration range;
[0129] A determination module is used to determine a target signal identifier corresponding to the low level duration according to the corresponding relationship.
[0130] Optionally, the data selection module includes:
[0131] A first acquisition submodule, used to acquire a target signal identifier corresponding to the trigger instruction;
[0132] A second acquisition submodule, used to acquire the corresponding relationship between the signal identifier and the data format;
[0133] The first determining submodule is used to determine the target data corresponding to the target signal identifier according to the corresponding relationship.
[0134] Optionally, the simulated SENT segment signal includes a status segment, a first data segment, a second data segment, a third data segment, and a check segment in sequence, and each segment is composed of a low level segment and a high level segment, wherein the low level segment corresponds to a preset duration; based on the SENT protocol format corresponding to the target sensor, the target data is processed to obtain a simulated SENT segment signal, including:
[0135] A second determination submodule is used to determine, according to the target data, a first duration corresponding to the high level segment in the first data segment, a second duration corresponding to the high level segment in the second data segment, and a third duration corresponding to the high level segment in the third data segment;
[0136] A third determining submodule, configured to determine a state value according to the target data, and determine a fourth duration corresponding to a high level segment in the state segment according to the state value;
[0137] a fourth determination submodule, configured to calculate a check value corresponding to the target data by using a preset check algorithm, and determine a fifth duration corresponding to the high level segment in the check segment according to the check value;
[0138] The fifth determination submodule is used to determine the time corresponding to the starting point and the ending point of the high-level segment in each segment of the simulated SENT segment signal according to the first duration, the second duration, the third duration, the fourth duration, the fifth duration and the preset duration.
[0139] Optionally, after determining the target signal identifier corresponding to the low level duration, the method further includes:
[0140] The second sending module is used to send the target signal identifier to the host computer.
[0141] Optionally, before sending the simulated SENT segment signal to the target controller, the device further includes:
[0142] The second acquisition module is used to acquire the interval between the time when the trigger instruction is received and the current time;
[0143] The control module is used to control the first sending module to send the simulated SENT segment signal to the target controller when the interval duration reaches a preset duration threshold.
[0144] The sensor signal simulation device provided by the present application receives the trigger instruction sent by the target controller in the test bench and the data to be transmitted including multiple formats sent by the host computer in the test bench through the CAN transceiver module, and selects the target data from the data in multiple formats included in the data to be transmitted according to the trigger instruction, and screens the data through the trigger instruction, so that the single-chip microcomputer can flexibly adapt to different test requirements, accurately obtain the data related to the current simulation task, and improve the adaptability and pertinence of the entire simulation system, so that the tester can adjust the format of the data to be transmitted through the host computer, so as to adapt to different test scenarios. Based on the SENT protocol format corresponding to the target sensor, the target data is processed to obtain the simulated SENT segment signal, ensuring the high consistency of the simulated signal and the real sensor signal in format and timing, so that the performance of the target controller in the real sensor environment can be more accurately evaluated, and the accuracy and reliability of the test can be improved. By using a single-chip microcomputer to simulate the sensor signal, the problem of not being able to guarantee the accuracy of the signal, not being able to manufacture the waveform of the expected output, and not being able to automatically control the output signal when using a real sensor for testing is avoided. Since no real sensor or SPC simulation board is required, the test cost can also be reduced.
[0145] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0146] An embodiment of the present application also provides an electronic device, including: a processor, a memory, and a computer program stored in the memory and executable on the processor. When the computer program is executed by the processor, each process of the above-mentioned sensor signal simulation method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be described here.
[0147] For example, Figure 6 FIG. 1 shows a schematic diagram of the physical structure of an electronic device. Figure 6As shown, the electronic device may include: a processor (processor) 610, a communication interface (Communications Interface) 620, a memory (memory) 630 and a communication bus 640, wherein the processor 610, the communication interface 620, and the memory 630 complete mutual communication through the communication bus 640. The processor 610 can call the logic instructions in the memory 630, and the processor 610 is used to perform the following steps: receiving the trigger instruction sent by the target controller in the test bench, and the data to be transmitted sent by the host computer in the test bench through the CAN transceiver module; wherein the data to be transmitted includes data in multiple formats; according to the trigger instruction, the target data is selected from the data in multiple formats included in the data to be transmitted; based on the SENT protocol format corresponding to the target sensor, the target data is processed to obtain a simulated SENT segment signal; and the simulated SENT segment signal is sent to the target controller. The processor 610 can also execute other schemes in the embodiments of the present application, which will not be further elaborated here.
[0148] In addition, the logic instructions in the above-mentioned memory 630 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application.
[0149] The embodiment of the present application also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, each process of the above-mentioned sensor signal simulation method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it is not repeated here. The computer-readable storage medium is, for example, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0150] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0151] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in each embodiment of the present application.
[0152] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.
[0153] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed in the present application can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0154] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0155] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0156] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0157] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0158] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as USB flash drives, mobile hard drives, ROM, RAM, magnetic disks, or optical disks.
[0159] The above description is only a specific implementation manner of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application.
Claims
1. A sensor signal simulation method, characterized in that: Applied to a single-chip microcomputer, the single-chip microcomputer is connected to a target controller and a host computer in a test bench, the single-chip microcomputer is used to simulate a SENT segment in an SPC signal sent by a target sensor to the target controller, the method comprising: Receive a trigger instruction sent by a target controller in the test bench, and data to be transmitted sent by a host computer in the test bench through a CAN transceiver module; wherein the data to be transmitted includes data in multiple formats; According to the trigger instruction, select target data from data in multiple formats included in the data to be transmitted; Based on the SENT protocol format corresponding to the target sensor, the target data is processed to obtain a simulated SENT segment signal; The simulated SENT segment signal is sent to the target controller.
2. The sensor signal simulation method according to claim 1, characterized in that: Receive trigger instructions sent by the target controller in the test bench, including: Detecting the level signal outputted from the target controller to the single chip microcomputer according to a preset frequency; When it is detected that the level signal switches from a high level to a low level, timing is started, and when the level signal switches from a low level to a high level, timing is ended to obtain the duration of the low level; When the duration of the low level is within a preset duration range, it is determined that the trigger instruction is received.
3. The sensor signal simulation method according to claim 2, characterized in that: After determining that the trigger instruction is received, the method further includes: Obtaining the correspondence between the signal identifier and the duration range; According to the corresponding relationship, a target signal identifier corresponding to the low level duration is determined.
4. The sensor signal simulation method according to claim 1, characterized in that: According to the trigger instruction, target data is selected from data in multiple formats included in the data to be transmitted, including: Obtaining a target signal identifier corresponding to the trigger instruction; Obtaining the correspondence between signal identifiers and data formats; According to the corresponding relationship, target data corresponding to the target signal identifier is determined.
5. The sensor signal simulation method according to claim 1, characterized in that: The simulated SENT segment signal includes a status segment, a first data segment, a second data segment, a third data segment, and a check segment in sequence, and each segment is composed of a low level segment and a high level segment, wherein the low level segment corresponds to a preset duration; based on the SENT protocol format corresponding to the target sensor, the target data is processed to obtain a simulated SENT segment signal, including: According to the target data, determine a first duration corresponding to the high level segment in the first data segment, a second duration corresponding to the high level segment in the second data segment, and a third duration corresponding to the high level segment in the third data segment; Determine a state value according to the target data, and determine a fourth duration corresponding to a high level segment in the state segment according to the state value; Calculating a check value corresponding to the target data by a preset check algorithm, and determining a fifth duration corresponding to the high level segment in the check segment according to the check value; According to the first duration, the second duration, the third duration, the fourth duration, the fifth duration and the preset duration, determine the moments corresponding to the starting point and the ending point of the high level segment in each segment of the simulated SENT segment signal.
6. The sensor signal simulation method according to claim 3, characterized in that: After determining the target signal identifier corresponding to the low level duration, the method further includes: The target signal identifier is sent to the host computer.
7. The sensor signal simulation method according to claim 1, characterized in that: Before sending the simulated SENT segment signal to the target controller, the method further includes: Get the interval between the time when the trigger command is received and the current time; When the interval duration reaches a preset duration threshold, a step of sending the simulated SENT segment signal to the target controller is executed.
8. A sensor signal simulation device, characterized in that: Applied to a single-chip microcomputer, the single-chip microcomputer is connected to a target controller and a host computer in a test bench, the single-chip microcomputer is used to simulate the SENT segment in the SPC signal sent by the target sensor to the target controller, and the device includes: A receiving module, used to receive a trigger instruction sent by a target controller in a test bench, and data to be transmitted sent by a host computer in the test bench through a CAN transceiver module; wherein the data to be transmitted includes data in multiple formats; A data selection module, used to select target data from data of multiple formats included in the data to be transmitted according to the trigger instruction; A data processing module, used for processing the target data based on the SENT protocol format corresponding to the target sensor to obtain a simulated SENT segment signal; The first sending module is used to send the simulated SENT segment signal to the target controller.
9. An electronic device, characterized in that: The method comprises a processor, a memory and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the sensor signal simulation method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the sensor signal simulation method according to any one of claims 1 to 7 is implemented.