Sensor data filtering method

By adopting the window mean filtering method of dual output mode in the sensor system, combining short-term, long-term and ultra-long-term filtering, the problems of noise interference and data changes in the sensor system are solved, and the stability and accuracy of the output data are achieved.

CN120263181APending Publication Date: 2025-07-04PINGJIE ELECTRONIC TECHNOLOGY (JIANGSU) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510354093.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-25
Publication Date
2025-07-04

AI Technical Summary

Technical Problem

The instantaneous drastic changes caused by changes in external noise signals and input data in the sensor system affect the stability and security of the system. The conventional mean filtering algorithm responds too slowly, resulting in information loss.

Method used

The window mean filtering method of dual output mode is adopted. By combining short-time, long-time and ultra-long-time filtering, the input data changes are monitored, and the short-time filtering result or the system's last output is output in stable mode. The IIR filtering result is output in changing mode to ensure the stability and accuracy of the output data.

Benefits of technology

Effectively reduce external noise interference, monitor the slow changes in input data, and retain data mutations, avoid data trend attenuation caused by conventional mean filtering, and improve the stability and accuracy of output data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120263181A_ABST
    Figure CN120263181A_ABST
Patent Text Reader

Abstract

The invention discloses a sensor data filtering method. The method comprises a data sampling stage; carrying out primary sampling on data output by an analog-to-digital converter in the sensor system, and storing the sampled data to a corresponding variable Cv; a monitoring variable calculation stage; calculating filtering results of short-time filtering, long-time filtering, super-long-time filtering and IIR filtering, and calculating filtering variations of the short-time filtering, the long-time filtering and the super-long-time filtering; a mode judgment stage; the filtering variable quantity obtained through calculation in the monitoring variable calculation stage is compared with a preset value to judge whether the sensor system enters a stable mode or a change mode; a data output stage; and in the stable mode and the change mode, outputting different filtering results respectively, and storing the output data to a variable Lv. The method can effectively reduce the interference of noise, monitors the slow change of the input data, and avoids the defect that the data trend is attenuated by times by conventional mean filtering.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of data processing, and particularly to a method for filtering sensor data. Background Art

[0002] Currently, in various sensor systems, the system converts various physical signals into discrete digital signals through an analog-to-digital converter. However, both the noise signals in the external environment and the changes in the input data of the sensor system itself may cause instantaneous and drastic changes in the output data of the system.

[0003] In some applications, the drastic jitter of the system output data may affect the stability and safety of the system itself or other related devices. It is a common means for technicians to reduce the interference of noise signals through digital filtering algorithms to make the system output data smoother. Algorithms such as mean filtering and low-pass filtering, etc.; but when the input data undergoes a large mutation, the common mean filtering algorithm will make the system response become too slow, thus causing the system to lose the information that should have been captured. Summary of the Invention

[0004] The technical problem to be solved by the present invention is: Currently, in various sensor systems, the instantaneous and drastic changes in the output data of the system caused by the noise signals in the external environment and the changes in the input data of the sensor system itself will affect the stability and safety of the sensor system itself or other related devices.

[0005] To solve the above technical problem, the present invention proposes a window mean filtering method with a dual-output mode, which can effectively reduce the interference of external environmental noise signals, monitor the slow changes in the input data, and at the same time can retain the situation where the input data undergoes mutations, avoiding the disadvantage of the conventional mean filtering that exponentially attenuates the data trend.

[0006] The technical solution adopted is as follows: A method for filtering sensor data, comprising: a sampling data stage; for performing a first sampling on the data output by the analog-to-digital converter in the sensor system, and saving the sampled data to a corresponding variable Cv; a monitoring variable calculation stage; according to the data sampled in the sampling data stage, first calculating the filtering results of short-term filtering, long-term filtering, ultra-long-term filtering, and IIR filtering respectively, and then calculating the filtering change amounts of short-term filtering, long-term filtering, and ultra-long-term filtering respectively; a mode determination stage; comparing the filtering change amounts calculated in the monitoring variable calculation stage with a preset value to determine whether the sensor system enters a stable mode or a changing mode; an output data stage; the sensor system outputs the short-term filtering result or the filtering result output by the system last time in the stable mode, and outputs the IIR filtering result in the changing mode, and saves the output data to a variable Lv.

[0007] The method of the present invention samples the input data by using window mean filtering with three different lengths: short-time filtering, long-time filtering, and ultra-long-time filtering, and monitors the change of the input data through four stages: sampled data, monitoring variable calculation, mode judgment, and output data, and outputs the finally less fluctuating data, which can ensure the stability and accuracy of the output data.

