Analog Signal Filtering Automatic Adjustment Method, System, Device and Medium
By calculating the standard deviation of the analog signal and setting the confidence interval and filtering, the frequency range limitation and signal lag problems in the traditional analog filtering method are solved, and the accuracy and real-time improvement of signal processing are achieved.
Patent Information
- Application Number
- CN202510502393.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-22
- Publication Date
- 2025-07-22
- Estimated Expiration
- 2045-04-22
AI Technical Summary
Traditional analog filtering methods have problems with frequency range limitations and signal lag, and cannot effectively deal with interfering signals beyond a specific frequency range, affecting the system response speed and control quality.
By calculating the standard deviation of the analog signal, setting the confidence interval, determining whether the signal is within the interval, if the filtering process is not performed within the interval, a new signal value is generated and output, and the abnormal signal is processed by the median or average filtering method.
It improves the accuracy and reliability of signal processing, reduces the signal hysteresis effect, improves the system's response speed and real-time performance, enhances anti-interference ability, and adapts to changes in different working conditions.
Smart Images

Figure CN120034155B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing, and particularly to a method, system, device, and medium for automatic adjustment of analog signal filtering. Background Art
[0002] In the fields of industrial automation and process control, the accuracy and stability of analog signals are crucial. Traditional analog filtering methods mainly rely on frequency characteristics to design filter circuits, such as low-pass, high-pass, band-pass, and band-stop filters. These methods are effective within a specific frequency range but have significant limitations. Firstly, they can only process signals within a specific frequency range and cannot handle interference signals outside this range. Secondly, in a continuous control loop, a frequency-domain filter may introduce additional delays, affecting the system's response speed and control quality, resulting in signal lag problems. This is particularly inconvenient for rapidly changing signals (such as flow rate, current, etc.) and may even affect equipment safety.
[0003] Therefore, the technical problems of frequency range limitation and signal lag in traditional filtering methods need to be solved urgently. Summary of the Invention
[0004] The main purpose of this application is to provide a method, system, device, and medium for automatic adjustment of analog signal filtering, aiming to solve the technical problems of frequency range limitation and signal lag in traditional filtering methods.
[0005] To achieve the above invention purpose, this application proposes a method for automatic adjustment of analog signal filtering, the method comprising:
[0006] Receiving the current analog signal value;
[0007] Calculating the standard deviation of the previous K consecutive analog signal values before the current analog signal value, where K is a natural number greater than 1;
[0008] Setting a confidence interval using the standard deviation;
[0009] Determining whether the current analog signal value is within the confidence interval;
[0010] If not within the confidence interval, performing filtering processing on the current analog signal value;
[0011] Generating and outputting a second analog signal value based on the result of the filtering processing.
[0012] Further, the step of calculating the standard deviation of the previous K consecutive analog signal values before the current analog signal value includes:
[0013] Collecting analog signal values based on a preset sampling frequency and time interval until K data points of analog signal values are collected;
[0014] Calculate the average value corresponding to the analog signal values of K data points;
[0015] Calculate the square of the difference between the analog signal value of each data point and the average value, and calculate the corresponding variance;
[0016] Calculate the standard deviation of the analog signal values for K consecutive times based on the variance.
[0017] Further, the step of setting the confidence interval using the standard deviation includes:
[0018] Set the lower limit PV - nσ of the confidence interval and the upper limit PV + nσ of the confidence interval to obtain the confidence interval (PV - nσ, PV + nσ);
[0019] Where PV is the average value of the analog signal values for K times, σ is the standard deviation of the analog signal values for K consecutive times, and n is the confidence level coefficient.
[0020] Further, the step of filtering the current analog signal value if it is not within the confidence interval includes:
[0021] When it is detected that the current analog signal value is not within the set confidence interval, obtain the M consecutive analog signal values before the current analog signal value, where M is a natural number greater than 1;
[0022] Arrange the M analog signal values in ascending or descending order according to the numerical size, and calculate the median value to obtain the result of the filtering process.
[0023] Further, the step of filtering the current analog signal value if it is not within the confidence interval further includes:
[0024] When it is detected that the current analog signal value is not within the set confidence interval, obtain the M consecutive analog signal values before the current analog signal value, where M is a natural number greater than 1;
[0025] Calculate the average value of the M analog signal values to obtain the result of the filtering process.
[0026] Further, before the step of setting the lower limit PV - nσ of the confidence interval and the upper limit PV + nσ of the confidence interval to obtain the confidence interval (PV - nσ, PV + nσ), it includes:
[0027] Calculate the average value of the analog signal values for K times;
[0028] Calculate the deviation value between the standard deviation and the average value;
[0029] Obtain the corresponding confidence level coefficient within the preset confidence level coefficient range based on the deviation value to obtain the confidence level coefficient n, where the deviation value and the confidence level coefficient n are in direct proportion growth.
[0030] Further, after the step of receiving the current analog signal value, it includes:
[0031] Obtain the total number a of the currently obtained analog signal values;
[0032] Judge whether the total number a is greater than K;
[0033] If it is less than K, update K based on a, where a is a natural number greater than 1;
[0034] If it is greater than k, execute the step of calculating the standard deviation of the previous K consecutive analog signal values before the current analog signal value.
[0035] The second aspect of the present application also proposes an analog signal filtering automatic adjustment system, including:
[0036] A receiving module, configured to receive the current analog signal value;
[0037] A calculation module, configured to calculate the standard deviation of the previous K consecutive analog signal values before the current analog signal value, where K is a natural number greater than 1;
[0038] A setting module, configured to set a confidence interval by using the standard deviation;
[0039] A judgment module, configured to judge whether the current analog signal value is within the confidence interval;
[0040] A filtering module, configured to perform filtering processing on the current analog signal value if it is not within the confidence interval;
[0041] An adjustment module, configured to adjust and generate a second analog signal value and output it based on the result of the filtering processing.
[0042] The third aspect of the present application further includes a computer device, including a memory and a processor, where the memory stores a computer program, and when the processor executes the computer program, it implements the steps of the method described in any one of the above.
[0043] The fourth aspect of the present application further includes a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, it implements the steps of the method described in any one of the above.
[0044] Beneficial effects
[0045] By calculating the standard deviation of consecutive K analog signal values and setting a confidence interval based on the principle of normal distribution, this application can effectively screen out abnormal data, significantly improving the accuracy and reliability of signal processing. Dynamically setting the confidence interval using the standard deviation ensures that the system can adapt to different operating conditions and provide stable signal processing results. Compared with traditional frequency filters, this solution avoids the problem of sluggish signal changes caused by frequency domain filtering. Especially when processing rapidly changing signals (such as flow rate, current, frequency, rotational speed, etc.), it reduces the lag effect in the control loop and improves the response speed and real-time performance of the system. When the current analog signal value is not within the confidence interval, the system immediately filters it and updates the output value based on the processing result to ensure the continuity and accuracy of signal processing. In addition, by performing median filtering or average filtering on the current analog signal value, the anti-interference ability is further enhanced, ensuring the stability and reliability of the signal, and improving the performance and safety of the entire control system. Brief Description of the Drawings
[0046] Figure 1 It is a schematic flowchart of a method for automatically adjusting analog signal filtering according to an embodiment of this application;
[0047] Figure 2 It is a schematic block diagram of the structure of a system for automatically adjusting analog signal filtering according to an embodiment of this application;
[0048] Figure 3 It is a schematic block diagram of the structure of a computer device according to an embodiment of this application.
[0049] The implementation, functional features, and advantages of the purpose of this application will be further described with reference to the embodiments and the accompanying drawings. Detailed Embodiments
[0050] In order to make the purpose, technical solution, and advantages of this application clearer, the following further details this application with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain this application and are not used to limit this application.
[0051] Those skilled in the art of the present technology can understand that, unless specifically stated otherwise, the singular forms "a", "an", "the above-mentioned", and "the" used herein may also include the plural forms. It should be further understood that the term "comprising" used in the specification of the present invention means the presence of features, integers, steps, operations, elements, modules, and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, modules, components, and / or groups thereof. It should be understood that when an element is "connected" or "coupled" to another element, it can be directly connected or coupled to other elements, or there may also be intermediate elements. In addition, the "connection" or "coupling" used herein may include wireless connection or wireless coupling. The phrase "and / or" used herein includes all or any one of the one or more related listed items and all combinations thereof.
[0052] Those skilled in the art of the present technology can understand that, unless otherwise defined, all terms used herein (including technical terms and scientific terms) have the same meaning as the general understanding of those of ordinary skill in the art to which the present invention belongs. It should also be understood that terms such as those defined in a general dictionary should be understood to have a meaning consistent with the meaning in the context of the prior art, and will not be interpreted with an idealized or overly formal meaning unless specifically defined as herein.
[0053] Referring to Figure 1 , an embodiment of the present invention provides an analog signal filtering automatic adjustment method, including steps S1 - S6, specifically:
[0054] S1. Receive the current analog signal value;
[0055] S2. Calculate the standard deviation of the continuous K analog signal values;
[0056] S3. Set a confidence interval using the standard deviation;
[0057] S4. Determine whether the current analog signal value is within the confidence interval;
[0058] S5. If it is not within the confidence interval, perform filtering processing on the current analog signal value;
[0059] S6. Adjust and generate a second analog signal value based on the result of the filtering processing and output it.
[0060] As described in the above steps S1 - S2, first, the currently newly entered analog signal value, i.e., the analog signal value, is received, and this receiving process is carried out continuously. When each new analog signal value is received, the standard deviation is calculated based on the current analog signal as the starting point and the previous K consecutive analog signal values of the current signal value, where K is a natural number greater than 1. In practical applications, in order to ensure that the collected data is representative and can reflect the stable state of the system, it is first necessary to set an appropriate sampling frequency and time interval. Assume that the selected sampling frequency is 10 times per second (which can be adjusted according to actual needs), and K is set to 50 times, which means that the analog signal values of 50 consecutive data points will be collected. For example, in an industrial automation control system, these analog signals can be parameters such as temperature, pressure, or flow detected by sensors. The system starts to record the signal values collected each time according to the preset sampling frequency and time interval and stores them in a temporary buffer or database. For example, assume that the 50 signal values collected within a certain time period are: 3.2V, 3.3V, 3.4V,... 3.6V.
[0061] Next, these 50 data points need to be processed to calculate the standard deviation. First, calculate the average value (PV) of these data points. The calculation formula is: , where x i represents the signal value collected at the i - th time, and K is the total number of collections. Assume that the calculated average value is 3.5V. Then, calculate the variance. The variance reflects the degree of dispersion of each data point relative to the average value. The specific steps are: calculate the square of the difference between each data point and the average value, sum them up, and finally divide by the total number of data points to obtain the variance. The formula is: , assume that the calculated variance is 0.25. Based on the above variance, calculate the standard deviation σ. The standard deviation is an important indicator to measure the degree to which each value in the data set deviates from the average value. The calculation formula is: .
[0062] In addition, if at the initial startup of the program, the system does not reach the data point buffer capacity of K analog data values before the current analog signal value, then at this time, it is determined not to perform filtering operations and directly output based on the current analog signal value; or K is changed from the preset value to an automatically assigned value. That is, if K is assigned the value of 50 in the initial state, and the current analog signal value is the 31 - st analog signal value, when K is not sufficient to reach the preset data volume, at this time K is assigned the value of 30, and the system directly obtains the first 30 analog signal values to calculate the standard deviation. Until the preset 50 analog signal values are reached, based on the initial preset value, the standard deviation calculation is continuously carried out to achieve dynamic calculation.
[0063] This step not only provides a means to quantify the degree of data dispersion but also lays the foundation for setting confidence intervals in subsequent steps. First, as an important indicator for measuring data fluctuations, the standard deviation can help identify abnormal data that deviates from the normal range. By setting a reasonable threshold, noise and abnormal signals can be effectively filtered out, improving the accuracy and reliability of signal processing. Second, since the calculation of the standard deviation and confidence intervals is based on real-time collected data, this method can dynamically adapt to different working conditions, ensuring reliable signal processing results under various conditions. In addition, compared with traditional frequency filters, this solution calculates the standard deviation and sets the confidence interval in the time domain, avoiding the problem of slow signal changes caused by frequency domain filtering and improving the system's response speed and real-time performance. In summary, by calculating the standard deviation of consecutive K analog signal values, step S2 not only provides key data support for subsequent steps but also significantly improves the reliability and real-time performance of the entire signal filtering process, making it applicable to various application scenarios that require high-precision signal processing. This process ensures that the system can maintain high-precision operation in a complex and changing environment and respond promptly to any unexpected changes, thereby improving the performance and safety of the overall control system.
[0064] As described in step S3 above, in step S2, the standard deviation σ of the continuously K analog signal values has been successfully calculated. Next, based on the principle of normal distribution, this standard deviation is used to set the confidence interval. Suppose the selected confidence level coefficient n is 2 (which can be adjusted according to actual requirements. For example, the value range of N is 1, 2, 3, 4), which means a 95% confidence interval will be set. First, determine the average value PV, which is the average of the continuously K analog signal values obtained from step S2. For example, suppose PV is 3.5V. Then, according to the principle of normal distribution, the lower and upper limits of the confidence interval can be calculated by the following formulas: Lower limit of the confidence interval: PV - nσ; Upper limit of the confidence interval: PV + nσ; where n is the confidence level coefficient and σ is the standard deviation. Suppose the standard deviation σ is 0.5 and the confidence level coefficient n is 2, then the lower limit of the confidence interval is: Therefore, the confidence interval is (2.5V, 4.5V). In this way, a reasonable range can be determined within which the signal value is considered normal, and signal values outside this range are considered outliers. After setting the confidence interval, the system compares the current analog signal value with this interval to determine whether it is within the confidence interval. If the current analog signal value is between (2.5V, 4.5V), it is considered that the signal value is reliable and is directly output for subsequent calculations; otherwise, the system will perform further filtering processing on this signal value. This method based on the principle of normal distribution has many advantages. First, it can effectively identify and exclude those noises or abnormal signals that deviate from the normal range, thus improving the accuracy of signal processing. Second, since the calculation of the standard deviation and the confidence interval is based on the real-time collected data, this method can dynamically adapt to different working conditions changes, ensuring reliable signal processing results under various conditions. Compared with traditional frequency filters, this solution avoids the problem of signal change sluggishness caused by frequency domain filtering. Especially when processing rapidly changing signals (such as flow rate, current, frequency, rotational speed, etc.), it reduces the lag effect in the control loop and improves the response speed and real-time performance of the system. In addition, by performing median filtering or average value filtering on the current analog signal value, the anti-interference ability is further enhanced, ensuring the stability and reliability of the signal, and improving the performance and safety of the entire control system. This method is not only applicable to industrial automation control systems, but also can be widely used in other fields that require high-precision signal processing, such as environmental monitoring, medical equipment, etc. Through these steps, the system can maintain high-precision operation in a complex and changeable environment and respond to any unexpected changes in a timely manner, thus improving the performance and safety of the overall control system. In summary, step S3 not only provides key data support for subsequent steps by setting the confidence interval based on the principle of normal distribution, but also significantly improves the reliability and real-time performance of the entire signal filtering process.
[0065] As described in step S4 above, step S4 is to determine whether the current analog signal value is within the set confidence interval. This process ensures that the system can effectively identify and process abnormal signals, improving the accuracy and reliability of signal processing. Specifically, first, in step S3, the confidence interval has been set (for example, (2.5V, 4.5V)). Next, whenever a new signal value enters the system, the system will judge this signal value. Suppose the current analog signal value is 5.0V, and the system needs to compare it with the set confidence interval. The specific steps are as follows: First, obtain the current analog signal value: The system collects new analog signal values in real time and stores them in a temporary buffer or database. For example, suppose the current analog signal value is 5.0V. Then, determine whether it is within the confidence interval: The system compares the current analog signal value with the set confidence interval. If the signal value is within the confidence interval (that is, between 2.5V and 4.5V), it is considered that the signal value is credible and directly output for subsequent calculations. Otherwise, the system will process it further. For example, since 5.0V is not within the range of (2.5V, 4.5V), this signal value is considered an outlier. Then, record the result: Whether the signal value is within the confidence interval or not, the system needs to record this judgment result for subsequent analysis and optimization. If the signal value is within the confidence interval, it is marked as "credible" and corresponding output is performed; if it is not within the confidence interval, it is marked as "not credible" and the next filtering process is triggered.
[0066] In this way, the system can effectively identify abnormal signals that deviate from the normal range, thereby improving the accuracy of signal processing. Its main functions and advantages include: First, this method can quickly and accurately judge the validity of signal values, avoiding misjudgments caused by noise or outliers. Second, since the judgment process is based on real-time collected data, this method can dynamically adapt to different working conditions, ensuring reliable signal processing results under various conditions. Compared with traditional frequency filters, this solution avoids the problem of slow signal change caused by frequency domain filtering. Especially when processing rapidly changing signals (such as flow rate, current, frequency, rotational speed, etc.), it reduces the lag effect in the control loop and improves the response speed and real-time performance of the system.
[0067] As described in step S5 above, step S5 is to filter the current analog signal value that is not within the confidence interval. This process ensures that the system can effectively eliminate the influence of abnormal signals and improve the stability and reliability of the signal. When the current analog signal value is determined not to be within the confidence interval (for example, 5.0V is not within the range of (2.5V, 4.5V)), the system will filter it.
[0068] Specifically, first, obtain historical data: Retrieve the most recent consecutive M analog signal values from the database (e.g., M = 10), where typically the value of M can be the same as K. Assume these signal values are [2.8V, 3.0V, 3.1V, 3.2V, 3.3V, 3.4V, 3.6V, 3.7V, 3.8V, 3.9V]. Then select a filtering method: Different filtering methods can be chosen according to actual requirements. For example, median filtering or average filtering. For median filtering, the system sorts these M signal values in ascending order of numerical magnitude and takes the middle value as the filtering result. For example, after sorting, the result is [2.8V, 3.0V, 3.1V, 3.2V, 3.3V, 3.4V, 3.6V, 3.7V, 3.8V, 3.9V], and the middle value is (3.3V + 3.4V) / 2 = 3.35V. For average filtering, the system calculates the average of these M signal values to obtain the filtering result. For example, the average is (2.8V + 3.0V + 3.1V + 3.2V + 3.3V + 3.4V + 3.6V + 3.7V + 3.8V + 3.9V) / 10 = 3.4V. Then generate a second analog signal value based on the result of the filtering process. For example, use the result of median filtering, 3.35V, or the result of average filtering, 3.4V, to replace the original 5.0V signal value (to form the second analog signal value).
[0069] In this way, the system can effectively eliminate the influence of abnormal signals, ensuring the stability and reliability of the signals. It effectively smooths the noise in the signals. Secondly, since the filtering process is based on real-time collected historical data, this method can dynamically adapt to different working conditions, ensuring reliable signal processing results under various conditions. Compared with traditional frequency filters, this solution avoids the problem of sluggish signal changes caused by frequency-domain filtering. Especially when dealing with rapidly changing signals, it reduces the lag effect in the control loop and improves the response speed and real-time performance of the system.
[0070] As described in step S6 above, when the current analog signal value is determined to be outside the confidence interval and after filtering (for example, 5.0V becomes 3.35V or 3.4V after filtering), the system will generate a second analog signal value based on the result of the filtering process to replace the "current analog signal value" for output. For example, assuming the result of the filtering process is 3.35V (median filtering) or 3.4V (average filtering), the original 5.0V signal value will be replaced with 3.35V or 3.4V. Output the replaced signal value: Output the replaced signal value for subsequent calculations. For example, the system outputs 3.35V or 3.4V as the new signal value for further processing by the control system or other modules. Record the processing result: The system needs to record the specific situation of each signal value adjustment for subsequent analysis and optimization. For example, record the original signal value, the result of the filtering process, and the finally output signal value to ensure that every step of the operation can be traced.
[0071] In this way, the system can provide a processed and reliable signal, significantly improving the performance and safety of the entire control system. Its main functions and advantages include: First, the adjusted signal value is more stable and reliable, avoiding misoperations caused by abnormal signals. Second, since the output signal value is based on the result of real-time processing, this method can dynamically adapt to different working conditions, ensuring reliable signal processing results under various conditions. Compared with traditional frequency filters, this solution avoids the problem of signal change sluggishness caused by frequency domain filtering. Especially when processing rapidly changing signals, it reduces the lag effect in the control loop and improves the response speed and real-time performance of the system. In addition, by filtering the current analog signal value and outputting the adjusted result, the anti-interference ability is further enhanced, ensuring the stability and reliability of the signal, and improving the performance and safety of the entire control system. This method is not only applicable to industrial automation control systems but also can be widely used in other fields that require high-precision signal processing, such as environmental monitoring, medical equipment, etc.
[0072] In one embodiment, the step of calculating the standard deviation of the continuous K analog signal values includes:
[0073] S20. Collect analog signal values based on a preset sampling frequency and time interval until K data points of analog signal values are collected;
[0074] S21. Calculate the average value corresponding to the K data points of analog signal values;
[0075] S22. Calculate the square of the difference between each data point of the analog signal value and the average value, and calculate the corresponding variance;
[0076] S23. Calculate the standard deviation of the continuous K analog signal values based on the variance.
[0077] In this embodiment, first, in step S20, the system starts to collect analog signal values based on a preset sampling frequency and time interval. For example, assume that the set sampling frequency is 10 times per second and K is 50 times. Then the system will collect 50 data points within 5 seconds. These data points can be parameters such as temperature, pressure, or flow rate from sensors. The collected data will be stored in a temporary buffer or database for subsequent processing. The system calculates the average value (PV) of these 50 data points. This average value represents the signal level within a current period of time and is an important reference benchmark for subsequent steps. Then, in step S22, the system calculates the square of the difference between each data point and the average value, sums them up, and finally divides by the total number of data points to obtain the variance. The specific steps are as follows: for each data point, calculate the difference between it and the average value, square it and accumulate, and finally divide by the total number of data points. The standard deviation not only helps to understand the degree of dispersion of the data but also provides a key basis for setting the confidence interval in subsequent steps.
[0078] Through this embodiment, the system can dynamically calculate the standard deviation of continuous K analog signal values, thereby realizing effective monitoring of signal quality. This method not only provides a means to quantify the degree of data dispersion but also can dynamically adapt to different working conditions, ensuring reliable signal processing results under various conditions. Compared with traditional filtering methods, this solution avoids the problem of signal change slowness caused by frequency-domain filtering. Especially when processing rapidly changing signals, it reduces the lag effect in the control loop and improves the response speed and real-time performance of the system. In addition, by standardizing the signal, the anti-interference ability of the system is further enhanced, ensuring the stability and reliability of the signal. This process lays a solid foundation for subsequent signal judgment and filtering processing.
[0079] In one embodiment, the step of setting the confidence interval based on the normal distribution principle using the standard deviation includes:
[0080] S30. Set the lower limit PV - nσ of the confidence interval and the upper limit PV + nσ of the confidence interval to obtain the confidence interval (PV - nσ, PV + nσ); where PV is the average value of K analog signal values, σ is the standard deviation of continuous K analog signal values, and n is the confidence level coefficient.
[0081] In this embodiment, in step S30, the system sets the lower and upper limits of the confidence interval according to the confidence level coefficient n. With these parameters, the system can dynamically adapt to different operating condition changes, ensuring reliable signal processing results under various conditions. Whenever the system receives a new signal value, it compares the value with the newly calculated confidence interval. If the current analog signal value is within the confidence interval, it is considered normal and directly output; if not, further filtering is performed on it to eliminate the influence of noise or outliers. This method not only improves the accuracy and reliability of signal processing but also reduces the hysteresis effect in the control loop, enhancing the system's response speed and real-time performance.
[0082] In one embodiment, the step of filtering the current analog signal value when it is not within the confidence interval includes:
[0083] S40. When it is detected that the current analog signal value is not within the set confidence interval, obtain the previous consecutive M analog signal values before the current analog signal value, where M is a natural number greater than 1;
[0084] S41. Arrange the M analog signal values in ascending or descending order according to their numerical magnitudes, and calculate the median value to obtain the result of the filtering process.
[0085] In this embodiment, when the current analog signal value is not within the set confidence interval, the step of filtering the current analog signal value includes: First, in step S40, when it is detected that the current analog signal value is not within the set confidence interval, the system obtains the previous consecutive M analog signal values starting from the current analog signal value from the database. For example, assuming M is 10, the system will obtain the 10 analog signal values closest to the current analog signal value. Then, in step S41, the system arranges the M analog signal values in ascending or descending order according to their numerical magnitudes and calculates the median value to obtain the result of the filtering process. For example, if the 10 sorted signal values are [2.8V, 3.0V, 3.1V, 3.2V, 3.3V, 3.4V, 3.6V, 3.7V, 3.8V, 3.9V], the median value is (3.3V + 3.4V) / 2 = 3.35V. By this method, the system can effectively smooth abnormal signals, eliminate the influence of noise or outliers, and ensure the stability and reliability of the output signal. This process not only improves the accuracy of signal processing but also enhances the anti-interference ability of the system, and is applicable to various application scenarios that require high-precision signal processing.
[0086] In one embodiment, the step of filtering the current analog signal value when it is not within the confidence interval further includes:
[0087] S50. When it is detected that the current analog signal value is not within the set confidence interval, obtain the M consecutive analog signal values before the current analog signal value, where M is a natural number greater than 1;
[0088] S51. Calculate the average value of the M analog signal values to obtain the result of filtering processing.
[0089] In this embodiment, first, in step S50, when it is detected that the current analog signal value is not within the set confidence interval, the system obtains the M consecutive analog signal values before the current analog signal value from the database. For example, assuming M is 10, the system will obtain the most recent 10 analog signal values, which can be parameters such as temperature, pressure, or flow rate collected by sensors. Then, in step S51, the system calculates the average value of these M analog signal values to obtain the result of filtering processing. By calculating the average value of these M signal values, the system can effectively smooth abnormal signals, eliminate the influence of noise or outliers, and ensure the stability and reliability of the output signal.
[0090] This method not only improves the accuracy of signal processing but also enhances the anti-interference ability of the system, and is applicable to various application scenarios that require high-precision signal processing. Compared with other filtering methods, the method of calculating the average value is simple and efficient, and is particularly suitable for control systems with high real-time requirements. Through these steps, the system can maintain high-precision operation in a complex and changing environment, and respond promptly to any unexpected changes, thereby improving the performance and safety of the overall control system.
[0091] In one embodiment, after the step of determining whether the current analog signal value is within the confidence interval, it includes:
[0092] S60. If it is within the confidence interval, output the current analog signal value.
[0093] In this embodiment, if the system determines that the current analog signal value is within the set confidence interval, the signal value is output for subsequent calculations. Specifically, assuming that the confidence interval of the system is (2.5V, 4.5V), when the current analog signal value is 4.0V, this value falls within the confidence interval, and the system will confirm the validity of the signal value, that is, confirm whether the signal value (such as 4.0V) is within the set confidence interval (for example, between 2.5V and 4.5V). Once it is confirmed that the signal value is within the confidence interval, the system immediately uses the analog signal value (such as 4.0V) as the output value, and the output analog signal value will be used for various subsequent calculation and analysis tasks. For example, in an industrial automation control system, these analog signal values may be used for control loop adjustment, trend analysis, or alarm triggering, etc. In this way, the system can ensure that only verified signal values within the confidence interval will be further processed and used, thereby improving the reliability and accuracy of the entire system. This process not only improves the accuracy of signal processing but also enhances the anti-interference ability of the system, and is applicable to various application scenarios that require high-precision signal processing.
[0094] In one embodiment, before the step of setting the lower limit PV - nσ and the upper limit PV + nσ of the confidence interval to obtain the confidence interval (PV - nσ, PV + nσ), it includes:
[0095] S70. Calculate the average value of the K analog signal values;
[0096] S71. Calculate the deviation value between the standard deviation and the average value;
[0097] S72. Based on the deviation value, obtain the corresponding confidence level coefficient within the preset confidence level coefficient range to obtain the confidence level coefficient n, where the deviation value is proportional to the confidence level coefficient n.
[0098] In this embodiment, the system first calculates the average value PV of the continuous K analog signal values. For example, assuming that the 50 collected signal values are 3.2V, 3.3V, 3.4V,... 3.6V respectively, the calculated average value is 3.5V. Next, the system calculates the standard deviation σ and compares it with the average value PV to obtain the deviation value. Specifically, the deviation value can be calculated by the formula σ / PV. Assuming that the standard deviation σ is 0.5, the deviation value is 0.5 / 3.5≈0.14. According to the deviation value, the system selects a suitable confidence level coefficient n from the preset range of confidence level coefficients. Usually, the larger the deviation value, the larger the confidence level coefficient n should be to ensure that more data points are included in the confidence interval. For example, if the preset range of confidence level coefficients is from 1 to 4, and the deviation value increases proportionally with the confidence level coefficient, then when the deviation value is 0.14, n = 2 can be correspondingly mapped. By calculating the deviation value between the standard deviation and the average value, and dynamically selecting a suitable confidence level coefficient n based on this deviation value, the system can set the confidence interval more accurately. This method ensures that under different working conditions, the confidence interval can adapt to the degree of data dispersion, so as to more accurately identify and exclude noise or abnormal signals. For example, in the case of large data fluctuations, selecting a larger confidence level coefficient n can avoid misjudging normal signals as abnormal signals, while in the case of relatively stable data, selecting a smaller confidence level coefficient n can more sensitively detect small abnormal changes.
[0099] In one embodiment, after the step of receiving the current analog signal value, it includes:
[0100] S80. Obtain the total number a of the currently obtained analog signal values;
[0101] S81. Determine whether the total number a is greater than K;
[0102] S82. If it is less than K, update K based on a, where a is a natural number greater than 1;
[0103] S83. If it is greater than k, execute the step of calculating the standard deviation of the continuous K analog signal values before the current analog signal value.
[0104] In this embodiment, the system compares the total number a with a preset K value. If a is less than K, it indicates that not enough data points have been collected for standard deviation calculation. If the total number a is less than K, the system dynamically adjusts the K value to be equal to the current total number of existing data points a. For example, assume the preset K value is 50, but currently only 30 data points have been collected. Then the system updates K to 30 to perform preliminary standard deviation calculation and signal processing using all the existing data. If the total number a is greater than or equal to K, the system proceeds to the next step, that is, performs operations such as standard deviation calculation and confidence interval setting based on the initially preset K value. This means that the system already has enough data points for effective signal analysis and processing. When the system starts running, it may not have collected enough data points (i.e., the total number a is less than the preset K value). By dynamically adjusting the K value to be equal to the current total number of existing data points a, the system can utilize all the existing data for preliminary standard deviation calculation and signal processing in the case of insufficient data. This not only improves the data utilization rate in the initial stage but also enables the system to provide a certain degree of signal analysis and processing results at an early stage, enhancing the real-time response ability of the system. Compared with traditional methods, this method avoids processing delays or inaccuracies caused by insufficient data. Especially in a rapidly changing environment, it can effectively reduce the lag effect in the control loop and improve the response speed and real-time performance of the system.
[0105] Referring to Figure 2 , which is a block diagram of the analog signal filtering automatic adjustment system in an embodiment of the present application. The system includes:
[0106] A receiving module 100 for receiving the current analog signal value;
[0107] A calculation module 200 for calculating the standard deviation of the previous K consecutive analog signal values of the current analog signal value, where K is a natural number greater than 1;
[0108] A setting module 300 for setting a confidence interval using the standard deviation;
[0109] A judgment module 400 for judging whether the current analog signal value is within the confidence interval;
[0110] A filtering module 500 for filtering the current analog signal value if it is not within the confidence interval;
[0111] An adjustment module 600 for adjusting and generating a second analog signal value and outputting it based on the result of the filtering process.
[0112] Furthermore, the calculation module 200 includes an acquisition unit for:
[0113] Collect analog signal values based on a preset sampling frequency and time interval until K analog signal values of data points are collected;
[0114] Calculate the average value corresponding to the analog signal values of K data points;
[0115] Calculate the square of the difference between the analog signal value of each data point and the average value, and calculate the corresponding variance;
[0116] Calculate the standard deviation of continuous K analog signal values based on the variance.
[0117] Further, the setting module 300 includes a confidence interval setting unit for:
[0118] Set the lower limit PV - nσ and the upper limit PV + nσ of the confidence interval to obtain the confidence interval (PV - nσ, PV + nσ);
[0119] Where PV is the average value of K analog signal values, σ is the standard deviation of continuous K analog signal values, and n is the confidence level coefficient.
[0120] Further, the filtering module 500 includes a median filtering processing unit for:
[0121] When it is detected that the current analog signal value is not within the set confidence interval, obtain the continuous M analog signal values before the current analog signal value, where M is a natural number greater than 1;
[0122] Arrange the M analog signal values in ascending or descending order according to the numerical value, and calculate the middle value to obtain the result of the filtering process.
[0123] Further, the filtering module 500 includes an average filtering processing unit for:
[0124] When it is detected that the current analog signal value is not within the set confidence interval, obtain the continuous M analog signal values before the current analog signal value, where M is a natural number greater than 1;
[0125] Calculate the average value of the M analog signal values to obtain the result of the filtering process.
[0126] Further, the setting module 300 further includes a coefficient obtaining unit for:
[0127] Calculate the average value of K analog signal values;
[0128] Calculate the deviation value between the standard deviation and the average value;
[0129] Obtain the corresponding confidence level coefficient within the preset confidence level coefficient range based on the deviation value to obtain the confidence level coefficient n, where the deviation value is proportional to the confidence level coefficient n for growth.
[0130] Further, the system further includes an acquisition point number update unit for:
[0131] Obtain the total number a of the currently acquired analog signal values;
[0132] Judge whether the total number a is greater than K;
[0133] If it is less than K, update K based on a, where a is a natural number greater than 1;
[0134] If it is greater than k, perform the step of calculating the standard deviation of the previous K consecutive analog signal values before the current analog signal value.
[0135] Refer to Figure 3 , in the embodiments of the present application, a computer device is further provided. The computer device may be a server, and its internal structure may be as Figure 3 shown. The computer device includes a processor, an internal memory, a storage medium (non-volatile storage medium), and a network interface connected through a system bus. Among them, the processor of the computer design is used to provide computing and control capabilities. The memory of the computer device includes the above storage medium (non-volatile storage medium) and the internal memory. The storage medium (non-volatile storage medium) stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the storage medium (non-volatile storage medium). The database of the computer device is used to store the usage data and the like in the process of an analog signal filtering automatic adjustment method. The network interface of the computer device is used to communicate with an external terminal through a network connection. Further, the above computer device may also be provided with an input device, a display screen, and the like. When the above computer program is executed by the processor, it realizes an analog signal filtering automatic adjustment method, including the following steps: receiving the current analog signal value; calculating the standard deviation of the previous K consecutive analog signal values before the current analog signal value, where K is a natural number greater than 1; setting a confidence interval by using the standard deviation; judging whether the current analog signal value is within the confidence interval; if it is not within the confidence interval, performing filtering processing on the current analog signal value; generating and outputting a second analog signal value based on the result of the filtering processing.
[0136] Those skilled in the art can understand that Figure 3 the structure shown in
[0137] An embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, it implements a method for automatically adjusting analog signal filtering, including the following steps: receiving the current analog signal value; calculating the standard deviation of the continuous K analog signal values before the current analog signal value, where K is a natural number greater than 1; setting a confidence interval using the standard deviation; determining whether the current analog signal value is within the confidence interval; if not within the confidence interval, performing filtering processing on the current analog signal value; generating and outputting a second analog signal value based on the result of the filtering processing. It can be understood that the computer-readable storage medium in this embodiment can be a volatile readable storage medium or a non-volatile readable storage medium.
[0138] Those of ordinary skill in the art can understand that all or part of the processes of implementing the methods in the above embodiments can be completed by instructing relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above methods. Among them, any reference to a memory, storage, database, or other medium provided in the present application and used in the embodiments can include non-volatile and / or volatile memories. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or an external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (SSRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0139] It should be noted that in this article, the term "including", "comprising", or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, apparatus, article, or method including a series of elements not only includes those elements but also includes other elements not explicitly listed, or further includes elements inherent to such a process, apparatus, article, or method. Without further limitation, an element defined by the statement "including one..." does not exclude the existence of additional identical elements in the process, apparatus, article, or method including that element.
[0140] The above are only the preferred embodiments of the present application, and do not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made by using the content of the specification and drawings of the present application, or directly or indirectly applied in other related technical fields, shall be equally included in the patent protection scope of the present application.
Claims
1. An analog signal filtering automatic adjustment method, characterized in that, The method includes: Receiving the current analog signal value; Calculating the standard deviation of the continuous K analog signal values before the current analog signal value, where K is a natural number greater than 1; Setting a confidence interval using the standard deviation; Determining whether the current analog signal value is within the confidence interval; If not within the confidence interval, performing filtering processing on the current analog signal value; Generating and outputting a second analog signal value based on the result of the filtering processing; The step of setting the confidence interval using the standard deviation includes: Setting the lower limit PV - nσ of the confidence interval and the upper limit PV + nσ of the confidence interval to obtain the confidence interval (PV - nσ, PV + nσ); Where PV is the average value of the K analog signal values, σ is the standard deviation of the continuous K analog signal values, and n is the confidence level coefficient.
2. The analog signal filtering automatic adjustment method according to claim 1, wherein The step of calculating the standard deviation of the continuous K analog signal values before the current analog signal value includes: Collecting analog signal values based on a preset sampling frequency and time interval until K data points of analog signal values are collected; Calculating the average value corresponding to the K data points of analog signal values; Calculating the square of the difference between each data point of the analog signal value and the average value, and calculating the corresponding variance; Calculating the standard deviation of the continuous K analog signal values based on the variance.
3. The analog signal filtering automatic adjustment method according to claim 1, wherein The step of, if not within the confidence interval, performing filtering processing on the current analog signal value includes: When it is detected that the current analog signal value is not within the set confidence interval, obtaining the continuous M analog signal values before the current analog signal value, where M is a natural number greater than 1; Sorting the M analog signal values in ascending or descending order according to the numerical value and calculating the median value to obtain the result of the filtering processing.
4. The analog signal filtering automatic adjustment method according to claim 1, wherein The step of, if not within the confidence interval, performing filtering processing on the current analog signal value further includes: When it is detected that the current analog signal value is not within the set confidence interval, obtaining the continuous M analog signal values before the current analog signal value, where M is a natural number greater than 1; Calculating the average value of the M analog signal values to obtain the result of the filtering processing.
5. The analog signal filtering automatic adjustment method according to claim 1, characterized in that Before the step of setting the lower limit PV - nσ of the confidence interval and the upper limit PV + nσ of the confidence interval to obtain the confidence interval (PV - nσ, PV + nσ), it includes: Calculating the average value of the K analog signal values; Calculating the deviation value between the standard deviation and the average value; Obtaining the corresponding confidence level coefficient n within the preset confidence level coefficient range based on the deviation value, where the deviation value and the confidence level coefficient n increase proportionally.
6. The analog signal filtering automatic adjustment method according to claim 1, wherein After the step of receiving the current analog signal value, it includes: Obtaining the total number a of the currently obtained analog signal values; Determining whether the total number a is greater than K; If less than K, updating K based on a, where a is a natural number greater than 1; If greater than K, then performing the step of calculating the standard deviation of the continuous K analog signal values before the current analog signal value.
7. An analog signal filtering automatic adjustment system for implementing the method described in any one of claims 1-6, characterized in that, It includes: A receiving module for receiving the current analog signal value; A calculation module, configured to calculate the standard deviation of the analog signal values in the K consecutive times before the current analog signal value, where K is a natural number greater than 1; A setting module, configured to set a confidence interval by using the standard deviation; A judgment module, configured to judge whether the current analog signal value is within the confidence interval; A filtering module, configured to perform filtering processing on the current analog signal value if it is not within the confidence interval; An adjustment module, configured to adjust and generate a second analog signal value based on the result of the filtering processing and output the second analog signal value.
8. A computer device, comprising a memory and a processor, the memory storing a computer program, characterized in that, When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, the steps of the method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Filtering device and filtering algorithm based on 3-sigma rule
CN103412867A