A logic level-based data acquisition method and device
By detecting and correcting the starting position of the logic level data acquisition cycle, the problem of abnormal data caused by acquisition cycle offset was solved, thus achieving the correctness and efficiency of data acquisition.
Patent Information
- Application Number
- CN202211493463.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-25
- Publication Date
- 2025-11-11
- Estimated Expiration
- 2042-11-25
AI Technical Summary
In the existing technology, abnormal data is caused by the acquisition cycle offset during the logic level data acquisition process, which makes the acquisition work cumbersome and reduces the data acquisition efficiency.
By detecting whether an offset occurs during the logic level data acquisition process, and correcting the starting position of the acquisition cycle when an offset is determined, the corrected acquisition cycle is obtained, ensuring that the acquisition cycle is always at the correct position expected by the user.
It ensures the correctness and efficiency of logic level data acquisition, reduces the probability of data loss and abnormal data, and improves the accuracy and efficiency of data acquisition.
Smart Images

Figure CN116248083B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data acquisition technology, and in particular to a data acquisition method and apparatus based on logic levels. Background Technology
[0002] With the continuous development of embedded software and sensor technologies, the number of modules for various logic level transmission data types is rapidly increasing. Under certain conditions (such as frequency differences between communicating parties), the method of acquiring data via logic levels can lead to a shift in the logic level acquisition cycle, resulting in abnormal data after processing. When abnormal data is acquired, current technology can only re-acquire it until normal data is obtained. This undoubtedly makes the acquisition process extremely cumbersome, greatly increasing the workload and reducing efficiency. Summary of the Invention
[0003] To address the problems in the prior art, this application proposes a data acquisition method and apparatus based on logic levels, which can correct for any deviations in the acquisition cycle during the acquisition of logic level data in real time, thereby ensuring the accuracy and efficiency of data acquisition.
[0004] To achieve the above objectives, the technical solution of the present invention is implemented as follows:
[0005] In a first aspect, embodiments of the present invention provide a data acquisition method based on logic levels, the method comprising:
[0006] During the acquisition of logic level data, the acquisition period is checked for any deviation.
[0007] When it is determined that the acquisition period has shifted, the starting position of the acquisition period is corrected to obtain the corrected acquisition period;
[0008] Logical level data is acquired based on the corrected acquisition period.
[0009] In some embodiments, detecting whether the acquisition period has shifted during the acquisition of logic level data includes:
[0010] During the process of acquiring logic level data, it is determined whether the acquired logic level data is correct;
[0011] When the acquired logic level data is incorrect, it is determined that the acquisition period has shifted.
[0012] In some embodiments, detecting whether the acquisition period has shifted during the acquisition of logic level data includes:
[0013] During the acquisition of logic level data, it is determined whether the time of receiving the logic level data meets the preset time range;
[0014] When the time of receiving the logic level data does not meet the preset time range, it is determined that the acquisition period has shifted.
[0015] In some embodiments, the method further includes:
[0016] When it is determined that the acquisition period has deviated, a prompt message is generated to alert the user.
[0017] In some embodiments, the method further includes:
[0018] Obtain the target correction value and the maximum unit correction value;
[0019] When it is determined that the acquisition period has shifted, the starting position of the acquisition period is corrected to obtain a corrected acquisition period, including:
[0020] When it is determined that the acquisition period has shifted, the starting position of the acquisition period is corrected based on the correction target value and the maximum unit correction value to obtain the corrected acquisition period.
[0021] In some embodiments, correcting the starting position of the acquisition period based on the correction target value and the maximum unit correction value to obtain the corrected acquisition period includes:
[0022] S1: Start timing from the preset time and obtain the current accumulated time;
[0023] S2: Determine whether the current cumulative time is less than the maximum unit correction value;
[0024] S3: When the current cumulative time is less than the maximum unit correction value, determine whether the current cumulative time is greater than the correction target value;
[0025] S4: When the current accumulated time is greater than the correction target value, determine whether the current accumulated time has reached the time of one acquisition cycle;
[0026] S5: When the current accumulated time reaches the time of one acquisition cycle, calculate the difference between the current accumulated time and the correction target value to obtain the current moving target value;
[0027] S6: Move the starting position of the acquisition cycle based on the current target value to obtain the current starting position of the acquisition cycle;
[0028] S7: Determine whether the current starting position has reached the position corresponding to the correction target value;
[0029] If the current starting position does not reach the position corresponding to the correction target value, return to S1;
[0030] When the current starting position reaches the position corresponding to the correction target value, the correction of the starting position of the acquisition cycle is completed, and the corrected acquisition cycle is obtained.
[0031] In some embodiments, the step of correcting the starting position of the acquisition period based on the correction target value and the maximum unit correction value to obtain the corrected acquisition period further includes:
[0032] When the current cumulative time is not less than the maximum value of the unit correction, determine whether the current cumulative time has reached the time of one acquisition cycle, and proceed to S5;
[0033] If the current cumulative time is not greater than the correction target value, return to S2;
[0034] If the current cumulative time has not reached the time of one collection cycle, return to S2.
[0035] In some embodiments, the preset time is the time when the logic level changes from low to high; the maximum value of the unit correction is 10% to 20% of the time of one acquisition cycle.
[0036] Secondly, embodiments of the present invention provide a data acquisition device based on logic levels, the device comprising:
[0037] The detection unit is used to detect whether the acquisition period has shifted during the acquisition of logic level data.
[0038] A correction unit is used to correct the starting position of the acquisition period when it is determined that the acquisition period has shifted, so as to obtain a corrected acquisition period.
[0039] The acquisition unit is used to acquire logic level data based on the corrected acquisition period.
[0040] Thirdly, embodiments of the present invention provide a computer-readable storage medium storing program code, which, when executed by a processor, implements the logic level-based data acquisition method as described in any of the above embodiments.
[0041] Fourthly, embodiments of the present invention provide an electronic device, the electronic device including a memory and a processor, the memory storing program code executable on the processor, the program code being executed by the processor to implement the logic level-based data acquisition method as described in any of the above embodiments.
[0042] The data acquisition method and apparatus based on logic level provided in this invention detect whether the acquisition period has shifted during the acquisition of logic level data. When it is determined that the acquisition period has shifted, the starting position of the acquisition period is corrected to obtain a corrected acquisition period. Logic level data is acquired based on the corrected acquisition period. This allows for real-time correction of the shifted acquisition period during the acquisition of logic level data, ensuring that the starting position of the acquisition period is always at the correct position expected by the user, thereby guaranteeing the correctness and efficiency of data acquisition. Attached Figure Description
[0043] The scope of this invention can be better understood by reading the following detailed description of exemplary embodiments in conjunction with the accompanying drawings. The accompanying drawings are:
[0044] Figure 1A This is a schematic diagram of data acquisition under ideal conditions;
[0045] Figure 1B This is a schematic diagram of data acquisition under the condition of acquisition period offset;
[0046] Figure 1C This is a schematic diagram of data acquisition after the acquisition period has been corrected.
[0047] Figure 2 This is a flowchart of a method according to an embodiment of the present invention;
[0048] Figure 3 The method flow of this invention embodiment Figure 2 ;
[0049] Figure 4 This is a flowchart of the method for correcting the acquisition period in an embodiment of the present invention;
[0050] Figure 5 The following is a method flow for correcting the acquisition period in an embodiment of the present invention. Figure 2 ;
[0051] Figure 6 This is a schematic diagram illustrating the acquisition period correction method provided in the embodiments of the present invention;
[0052] Figure 7 This is a structural diagram of the device according to an embodiment of the present invention. Detailed Implementation
[0053] To make the objectives, technical solutions, and advantages of the present invention clearer, the implementation method of the present invention will be described in detail below with reference to the accompanying drawings and embodiments, so that the process of how the present invention uses technical means to solve technical problems and achieve technical effects can be fully understood and implemented accordingly.
[0054] Many specific details are set forth in the following description in order to provide a full understanding of the invention. However, the invention may also be practiced in other ways different from those described herein, and therefore the scope of protection of the invention is not limited to the specific embodiments disclosed below.
[0055] Example 1
[0056] Some sensors or modules that acquire data based on logic levels may experience a loss of level judgment during reception, resulting in abnormal data acquisition. For example... Figure 1A and Figure 1B As shown, when the data acquisition cycle is offset, the sampled data obtained after processing the logic level data is incorrect. Specifically, Figure 1B This is just an example; the actual degree of offset is uncertain and may be very small or very large.
[0057] To address this technical problem, this invention proposes a data acquisition method. This method can correct logic level data and perform further correction when data anomalies occur, ensuring the acquired data is normal. This method can correct the start position of the acquisition cycle to the user-expected target position based on user expectations, such as... Figure 1C As shown. Among them, Figure 1C This is merely an example of the corrected state. The method provided by this invention can correct the starting position of the acquisition cycle to the position desired by the user, and of course, it can also correct it to... Figure 1A The position of the ideal state shown.
[0058] Based on the above ideas, embodiments of the present invention provide a data acquisition method based on logic levels, such as... Figure 2 As shown, the logic level data acquisition method described in this embodiment includes steps S101, S102, and S103. The specific contents of these steps are described in detail below:
[0059] Step S101: During the acquisition of logic level data, detect whether the acquisition period has shifted.
[0060] To detect whether the acquisition period has shifted in a timely, accurate, and effective manner, embodiments of the present invention can employ the following two detection methods:
[0061] The first method involves determining whether the acquired logic level data is correct during the acquisition process; if the acquired logic level data is incorrect, it is determined that the acquisition period has shifted; if the acquired logic level data is correct, it is determined that the acquisition period has not shifted.
[0062] The second method involves determining whether the time of receiving the logic level data meets a preset time range during the acquisition process; if the time of receiving the logic level data does not meet the preset time range, it is determined that the acquisition period has shifted; if the time of receiving the logic level data meets the preset time range, it is determined that the acquisition period has not shifted.
[0063] Specifically, for the first method mentioned above, the collected logic level data can be processed into the required collected data. The correctness of the collected logic level data is determined by checking the correctness of the required collected data, thereby determining whether the collection period has shifted. In some application scenarios (such as infrared dust sensors), the required collected data can be obtained by calculating the proportion of low levels per unit time. For example, if the collection period T is 1 second, and the system counts once every 1 second, for a total of 1000 times, each time the system detects a low level, it accumulates an increment X. X / T is the proportion, and the actual collected data can be calculated using the following formula: X*(X / T). For example, if a fixed value is simulated using a fixture, when the actual collected data deviates from this fixed value, it indicates that the collected data is abnormal, and thus indicates that the collection period has shifted.
[0064] In the second method described above, in practical applications, the system can determine in real time whether the communication cycles of the data sender and receiver match. If they do not match, it indicates that the acquisition cycle has shifted. For example, if the communication cycle between the two parties is 1 second, the data sender (such as a sensor) sends data, and the data receiver (such as a main controller) starts acquiring data. If the main controller's cycle has not yet reached the agreed 1 second or has exceeded 1 second before receiving the next data packet signal from the sensor, it indicates that the acquisition cycle has shifted.
[0065] Step S102: When it is determined that the acquisition period has shifted, the starting position of the acquisition period is corrected to obtain the corrected acquisition period;
[0066] In order to provide timely and effective reminders to users, the method described in this embodiment further includes: when it is determined that the collection period has shifted, generating a prompt message to remind the user that the collection period has shifted.
[0067] In order to correct the offset acquisition period based on user expectations, the method described in this embodiment further includes: obtaining a correction target value and a maximum unit correction value; under this premise, when it is determined that the acquisition period has offset, the method described in this embodiment corrects the starting position of the acquisition period to obtain the corrected acquisition period, including: when it is determined that the acquisition period has offset, correcting the starting position of the acquisition period based on the correction target value and the maximum unit correction value to obtain the corrected acquisition period.
[0068] In this embodiment, the user can set the aforementioned target correction value and maximum unit correction value. The system obtains the target correction value and maximum unit correction value by receiving the user's settings for these parameters. In practical applications, the target correction value and maximum unit correction value can also be pre-set fixed parameters. This embodiment does not specifically limit the method of obtaining the target correction value and maximum unit correction value.
[0069] It should be noted that when the user does not set a calibration target value, the system will default to calibrating the start position of the acquisition cycle to, for example, . Figure 1A The image shows the ideal, offset-free position. The system can also preset a default maximum unit correction value. When the user does not set a correction target value or a maximum unit correction value, the system uses these default values to correct the starting position of the acquisition cycle.
[0070] In this embodiment, the correction target value refers to the position of the starting position of the user's desired acquisition period, i.e., the specific numerical unit of offset required. This can be set according to the user's actual needs. If the correction target value is set to 0, then the correction will be to... Figure 1A The position shown is without offset. Taking a certain dust sensor as an example, 1ms is the reference time for timing, and 1000ms is the time of one acquisition cycle. Then, the user can set the value of the calibration target value to 100.
[0071] In this embodiment, the maximum unit correction value refers to the maximum offset of a single correction per unit time. This setting can prevent correction errors and improve correction accuracy.
[0072] To accurately and effectively correct the starting position of the acquisition period, this embodiment describes correcting the starting position of the acquisition period based on the correction target value and the maximum unit correction value to obtain the corrected acquisition period. This includes sequentially executing the following steps: Figure 4 As shown:
[0073] S1: Start timing from the preset time and obtain the current accumulated time;
[0074] S2: Determine whether the current cumulative time is less than the maximum unit correction value;
[0075] S3: When the current cumulative time is less than the maximum unit correction value, determine whether the current cumulative time is greater than the correction target value;
[0076] S4: When the current accumulated time is greater than the correction target value, determine whether the current accumulated time has reached the time of one acquisition cycle;
[0077] S5: When the current accumulated time reaches the time of one acquisition cycle, calculate the difference between the current accumulated time and the correction target value to obtain the current moving target value;
[0078] S6: Move the starting position of the acquisition cycle based on the current target value to obtain the current starting position of the acquisition cycle;
[0079] S7: Determine whether the current starting position has reached the position corresponding to the correction target value;
[0080] If the current starting position does not reach the position corresponding to the correction target value, return to S1;
[0081] When the current starting position reaches the position corresponding to the correction target value, the correction of the starting position of the acquisition cycle is completed, and the corrected acquisition cycle is obtained.
[0082] To further accurately and effectively correct the starting position of the acquisition cycle, this embodiment corrects the starting position of the acquisition cycle based on the correction target value and the maximum unit correction value to obtain the corrected acquisition cycle. The method further includes: when the current accumulated time is not less than the maximum unit correction value, determining whether the current accumulated time has reached the time of one acquisition cycle, and proceeding to S5; when the current accumulated time is not greater than the correction target value, returning to S2; when the current accumulated time has not reached the time of one acquisition cycle, returning to S2, and so on. Figure 5 As shown.
[0083] In this embodiment, when the current accumulated time is not less than the maximum unit correction value, it is first determined whether the current accumulated time has reached the time of one acquisition cycle, and then the process proceeds to S5 to perform the corresponding operation, and continues to execute the steps after S5; when the current accumulated time is not greater than the correction target value, the process returns to step S2 to re-determine whether the current accumulated time is less than the maximum unit correction value, and then executes the steps after S2 in sequence; when the current accumulated time has not reached the time of one acquisition cycle, the process returns to step S2 to re-determine whether the current accumulated time is less than the maximum unit correction value, and then executes the steps after S2 in sequence until the current starting position of the acquisition cycle reaches the position corresponding to the correction target value, thus completing the correction of the starting position of the acquisition cycle.
[0084] To facilitate accurate timing, in this embodiment, the preset time is the moment when the logic level changes from low to high. In practical applications, the preset time can be set according to the actual situation of both communicating parties.
[0085] To further improve the accuracy of the correction of the starting position of the acquisition cycle, in this embodiment, the maximum value of the unit correction is 10% to 20% of the time of one acquisition cycle.
[0086] Specifically, in step S2 above, the maximum unit correction value is the maximum allowed accumulation value of the current accumulated time to meet precise control. In step S4 above, since the current accumulated time is reset to zero and re-accumulated when it reaches one acquisition cycle, subsequent cycle offset operations are performed when the current accumulated time reaches one acquisition cycle. For example, if the current accumulated time accumulates to 1000 as one unit cycle, when T>1000, T=0, and accumulation continues.
[0087] exist Figure 5 In this context, T = CA means that when a data acquisition cycle is completed, the current accumulated time should be reset to zero. At this point, T = CA increases the initial value of the acquisition cycle, causing this cycle to be shorter than a normal unit cycle by CA. The next cycle then moves forward by CA. The starting position of the acquisition cycle keeps moving forward until it reaches a point between the correction target value and the maximum unit correction value. The next move will then coincide with the position of the correction target value, completing the correction. For example, if the correction target value A = 100 and the maximum unit correction value B = 200, and the starting position of the acquisition cycle moves to between A and B at a certain moment, say at 125, when the current accumulated time reaches 1000, T = CA = 125 - 100 = 25. This cycle will be shorter by 25 ms, and the starting position of the next cycle will be earlier by 25 ms, coinciding with the position corresponding to the correction target value, completing the correction.
[0088] In this embodiment, the acquisition cycle can only be corrected when the current accumulated time reaches the time of one acquisition cycle and the next cycle is about to begin; otherwise, the acquisition cycle cannot be corrected.
[0089] Step S103: Acquire logic level data based on the corrected acquisition period.
[0090] In this embodiment, the logic level data acquired based on the corrected acquisition period are all the correct logic level data expected by the user, and after processing, the corresponding correct acquisition data can be obtained.
[0091] The flowchart of the data acquisition method described in this embodiment in practical application is as follows: Figure 3 As shown, taking sensor data acquisition as an example, the main control MCU and sensor are first initialized, with the sensor acting as the data sender and the main control MCU as the data receiver. Then, the MCU acquires the sensor's logic level data and performs corresponding acquisition processing operations. When the MCU detects that the sensor's I / O port level is low, it starts accumulating a timer, calculating the proportion of low levels per unit time, and determining the actual acquired data based on this proportion. After obtaining the actual acquired data, it checks whether the acquisition period has shifted. If a shift is detected, the correction algorithm provided in this embodiment corrects the starting position of the acquisition period; if no shift is detected, it continues to acquire logic level data normally, and obtains the actual acquired data based on the acquired logic level data, thus completing the processing of the actual acquired data.
[0092] The periodic calibration method provided in this embodiment will be further described in detail below using a dust sensor as an example:
[0093] The sensor acquires data in a one-second cycle. When the I / O signal is low, a value is recorded every 1ms, and the average value is calculated every three seconds as the current sensor value. For example, if the current value is 300, the I / O signal is low for 300ms within one second.
[0094] Figure 1A Ideally, sampling should be performed per unit period; however, various complex factors can cause period offsets, resulting in incorrectly processed values. Figure 1B As shown. Based on this, calibration is needed to ensure that the sensor's low-level data is completely included within the sampling period (some extreme data may have some error; for example, if the set value is 10 and the sensor value is greater than 990, an error will occur, but this value is unusual and unlikely to occur). The calibrated period is as follows. Figure 1C As shown.
[0095] Figure 3 The overall process of sensor sampling and processing is supplemented with a correction algorithm.
[0096] Figure 5 It is a flowchart for implementing a specific calibration method.
[0097] Figure 6 It is a specific level processing analysis, and the process corresponds to Figure 5 . When the level changes from low to high, C starts to accumulate. When the current accumulated time reaches the time of one acquisition cycle and C meets the condition (A < C < B: greater than the calibration target value and less than the unit calibration maximum value), T = C - A. In the next cycle, C - A will be reduced, and the starting position of the cycle will move forward by C - A. When the starting position of the cycle coincides with the set position, the calibration is completed.
[0098] Similarly, this processing method is not limited to detecting low levels and can be adjusted according to actual needs to lock the required cycle, complete the sampling calibration, and determine the correct value of the acquired data.
[0099] This method focuses on processing logic level data, can lock the unit cycle, and ensures the correctness of the sampled data.
[0100] At the same time, this method is not limited to sensors and can be applied to any logic level communication, ensuring the correctness of the interactive data. The key of this method is to process the transmitted level data to improve the accuracy of the acquired data.
[0101] The data acquisition method based on logic level provided by the embodiment of the present invention detects whether the acquisition cycle drifts during the process of acquiring logic level data. When it is determined that the acquisition cycle drifts, the starting position of the acquisition cycle is calibrated to obtain the calibrated acquisition cycle, and the logic level data is acquired based on the calibrated acquisition cycle, so that during the process of acquiring logic level data, the drifted acquisition cycle can be corrected in real time, and then the starting position of the acquisition cycle is always at the correct position expected by the user, thereby ensuring the correctness and efficiency of data acquisition.
[0102] Example 2
[0103] Corresponding to the above method embodiment, the present invention also provides a data acquisition device based on logic level, as Figure 7 shown. The device described in this embodiment includes:
[0104] A detection unit 201, configured to detect whether the acquisition cycle drifts during the process of acquiring logic level data;
[0105] A calibration unit 202, configured to calibrate the starting position of the acquisition cycle to obtain the calibrated acquisition cycle when it is determined that the acquisition cycle drifts;
[0106] Acquisition unit 203 is used to acquire logic level data based on the corrected acquisition period.
[0107] In this embodiment, the detection unit 201 detects whether the acquisition period has shifted in the following manner:
[0108] During the process of acquiring logic level data, it is determined whether the acquired logic level data is correct;
[0109] When the acquired logic level data is incorrect, it is determined that the acquisition period has shifted.
[0110] In this embodiment, the detection unit 201 detects whether the acquisition period has shifted in the following manner:
[0111] During the acquisition of logic level data, it is determined whether the time of receiving the logic level data meets the preset time range;
[0112] When the time of receiving the logic level data does not meet the preset time range, it is determined that the acquisition period has shifted.
[0113] Furthermore, the apparatus described in this embodiment also includes:
[0114] The prompting unit is used to generate prompting information for the user when it is determined that the acquisition period has shifted.
[0115] Furthermore, the apparatus described in this embodiment also includes:
[0116] The acquisition unit is used to acquire the target correction value and the maximum unit correction value.
[0117] The correction unit 202 is further configured to, when it is determined that the acquisition period has shifted, correct the starting position of the acquisition period based on the correction target value and the maximum unit correction value, so as to obtain the corrected acquisition period.
[0118] In this embodiment, the correction unit 202 corrects the starting position of the acquisition period in the following manner to obtain the corrected acquisition period:
[0119] S1: Start timing from the preset time and obtain the current accumulated time;
[0120] S2: Determine whether the current cumulative time is less than the maximum unit correction value;
[0121] S3: When the current cumulative time is less than the maximum unit correction value, determine whether the current cumulative time is greater than the correction target value;
[0122] S4: When the current accumulated time is greater than the correction target value, determine whether the current accumulated time has reached the time of one acquisition cycle;
[0123] S5: When the current accumulated time reaches the time of one acquisition cycle, calculate the difference between the current accumulated time and the correction target value to obtain the current moving target value;
[0124] S6: Move the starting position of the acquisition cycle based on the current target value to obtain the current starting position of the acquisition cycle;
[0125] S7: Determine whether the current starting position has reached the position corresponding to the correction target value;
[0126] If the current starting position does not reach the position corresponding to the correction target value, return to S1;
[0127] When the current starting position reaches the position corresponding to the correction target value, the correction of the starting position of the acquisition cycle is completed, and the corrected acquisition cycle is obtained.
[0128] Furthermore, in this embodiment, the correction unit 202 also corrects the starting position of the acquisition period in the following manner to obtain the corrected acquisition period:
[0129] When the current cumulative time is not less than the maximum value of the unit correction, determine whether the current cumulative time has reached the time of one acquisition cycle, and proceed to S5;
[0130] If the current cumulative time is not greater than the correction target value, return to S2;
[0131] If the current cumulative time has not reached the time of one collection cycle, return to S2.
[0132] In this embodiment, the preset time is the time when the logic level changes from low to high; the maximum value of the unit correction is 10% to 20% of the time of one acquisition cycle.
[0133] For details regarding the working principle, workflow, and specific implementation methods of the aforementioned device, please refer to the specific implementation methods of the logic level-based data acquisition method provided by this invention. The same technical content will not be described in detail here.
[0134] The logic level-based data acquisition device provided in this embodiment of the invention detects whether the acquisition period has shifted during the acquisition of logic level data. When it is determined that the acquisition period has shifted, the starting position of the acquisition period is corrected to obtain a corrected acquisition period. Logic level data is then acquired based on the corrected acquisition period. This allows for real-time correction of the shifted acquisition period during the acquisition of logic level data, ensuring that the starting position of the acquisition period is always at the correct position expected by the user, thereby guaranteeing the accuracy and efficiency of data acquisition.
[0135] Example 3
[0136] According to an embodiment of the present invention, a computer-readable storage medium is also provided, wherein program code is stored on the computer-readable storage medium, and when the program code is executed by a processor, it implements the logic level-based data acquisition method as described in any of the above embodiments.
[0137] Example 4
[0138] According to an embodiment of the present invention, an electronic device is also provided, the electronic device including a memory and a processor, the memory storing program code executable on the processor, the program code being executed by the processor to implement the logic level-based data acquisition method as described in any of the above embodiments.
[0139] The data acquisition method, apparatus, storage medium, and electronic device based on logic level provided in this invention detect whether the acquisition period has shifted during the acquisition of logic level data. When it is determined that the acquisition period has shifted, the starting position of the acquisition period is corrected to obtain a corrected acquisition period. Logic level data is acquired based on the corrected acquisition period. This allows for real-time correction of the shifted acquisition period during the acquisition of logic level data, ensuring that the starting position of the acquisition period is always at the correct position expected by the user, thereby guaranteeing the correctness and efficiency of data acquisition.
[0140] The technical solution provided in this invention can lock the sampling period, effectively reducing data loss. Furthermore, it performs recalibration when data is abnormal to ensure data integrity, thus significantly reducing the probability of obtaining abnormal data. This method is applicable to logic level data processing, such as communication between two modules.
[0141] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed.
[0142] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of the embodiments of the present invention, depending on actual needs.
[0143] Furthermore, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0144] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause an electronic device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0145] While the embodiments disclosed in this invention are as described above, the content is merely for the purpose of facilitating understanding of the invention and is not intended to limit the invention. Any person skilled in the art to which this invention pertains may make any modifications and changes in form and detail of the implementation without departing from the spirit and scope disclosed herein; however, the scope of protection of this invention shall still be determined by the scope defined in the appended claims.
Claims
1. A data acquisition method based on logic levels, characterized in that, The method includes: During the acquisition of logic level data, the acquisition period is checked for any deviation. When it is determined that the acquisition period has shifted, a correction target value and a unit correction maximum value are obtained. Based on the correction target value and the unit correction maximum value, the starting position of the acquisition period is corrected to obtain the corrected acquisition period. The correction target value is the position of the starting position of the acquisition period that the user expects. The unit correction maximum value is the maximum shift caused by one correction per unit time. Logic level data is acquired based on the corrected acquisition period; The step of correcting the starting position of the acquisition period based on the correction target value and the maximum unit correction value to obtain the corrected acquisition period includes: S1: Start timing from the preset time and obtain the current accumulated time; S2: Determine whether the current cumulative time is less than the maximum unit correction value; S3: When the current cumulative time is less than the maximum unit correction value, determine whether the current cumulative time is greater than the correction target value; S4: When the current accumulated time is greater than the correction target value, determine whether the current accumulated time has reached the time of one acquisition cycle; S5: When the current accumulated time reaches the time of one acquisition cycle, calculate the difference between the current accumulated time and the correction target value to obtain the current moving target value; S6: Move the starting position of the acquisition cycle based on the current target value to obtain the current starting position of the acquisition cycle; S7: Determine whether the current starting position has reached the position corresponding to the correction target value; If the current starting position does not reach the position corresponding to the correction target value, return to S1; When the current starting position reaches the position corresponding to the correction target value, the correction of the starting position of the acquisition cycle is completed, and the corrected acquisition cycle is obtained.
2. The data acquisition method based on logic levels according to claim 1, characterized in that, The process of detecting whether the acquisition period has shifted during the acquisition of logic level data includes: During the process of acquiring logic level data, it is determined whether the acquired logic level data is correct; When the acquired logic level data is incorrect, it is determined that the acquisition period has shifted.
3. The data acquisition method based on logic levels according to claim 1, characterized in that, The process of detecting whether the acquisition period has shifted during the acquisition of logic level data includes: During the acquisition of logic level data, it is determined whether the time of receiving the logic level data meets the preset time range; When the time of receiving the logic level data does not meet the preset time range, it is determined that the acquisition period has shifted.
4. The data acquisition method based on logic levels according to claim 1, characterized in that, The method further includes: When it is determined that the acquisition period has deviated, a prompt message is generated to alert the user.
5. The data acquisition method based on logic levels according to claim 1, characterized in that, The step of correcting the starting position of the acquisition period based on the correction target value and the maximum unit correction value to obtain the corrected acquisition period further includes: When the current cumulative time is not less than the maximum value of the unit correction, determine whether the current cumulative time has reached the time of one acquisition cycle, and proceed to S5; If the current cumulative time is not greater than the correction target value, return to S2; If the current cumulative time has not reached the time of one collection cycle, return to S2.
6. The data acquisition method based on logic levels according to claim 4, characterized in that, The preset time is the time when the logic level changes from low to high; the maximum value of the unit correction is 10% to 20% of the time of one acquisition cycle.
7. A data acquisition device based on logic levels, characterized in that, The device includes: The detection unit is used to detect whether the acquisition period has shifted during the acquisition of logic level data. The correction unit is used to obtain a correction target value and a unit correction maximum value when it is determined that the acquisition period has shifted, and to correct the starting position of the acquisition period based on the correction target value and the unit correction maximum value to obtain the corrected acquisition period. The correction target value is the position of the starting position of the acquisition period that the user expects; the unit correction maximum value is the maximum shift of one correction per unit time. The acquisition unit is used to acquire logic level data based on the corrected acquisition period; The step of correcting the starting position of the acquisition period based on the correction target value and the maximum unit correction value to obtain the corrected acquisition period includes: S1: Start timing from the preset time and obtain the current accumulated time; S2: Determine whether the current cumulative time is less than the maximum unit correction value; S3: When the current cumulative time is less than the maximum unit correction value, determine whether the current cumulative time is greater than the correction target value; S4: When the current accumulated time is greater than the correction target value, determine whether the current accumulated time has reached the time of one acquisition cycle; S5: When the current accumulated time reaches the time of one acquisition cycle, calculate the difference between the current accumulated time and the correction target value to obtain the current moving target value; S6: Move the starting position of the acquisition cycle based on the current target value to obtain the current starting position of the acquisition cycle; S7: Determine whether the current starting position has reached the position corresponding to the correction target value; If the current starting position does not reach the position corresponding to the correction target value, return to S1; When the current starting position reaches the position corresponding to the correction target value, the correction of the starting position of the acquisition cycle is completed, and the corrected acquisition cycle is obtained.
8. A computer-readable storage medium storing program code thereon, characterized in that, When the program code is executed by the processor, it implements the data acquisition method based on logic levels as described in any one of claims 1 to 6.
9. An electronic device, characterized in that, The electronic device includes a memory and a processor. The memory stores program code that can run on the processor. When the program code is executed by the processor, it implements the logic level-based data acquisition method as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Calibration circuit and method thereof for data recovery
US20100296378A1
Time-to-digital converter and time measurement method
WO2018113625A1