[0008] For further optimization of the technical solution of the present invention, the filtering result of the IIR filtering is Rv; the window length of the short-time filtering is SN, the filtering result of the short-time filtering is Sv, and the previous filtering result of the short-time filtering is S V-1 , and the relationship between them is: Sv = S V-1 + (Cv - S V-1 ) / SN. By performing short-time filtering on the input data to obtain the filtering result for a short time, it is possible to determine the fluctuation and accuracy of the filtering result under short-time filtering.

[0009] For further optimization of the technical solution of the present invention, the window length of the long-time filtering is AN, the filtering result of the long-time filtering is Av, and the previous filtering result of the long-time filtering is A V-1 , and the relationship between them is: Av = A V-1 + (Cv - A V-1 ) / AN. By performing long-time filtering on the input data to obtain the filtering result for a long time, it is possible to determine the fluctuation of the filtering result under long-time filtering.

[0010] For further optimization of the technical solution of the present invention, the window length of the ultra-long-time filtering is LAN, the filtering result of the ultra-long-time filtering is LAv, and the previous filtering result of the ultra-long-time filtering is LA V-1 , and the relationship between them is: LAv = LA V-1 + (Cv - LA V-1 ) / LAN. By performing ultra-long-time filtering on the input data to obtain the filtering result for a long time, it is possible to determine the fluctuation of the filtering result under ultra-long-time filtering.

[0011] For further optimization of the technical solution of the present invention, the window lengths of the short-time filtering, long-time filtering, and ultra-long-time filtering of the three window mean filterings increase in sequence, and the relationship is: SN < AN < LAN. By sampling the input data by using three window mean filterings with different lengths, it is used to ensure the stability and accuracy of the system output data.

[0012] For further optimization of the technical solution of the present invention, the short-term change amount of short-term filtering is ΔKv = abs(Lv - Cv); the long-term change amount of long-term filtering is ΔDv = abs(Av - Cv); the ultra-long-term change amount of ultra-long-term filtering is ΔLKv = abs(LAv - Sv), where abs represents the absolute value symbol. By calculating the corresponding change amounts of the three filtering results, the interference of the noise signal on the three filtering results can be further reflected, so as to determine the accurate data output by the system.

[0013] For further optimization of the technical solution of the present invention, the initial state of the sensor system is the stable mode, and the long-term change amount ΔDv is selected as the basis for judging whether the sensor system maintains stability. By selecting the long-term change amount ΔDv as the monitoring object, it is possible to more accurately determine whether the sensor system switches to the stable mode or the change mode.

[0014] For further optimization of the technical solution of the present invention, in the mode judgment stage, when the sensor system is in the stable mode, by judging whether the long-term change amount ΔDv is greater than the preset value limit1 and whether the value of the counter COUNT1 is greater than the expected number C1, it is determined whether the sensor system maintains the stable mode or switches to the change mode; when the sensor system is in the change mode, by judging whether the long-term change amount ΔDv is less than the preset value limit2 and whether the value of the counter COUNT1 is greater than the expected number C2, it is determined whether the sensor system maintains the change mode or switches to the stable mode. By the mode judgment stage to judge whether the sensor system switches modes, so as to output data results with less fluctuation subsequently.

[0015] For further optimization of the technical solution of the present invention, in the output data stage, if the sensor system outputs in the stable mode, the filtering result Sv of the short-term filtering is updated to the temporary variable OUT, and then the value of the temporary variable OUT is passed to the variable Lv for output, or the variable Lv output by the sensor system last time is updated to the temporary variable OUT for output; if the sensor system outputs in the change mode, the filtering result Rv of the IIR filtering is updated to the temporary variable OUT, and then the value of the temporary variable OUT is passed to the variable Lv for output. By making corresponding judgments on the short-term change amount ΔKv, the short-term filtering result Sv, the IIR filtering result Rv or the last output value of the system is selected for output, reducing the fluctuation of the output data and improving the accuracy of the output data.

[0016] The beneficial effects of the present invention compared with the prior art: The method of the present invention samples the input data by using window mean filtering with three different lengths, namely short-term filtering, long-term filtering, and ultra-long-term filtering, and monitors the change of the input data through four stages: sampled data, monitored variable calculation, mode judgment, and output data, and outputs the finally less fluctuating data, which can ensure the stability and accuracy of the output data; the method of the present invention can effectively reduce the interference of external environmental noise signals, can monitor the slow change of the input data, and can also retain the situation where the input data undergoes sudden changes, avoiding the disadvantage that the conventional mean filtering exponentially attenuates the data trend. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] Figure 1 is a schematic flowchart of a sensor data filtering method; Figure 2 is a schematic diagram of variables of a sensor data filtering method; Figure 3 is a flowchart of the mode judgment and output data stages of a sensor data filtering method. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0018] In order to make the objectives, technical solutions and advantages of the present invention clearer and more understandable, the present invention will be further described in detail below with reference to the Figures 1-3 drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention. In addition, the technical features involved in the various embodiments of the present invention described below can be combined with each other as long as they do not conflict with each other. Embodiment 1

[0019] As Figure 1 shown, it is a schematic flowchart of a sensor data filtering method, which includes four stages: sampled data, monitored variable calculation, mode judgment, and output data, where: Sampled data stage; used to perform a first sampling on the data output by the analog-to-digital converter in the sensor system, and save the sampled data to the corresponding variable Cv.

[0020] Monitored variable calculation stage; according to the data sampled in the sampled data stage, first calculate the filtering results of short-term filtering, long-term filtering, ultra-long-term filtering, and IIR filtering respectively, and then calculate the filtering change amounts of short-term filtering, long-term filtering, and ultra-long-term filtering respectively.

[0021] Mode judgment stage; compare the filtering change amount calculated in the monitored variable calculation stage with a preset value to judge whether the sensor system enters the stable mode or the change mode.

[0022] Output data stage: The sensor system outputs the short-time filtering result or the filtering result output by the system last time in the stable mode, outputs the IIR filtering result in the changing mode, and saves the output data to the variable Lv.

[0023] The method of the present invention samples the input data by using the window mean filtering with three different lengths of short-time filtering, long-time filtering and ultra-long-time filtering, and monitors the change of the input data through four stages of sampled data, monitoring variable calculation, mode judgment and output data, and outputs the final data result with less fluctuation, which can effectively reduce the interference of the external environmental noise signal and ensure the stability and accuracy of the output data. Embodiment 2

[0024] As Figure 2 shown, it is a variable schematic diagram of a sensor data filtering method, which includes the filtering result calculation formulas of four filtering methods and the related change quantity calculation formulas. Specifically: The short-time filtering is the mean filtering with the window length of SN. The filtering result of the short-time filtering is Sv, and the previous filtering result of the short-time filtering is S V-1 , and the relationship between them is: Sv = S V-1 + (Cv - S V-1 ) / SN, and the short-time change quantity calculation method of the short-time filtering is ΔKv = abs(Lv - Cv), where abs represents the absolute value symbol; by performing short-time filtering on the input data, the high-frequency noise and the noise interference within a short time in the data can be removed, and by obtaining the filtering result within a short time, the fluctuation situation and accuracy of the filtering result under the short-time filtering can be determined.

[0025] The long-time filtering is the mean filtering with the window length of AN. The filtering result of the long-time filtering is Av, and the previous filtering result of the long-time filtering is A V-1 , and the relationship between them is: Av = A V-1 + (Cv - A V-1 ) / AN, and the long-time change quantity calculation method of the long-time filtering is ΔDv = abs(Av - Cv); by performing long-time filtering on the input data, the low-frequency noise and the noise interference within a long time in the data can be removed, and by obtaining the filtering result within a long time, the fluctuation situation of the filtering result under the long-time filtering can be determined.

[0026] The ultra-long-time filtering is the mean filtering with the window length of LAN. The filtering result of the ultra-long-time filtering is LAv, and the previous filtering result of the ultra-long-time filtering is LA V-1 , and the relationship between them is: LAv = LA V-1 + (Cv - LA V-1) / LAN, and the calculation method of the very long - time variation for very long - time filtering is ΔLKv = abs(LAv - Sv); by performing very long - time filtering on the input data, very low - frequency noise and noise interference within a long time can be removed from the data, and by obtaining the filtering result over a long time, the fluctuation of the filtering result under very long - time filtering can be determined.

[0027] Among them, the filtering result of IIR filtering is Rv; the sampled data obtained in the sampled data stage is the instantaneous output Cv; the data output by the analog - to - digital converter in the sensor system is Lv.

[0028] Secondly, the window lengths of the three types of window - mean filtering, namely short - time filtering, long - time filtering, and very long - time filtering, increase in sequence, and the relationship is: SN < AN < LAN; by sampling the input data using three types of window - mean filtering with different lengths, the stability and accuracy of the system output data can be ensured, and using window - mean filtering will not change the frequency of the output data like ordinary mean filtering, which can further improve the accuracy of the system output data. Embodiment 3

[0029] As Figure 3 shown, it is a flowchart of the mode judgment and output data stage of a sensor data filtering method. In the mode judgment stage, when the sensor system is in the stable mode, by judging whether the long - time variation ΔDv is greater than a preset value limit1 and whether the value of the counter COUNT1 is greater than the expected number C1, it is determined whether the sensor system maintains the stable mode or switches to the variation mode; when the sensor system is in the variation mode, by judging whether the long - time variation ΔDv is less than a preset value limit2 and whether the value of the counter COUNT1 is greater than the expected number C2, it is determined whether the sensor system maintains the variation mode or switches to the stable mode.

[0030] In the output data stage, if the sensor system outputs in the stable mode, the filtering result Sv of the short - time filtering is updated to the temporary variable OUT, and then the value of the temporary variable OUT is passed to the variable Lv for output; or the variable Lv output by the sensor system last time is updated to the temporary variable OUT for output. If the sensor system outputs in the variation mode, the filtering result Rv of the IIR filtering is updated to the temporary variable OUT, and then the value of the temporary variable OUT is passed to the variable Lv for output.

[0031] Among them, the initial state of the sensor system is the stable mode, and the long - time variation ΔDv is selected as the basis for judging whether the sensor system maintains stability, so as to accurately determine whether the sensor system switches to the stable mode or the variation mode.

[0032] The mode judgment stage specifically includes the following processes: The sensor system is in the stable mode; when ΔDv is less than or equal to the preset value limit1, the counter COUNT1 is cleared, and the output data phase is entered. When ΔDv is greater than the preset value limit1, if the counter COUNT1 is greater than the expected number of times C1, the sensor system is switched to the change mode, the counter COUNT1 is cleared, and the value of the instantaneous output Cv is updated to Lv, and the output data phase is entered; otherwise, the value of the counter COUNT1 is incremented by 1 and then the output data phase is entered. Among them, updating the value of the instantaneous output Cv to Lv is used as the value of the initial output Lv.

[0033] The sensor system is in the change mode; when ΔDv is greater than or equal to the preset value limit2, the counter COUNT1 is cleared and the output data phase is entered. When ΔDv is less than the preset value limit2, if the value of the counter COUNT1 is greater than the expected number of times C2, the sensor system is switched to the stable mode, the value of the counter COUNT1 is cleared, and the value of the instantaneous output Cv is updated to the short-term filtering result Sv and the ultra-long-term filtering result LAv, and the output data phase is entered; otherwise, the value of the counter COUNT1 is incremented by 1 and then the output data phase is entered.

[0034] The mode judgment stage is used to judge whether the sensor system switches modes, so as to output data results with less fluctuation in the subsequent system, increase the stability and accuracy of the system output data, and make the output result more conform to the latest state data of the system.

[0035] The output data phase specifically includes the following processes: First, a mode judgment is made. When the sensor system is in the stable mode, the short-term change amount ΔKv and the ultra-long-term change amount ΔLKv are calculated, and the value of the variable Lv is updated to the temporary variable OUT. When the short-term change amount ΔKv is greater than the preset value limit3, if the value of the counter COUNT2 is greater than the expected number of times C3, the counter COUNT2 is cleared, the short-term filtering result Sv is updated to the temporary variable OUT, and then the value of the temporary variable OUT is passed to the variable Lv for output. This situation indicates that the instantaneous output Cv fluctuates without breaking through the limit of the stable mode. At this time, the short-term filtering result Sv is output to make the data in this period smoother and filter out the noise signal.

[0036] If the value of the counter COUNT2 is less than or equal to the expected number of times C3, the value of the counter COUNT2 is incremented by 1, and the variable Lv output by the sensor system last time is updated to the temporary variable OUT for output. This situation is used to handle the case where the instantaneous output Cv fluctuates, but the number of times of breaking through the limit value limit3 is limited, and the system output value does not change, so that the system can maintain a stable output under slight fluctuations of the system data.

[0037] When the short-term change amount ΔKv is less than or equal to the preset value limit3, clear the value of the counter COUNT2; if the long-term change amount ΔLKv is greater than the preset value limit4, update the short-term filtering result Sv to the temporary variable OUT, and at the same time update the value of Sv to the long-term filtering result LAv, and then transfer the value of the temporary variable OUT to the variable Lv for output. This situation is used to handle the case where the short-term data fluctuation in the stable mode is less than or equal to limit3, but the small fluctuations of the data accumulate over a long time and exceed limit4. Outputting the result of the short-term filtering can effectively avoid the situation where the data fluctuates slowly while the system output remains unchanged all the time; and synchronously update the value of Sv to LAv for calculating the value of the long-term change amount ΔLKv in the next process.

[0038] If the long-term change amount ΔLKv is less than or equal to the preset value limit4, directly transfer the value of the temporary variable OUT to the variable Lv for output. At this time, the value of the temporary variable OUT is the variable Lv of the previous system output, and the system output remains unchanged; this situation is used to handle the case where the data fluctuates slightly over a long time.

[0039] Among them, the expected number values C1, C2, and C3 can be set and adjusted according to actual applications, and there is no fixed relationship; for the expected preset values limit1, limit2, limit3, and limit4, the setting values should meet limit4 < limit3, and there is no other fixed relationship.

[0040] When the sensor system is in the change mode, update the filtering result Rv of the IIR filter to the temporary variable OUT, and then transfer the value of the temporary variable OUT to the variable Lv for output.

[0041] Those skilled in the art can easily understand that the above are only the preferred embodiments of the present invention and are not intended to limit the present invention. Any modifications, equivalent replacements, and improvements made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims

1. A method for filtering sensor data, characterized in that, Including: Sampling data stage; used to sample the data output by the analog-to-digital converter in the sensor system once, and save the sampled data to the corresponding variable Cv; Monitoring variable calculation stage; according to the data sampled in the sampling data stage, first calculate the filtering results of short-term filtering, long-term filtering, ultra-long-term filtering, and IIR filtering respectively, and then calculate the filtering change amounts of short-term filtering, long-term filtering, and ultra-long-term filtering respectively; Mode judgment stage; Compare the filtering change amount calculated in the monitoring variable calculation stage with a preset value to determine whether the sensor system enters the stable mode or the changing mode; Output data stage; The sensor system outputs the short-term filtering result or the filtering result output by the system last time in the stable mode, outputs the IIR filtering result in the changing mode, and saves the output data to the variable Lv.

2. The sensor data filtering method according to claim 1, wherein The filtering result of the IIR filter is Rv; the window length of the short-time filter is SN, the filtering result of the short-time filter is Sv, and the previous filtering result of the short-time filter is S V-1 , and the relationship between them is: Sv = S V-1 + (Cv - S V-1 ) / SN.

3. A method for filtering sensor data according to claim 1, characterized in that, The window length of the long-term filtering is AN, the filtering result of the long-term filtering is Av, and the previous filtering result of the long-term filtering is A V-1 , and the relationship between them is: Av = A V-1 + (Cv - A V-1 ) / AN.

4. A method for filtering sensor data according to claim 1, characterized in that, The window length of the ultra-long-time filtering is LAN, the filtering result of the ultra-long-time filtering is LAv, and the previous filtering result of the ultra-long-time filtering is LA V-1 , and the relationship between them is: LAv = LA V-1 + (Cv - LA V-1 ) / LAN.

5. A method for filtering sensor data according to claim 2-4, characterized in that, The window lengths of the three window mean filterings of short-term filtering, long-term filtering, and ultra-long-term filtering increase in sequence, and the relationship is: SN < AN < LAN.

6. A method for filtering sensor data according to claim 1, characterized in that The short-term change amount of short-term filtering is ΔKv = abs(Lv - Cv); the long-term change amount of long-term filtering is ΔDv = abs(Av - Cv); the ultra-long-term change amount of ultra-long-term filtering is ΔLKv = abs(LAv - Sv), where abs represents the absolute value symbol.

7. A method for filtering sensor data according to claim 1, characterized in that, The initial state of the sensor system is the stable mode, and the long-term change amount ΔDv is selected as the basis for judging whether the sensor system maintains stability.

8. A method for filtering sensor data according to claim 1, wherein, In the mode judgment stage, when the sensor system is in the stable mode, determine whether the sensor system maintains the stable mode or switches to the changing mode by judging whether the long-term change amount ΔDv is greater than the preset value limit1 and whether the value of the counter COUNT1 is greater than the expected number C1; when the sensor system is in the changing mode, determine whether the sensor system maintains the changing mode or switches to the stable mode by judging whether the long-term change amount ΔDv is less than the preset value limit2 and whether the value of the counter COUNT1 is greater than the expected number C2.

9. A method for filtering sensor data according to claim 1, wherein, In the output data stage, if the sensor system outputs in the stable mode, update the filtering result Sv of short-term filtering to the temporary variable OUT, and then transfer the value of the temporary variable OUT to the variable Lv for output, or update the variable Lv output by the sensor system last time to the temporary variable OUT for output; if the sensor system outputs in the changing mode, update the filtering result Rv of IIR filtering to the temporary variable OUT, and then transfer the value of the temporary variable OUT to the variable Lv for output.