Water quality detection error correction method based on embedded computing

By using embedded computing multi-model Kalman filtering and chi-square gating techniques, a short-window detection queue is constructed to estimate water quality detection errors in parallel. This solves the detection error problem caused by sensor drift and disturbance, and realizes real-time, stable and highly adaptable correction of water quality detection results.

CN122432490BActive Publication Date: 2026-11-20ZHEJIANG QINGKE MASS SPECTROMETER INNOVATION CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202610575545.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2026-04-28
Publication Date
2026-11-20
Estimated Expiration
2046-04-28

AI Technical Summary

Technical Problem

Existing water quality testing equipment is prone to slow drift and transient disturbances after long-term operation of sensors, resulting in errors in the test results. Existing error correction methods are difficult to adapt to different error patterns, and the embedded computing power is insufficient, lacking the ability to make real-time corrections.

Method used

An interactive multi-model Kalman filter with embedded computing, chi-square gating, and recursive least squares incremental update techniques are used to construct a short-window detection queue to estimate steady-state noise, slow drift, and transient disturbance errors in parallel, perform bias compensation and disturbance compensation, and update the error compensation parameters based on feedback data.

Benefits of technology

It achieves strong real-time performance of water quality testing results, high adaptability to different error types, good stability of testing results, and has independent correction capability at the embedded end.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122432490B_ABST
    Figure CN122432490B_ABST
Patent Text Reader

Abstract

The application discloses a water quality detection error correction method based on embedded computing, which comprises the following steps: S1, acquiring multi-source data and pre-processing to form a short window detection queue; S2, initializing an interactive multi-model Kalman filter set at an embedded end and configuring a model transition probability matrix; S3, predicting a detection value change trend and updating an error estimation state to form an error estimation result and a model residual result; S4, performing matching calculation on a residual amplitude and a residual dispersion degree and recursively propagating a model probability weight to a current sampling period to adjust a current probability weight; S5, performing posterior re-estimation on the error estimation result and executing residual gating, performing bias compensation and disturbance compensation on original detection values to form a water quality detection result; and S6, collecting feedback data and incrementally updating error compensation parameters. The application can realize localized identification of water quality detection errors and improve the stability of water quality detection results.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of water quality testing technology, and in particular to a water quality testing error correction method based on embedded computing. Background Technology

[0002] Water quality testing is a crucial technical component in water environment monitoring, industrial discharge regulation, water supply safety management, and water treatment process control. Existing water quality testing equipment typically collects relevant parameters from water bodies using sensors, and the results are displayed, stored, and analyzed by a testing terminal or upper-level platform. However, in actual testing processes, the data is easily affected by factors such as sensor zero-point drift, sampling disturbances, fluctuations in the detection link, changes in environmental conditions, and long-term changes in equipment operating conditions, leading to discrepancies between the original test values ​​and the actual water quality.

[0003] Current methods for correcting water quality testing errors mainly employ static calibration, fixed compensation coefficients, simple filtering, or centralized calibration in the background. Static calibration typically relies on pre-set calibration parameters, making it difficult to adapt to the slow drift that occurs after long-term sensor operation. Simple filtering primarily smooths out short-term noise but lacks the ability to distinguish between gradual offset errors and transient disturbance errors. Centralized calibration in the background requires uploading and processing the test data, leaving the on-site testing terminal lacking real-time correction capabilities and making it difficult to promptly eliminate dynamic errors in the test results.

[0004] Meanwhile, while some existing error correction methods incorporate model estimation or data analysis algorithms, they typically treat different error sources using a uniform model, lacking parallel estimation and probability switching mechanisms for different error forms such as steady-state noise, slow drift, and transient disturbances. When continuous shifts and sudden disturbances coexist in the detection sequence, a single filtering model can easily misjudge transient anomalies as long-term drifts, causing the error compensation parameters to be affected by abnormal residuals, thereby reducing the reliability of subsequent detection result corrections.

[0005] In addition, the local computing power of existing water quality testing terminals is underutilized. Embedded terminals often only undertake data acquisition, temporary storage and communication uploading functions, lacking a complete correction link that can complete short-window detection queue construction, multi-model filtering estimation, residual matching, probability weight adjustment, gating compensation and feedback incremental update locally.

[0006] Therefore, how to provide a water quality detection error correction method based on embedded computing is a problem that urgently needs to be solved by those skilled in the art. Summary of the Invention

[0007] One objective of this invention is to propose a water quality detection error correction method based on embedded computing. This invention fully utilizes local computing on the embedded end, interactive multi-model Kalman filtering, Gaussian residual likelihood assessment, chi-square gating, and recursive least squares incremental update techniques. It details the process of constructing a short-window detection queue on the water quality detection equipment side, estimating steady-state noise error, slow-varying drift error, and transient disturbance error in parallel, adjusting the current probability weights based on model residuals, performing bias compensation and disturbance compensation on the original detection values, and updating the error compensation parameters based on feedback data. It has the advantages of strong real-time error correction, high adaptability to different error types, good stability of detection results, and strong independent correction capability on the embedded end.

[0008] A water quality detection error correction method based on embedded computing according to an embodiment of the present invention includes the following steps: S1. Acquire multi-source water quality testing data and preprocess it to form a short-window testing queue; S2. Initialize the interactive multi-model Kalman filter bank on the embedded end, load the state vector, assign the covariance matrix to each filter model and configure the model transition probability matrix to form a parallel filter calculation structure. S3. Based on the short window detection queue, the parallel filtering calculation structure performs synchronous operation, predicts the trend of detection value change according to the state vector and covariance matrix, and updates the error estimation state according to the prediction deviation to form the error estimation result and model residual result. S4. Based on the model residual results, the Gaussian residual likelihood evaluation method is used to match and calculate the residual amplitude and residual dispersion. Combined with the model transition probability matrix, the model probability weights of the previous sampling period are recursively pushed to the current sampling period to adjust the current probability weights of each filtering model. S5. Based on the current probability weight, perform posterior re-estimation on the error estimation result, and perform residual gating in combination with the model residual result. Based on the gated error estimation result, perform bias compensation and disturbance compensation on the original detection values ​​in the short window detection queue to form water quality detection results. S6. Collect feedback data of water quality test results and incrementally update the error compensation parameters of each filtering model using the least squares method.

[0009] Optionally, the preprocessing specifically includes: configuring a unified sampling timescale for multi-source water quality detection data on an embedded device, wherein the embedded device is a local computing environment set on the side of the water quality detection equipment and configured with a queue buffer area and a filtering operation area; The multi-source data are periodically aligned based on a unified sampling time scale, and the validity of the aligned multi-source data is screened based on the range boundary and the difference between adjacent samples. Valid sampled data is written into a queue cache according to a sliding window, and the sampling order within the window is indexed by a time stamp to form a short-window detection queue containing detection values, auxiliary status values, and sampling time stamps. The detection values ​​are the water quality parameter measurement values ​​output by the water quality detection equipment at the corresponding sampling time. The auxiliary status values ​​are the sensor temperature value, power supply voltage value, probe response time value, or equipment running time value, which are collected synchronously with the detection values ​​and used to characterize the detection process status. The sampling time stamp is the time index configured by the embedded terminal for the detection values ​​and auxiliary status values ​​according to a unified sampling period.

[0010] Optionally, the interactive multi-model Kalman filter bank includes a steady-state noise filtering model, a slowly varying drift filtering model, and a transient disturbance filtering model; Among them, the steady-state noise filtering model is used to characterize the random fluctuation error of the detected value under the stable sampling state, the slow drift filtering model is used to characterize the gradual offset error of the detected value with the continuous sampling period, and the transient disturbance filtering model is used to characterize the sudden deviation error of the detected value in the short window detection queue. The state vector is used to record the error estimation state of each filter model in the current sampling period. The covariance matrix is ​​used to record the dispersion of the error estimation state. The model transition probability matrix is ​​used to record the switching probability of each filter model between adjacent sampling periods. The current probability weight is used to represent the weight of the error estimation result corresponding to each filter model in the water quality detection error correction.

[0011] Optionally, S2 specifically includes: S21. Establish the filtering period on the embedded end based on the sampling time of the short window detection queue, and allocate the steady-state noise filtering model, the slow drift filtering model and the transient disturbance filtering model to the parallel filtering channel. S22. Based on the continuous change of the detected value and the change of the auxiliary state value in the short window detection queue, load a state vector for each filter model, wherein the state vector includes a detected value estimation term, an error offset term, and a change trend term. S23. Based on the degree of dispersion and continuous offset of the detected values ​​in the short window detection queue, assign covariance matrix values ​​to each filtering model, and configure the corresponding covariance value ranges based on the steady-state noise filtering model, the slow drift filtering model, and the transient disturbance filtering model. S24. Based on each filtering model, configure the model transition probability matrix according to the switching relationship between adjacent sampling periods, and bind the state vector, covariance matrix and model transition probability matrix to the corresponding filtering model to form a parallel filtering calculation structure.

[0012] Optionally, S3 specifically includes: S31. Synchronously trigger each parallel filtering channel according to the sampling time scale in the short window detection queue, and call the state vector, state transition matrix and covariance matrix of each filtering model within the same sampling period. The state transition matrix is ​​a matrix in each filtering model used to describe the state transmission relationship of the detection value estimation term, error offset term and change trend term within the same filtering period. S32. Based on the state transition matrix, each filtering model performs state prediction on the detection value estimation term, error offset term, and trend term in the state vector, and uses the predicted detection value estimation term as the predicted detection value for the current sampling period. S33. Perform a difference calculation between the predicted detection value and the current detection value in the short window detection queue to form the prediction bias, and calculate the Kalman gain corresponding to each filtering model based on the covariance matrix and the prediction bias. S34. Based on Kalman gain, the prediction bias is allocated to the error offset term and the trend term in the state vector, and the covariance matrix is ​​updated using the Joseph stabilized covariance update method to form the error estimation results and model residual results corresponding to each filtering model.

[0013] Optionally, S34 specifically includes: S341. Perform residual projection on the prediction bias based on Kalman gain, allocate the prediction bias to the error offset term and the trend term in the state vector, and update the detection offset of the current sampling period according to the allocated error offset term. S342. Correct the direction of change of the detected values ​​in the short window detection queue according to the assigned trend term, and write the detection offset and the direction of change into the state vector to form the error estimation results corresponding to each filtering model. S343. The Joseph stable covariance update method is used to perform a stable update on the covariance matrix, and the updated covariance matrix is ​​subjected to positive definite constraints through Cholesky decomposition to obtain a stable covariance matrix. S344. Construct model residual results based on prediction bias and stable covariance matrix. The model residual results include residual magnitude and residual dispersion.

[0014] Optionally, S4 specifically includes: S41. Based on the model residual results of each filtering model, the Mahalanobis distance metric is used to jointly measure the residual magnitude and residual dispersion to obtain the residual matching distance corresponding to each filtering model. S42. The Gaussian residual likelihood evaluation method is used to perform likelihood mapping on the residual matching distance, converting the residual matching distance corresponding to each filtering model into the model residual likelihood value. Specifically, this includes: Input the residual matching distance corresponding to each filtering model into the Gaussian kernel function, and configure the scale parameter of the Gaussian kernel function according to the distribution range of the residual matching distance in the short window detection queue; A Gaussian kernel function is used to perform a squared decay operation on the residual matching distance, mapping the residual matching distance to the initial likelihood response value of the corresponding filter model; Embedded fixed-point quantization is performed on the initial likelihood response value, and the quantized initial likelihood response value is truncated according to the preset lower likelihood limit to obtain the restricted likelihood response value. The restricted likelihood response values ​​are sequentially encapsulated according to the model identifier of each filtering model to form the model residual likelihood values ​​corresponding to the steady-state noise filtering model, the slow drift filtering model, and the transient disturbance filtering model. S43. Using the forward probability recursion method, perform matrix recursion operation on the model probability weights and model transition probability matrix of the previous sampling period, and allocate the probability weights of each filter model in the previous sampling period to the current sampling period to obtain the prior probability weights of each filter model. S44. Multiply the model residual likelihood value with the prior probability weights to correct the model, and then reallocate the current probability weights of the steady-state noise filtering model, the slow drift filtering model, and the transient disturbance filtering model according to the product correction result.

[0015] Optionally, S43 specifically includes: S431. Based on the row and column correspondence of each filtering model in the model transition probability matrix, determine the transition path from each filtering model in the previous sampling period to each filtering model in the current sampling period. S432. Multiply the model probability weights of each filter model in the previous sampling period with the corresponding switching probabilities along the transfer path to form the probability components that each filter model in the previous sampling period transmits to each filter model in the current sampling period. S433. Aggregate the probability components in the same column according to the target filtering model of the current sampling period to obtain the prior probability weights corresponding to each filtering model. S434. Apply probability boundary constraints to the prior probability weights, configure the prior probability weights below the minimum probability threshold as lower limit weights, and perform proportional callbacks on the remaining prior probability weights to form prior probability weights for the redistribution of the current probability weights.

[0016] Optionally, S5 specifically includes: S51. Based on the current probability weights of each filtering model, perform posterior re-estimation of the error estimation results, rearrange the error estimation results of each filtering model according to the current probability weights, and configure the corresponding posterior participation coefficients for each error estimation result. S52. Based on the residual amplitude and residual dispersion in the model residual results, the chi-square gating method is used to gating the error estimation results, and the posterior participation coefficient is corrected according to the gating discrimination results to obtain the gating error estimation results. S53. Based on the error estimation results after gating, construct the bias compensation amount and the disturbance compensation amount. The bias compensation amount is constructed with the error estimation results corresponding to the slow drift filter model, and the disturbance compensation amount is constructed with the error estimation results corresponding to the transient disturbance filter model. S54. Perform baseline offset correction on the original detection values ​​in the short window detection queue according to the offset compensation amount, and perform short window disturbance cancellation on the detection values ​​after baseline offset correction according to the disturbance compensation amount to form water quality detection results.

[0017] Optionally, S6 specifically includes: S61. Collect feedback data of water quality test results, and match the feedback data with the water quality test results according to the sampling time scale to form feedback residuals. The feedback data is the water quality test reference value after verification or the calibration test value under the same sampling period. S62. Construct a least squares update sample based on the feedback residual, wherein the least squares update sample includes the feedback residual, the bias compensation amount, the disturbance compensation amount, and the current probability weight; S63. Using the recursive least squares method with a forgetting factor, the bias compensation coefficient and disturbance compensation coefficient in each filtering model are incrementally estimated, and the update ratio of each filtering model participating in the incremental estimation is limited according to the current probability weight. S64. Update the error compensation parameters of the corresponding filtering model based on the incremental estimation results to form the filtering parameters for bias compensation and disturbance compensation in the next sampling period.

[0018] The beneficial effects of this invention are: First, this invention preprocesses multi-source water quality detection data on the embedded end and forms a short-window detection queue, enabling the detection data to be continuously organized and locally processed on the device side, thereby improving the timeliness of on-site processing of water quality detection results.

[0019] Secondly, this invention employs an interactive multi-model Kalman filter bank to estimate steady-state noise error, slow-varying drift error, and transient disturbance error in parallel. It also combines Mahalanobis distance metric, Gaussian residual likelihood assessment, and model probability recursion to adjust the current probability weights, enabling differentiated identification and correction of different error morphologies and reducing misjudgment of complex errors by a single model.

[0020] Finally, this invention uses chi-square gating to screen the error estimation results, performs bias compensation and disturbance compensation on the original detection values, and uses the recursive least squares method to incrementally update the error compensation parameters in combination with feedback data, so as to maintain the stability of water quality detection results and the continuous adaptability of error correction. Attached Figure Description

[0021] The accompanying drawings are provided to further illustrate the invention and form part of the specification. They are used in conjunction with embodiments of the invention to explain the invention and do not constitute a limitation thereof. In the drawings: Figure 1 This is an overall flowchart of a water quality detection error correction method based on embedded computing proposed in this invention; Figure 2 This is a flowchart of the parallel filtering prediction and error estimation process for a water quality detection error correction method based on embedded computing proposed in this invention. Figure 3 This is a flowchart of the residual gating and bias disturbance compensation process for a water quality detection error correction method based on embedded computing proposed in this invention. Detailed Implementation

[0022] The present invention will now be described in further detail with reference to the accompanying drawings. These drawings are simplified schematic diagrams, illustrating only the basic structure of the invention, and therefore only show the components relevant to the invention.

[0023] refer to Figures 1-3 A water quality detection error correction method based on embedded computing includes the following steps: S1. Acquire multi-source water quality testing data and preprocess it to form a short-window testing queue; S2. Initialize the interactive multi-model Kalman filter bank on the embedded end, load the state vector, assign the covariance matrix to each filter model and configure the model transition probability matrix to form a parallel filter calculation structure. S3. Based on the short window detection queue, the parallel filtering calculation structure performs synchronous operation, predicts the trend of detection value change according to the state vector and covariance matrix, and updates the error estimation state according to the prediction deviation to form the error estimation result and model residual result. S4. Based on the model residual results, the Gaussian residual likelihood evaluation method is used to match and calculate the residual amplitude and residual dispersion. Combined with the model transition probability matrix, the model probability weights of the previous sampling period are recursively pushed to the current sampling period to adjust the current probability weights of each filtering model. S5. Based on the current probability weight, perform posterior re-estimation on the error estimation result, and perform residual gating in combination with the model residual result. Based on the gated error estimation result, perform bias compensation and disturbance compensation on the original detection values ​​in the short window detection queue to form water quality detection results. S6. Collect feedback data of water quality test results and incrementally update the error compensation parameters of each filtering model using the least squares method.

[0024] In this embodiment, the preprocessing specifically includes: configuring a unified sampling time stamp for multi-source water quality detection data on the embedded end, wherein the embedded end is a local computing environment set on the water quality detection equipment side and configured with a queue buffer area and a filtering operation area; The multi-source data are periodically aligned based on a unified sampling time scale, and the validity of the aligned multi-source data is screened based on the range boundary and the difference between adjacent samples. Valid sampled data is written to a queue cache according to a sliding window, and the sampling order within the window is indexed by a time stamp to form a short-window detection queue containing detection values, auxiliary status values, and sampling time stamps. The detection values ​​are the water quality parameter measurements output by the water quality detection equipment at the corresponding sampling time. The auxiliary status values ​​are sensor temperature values, power supply voltage values, probe response time values, or equipment running time values ​​that are collected synchronously with the detection values ​​and used to characterize the detection process status. The sampling time stamp is the time index configured by the embedded terminal for the detection values ​​and auxiliary status values ​​according to a unified sampling period.

[0025] In this embodiment, the interactive multi-model Kalman filter bank includes a steady-state noise filtering model, a slow-varying drift filtering model, and a transient disturbance filtering model. Among them, the steady-state noise filtering model is used to characterize the random fluctuation error of the detected value under the stable sampling state, the slow drift filtering model is used to characterize the gradual offset error of the detected value with the continuous sampling period, and the transient disturbance filtering model is used to characterize the sudden deviation error of the detected value in the short window detection queue. The state vector records the error estimation state of each filter model in the current sampling period, the covariance matrix records the dispersion of the error estimation state, the model transition probability matrix records the switching probability of each filter model between adjacent sampling periods, and the current probability weight represents the weight of the error estimation result of each filter model in the water quality detection error correction.

[0026] In this embodiment, S2 specifically includes: S21. On the embedded end, a filtering period is established based on the sampling time of the short window detection queue, and the steady-state noise filtering model, the slow drift filtering model, and the transient disturbance filtering model are allocated to the parallel filtering channel. The parallel filtering channel is the calculation path in the embedded end that runs each filtering model according to the same filtering period. It is used to keep each filtering model performing state initialization, parameter calling, and result caching under the same sampling time. S22. Based on the continuous change of the detected value and the change of the auxiliary state value in the short window detection queue, load a state vector for each filter model, wherein the state vector includes a detected value estimation term, an error offset term, and a change trend term. S23. Based on the degree of dispersion and continuous offset of the detected values ​​in the short window detection queue, assign covariance matrix values ​​to each filtering model, and configure the corresponding covariance value ranges based on the steady-state noise filtering model, the slow drift filtering model, and the transient disturbance filtering model. S24. Based on each filtering model, configure the model transition probability matrix according to the switching relationship between adjacent sampling periods, and bind the state vector, covariance matrix and model transition probability matrix to the corresponding filtering model to form a parallel filtering calculation structure.

[0027] In this embodiment, S3 specifically includes: S31. Synchronously trigger each parallel filtering channel according to the sampling time scale in the short window detection queue, and call the state vector, state transition matrix and covariance matrix of each filtering model within the same sampling period. The state transition matrix is ​​the matrix in each filtering model used to describe the state transmission relationship of the detection value estimation term, error offset term and change trend term within the same filtering period. S32. Each filtering model performs state prediction on the detection value estimation term, error offset term, and trend term in the state vector based on the state transition matrix, and uses the predicted detection value estimation term as the predicted detection value for the current sampling period. Specifically, this includes: Based on the sampling time interval between the current sampling period and the previous sampling period, the state transition matrix of each filter model is discretized and configured using the zero-order state-space discretization method to determine the state transfer relationship between the detection value estimation term, the error offset term, and the trend term. Based on the discretized state transition matrix, the state vector of the previous sampling period is pushed forward, the change corresponding to the trend term is incorporated into the detection value estimation term, and the offset corresponding to the error offset term is incorporated into the detection value estimation term, forming the predicted state vector of the current sampling period. Based on the error type corresponding to each filtering model, model constraint processing is performed on the error offset term and the trend term in the predicted state vector. The steady-state noise filtering model constrains the short-window accumulation of the trend term, the slow drift filtering model constrains the continuous change of the error offset term, and the transient disturbance filtering model constrains the short-time response of the trend term. Extract the detection value estimate from the predicted state vector after model constraints, and use the extracted detection value estimate as the predicted detection value for the current sampling period; S33. Perform a difference calculation between the predicted detection value and the current detection value in the short window detection queue to form the prediction bias, and calculate the Kalman gain corresponding to each filtering model based on the covariance matrix and the prediction bias. S34. Based on Kalman gain, the prediction bias is allocated to the error offset term and the trend term in the state vector, and the covariance matrix is ​​updated using the Joseph stabilized covariance update method to form the error estimation results and model residual results corresponding to each filtering model.

[0028] In this embodiment, S34 specifically includes: S341. Perform residual projection on the prediction bias based on Kalman gain, allocate the prediction bias to the error offset term and the trend term in the state vector, and update the detection offset of the current sampling period according to the allocated error offset term. S342. Correct the direction of change of the detected values ​​in the short window detection queue according to the assigned trend term, and write the detection offset and the direction of change into the state vector to form the error estimation results corresponding to each filtering model. S343. The Joseph stable covariance update method is used to perform a stable update on the covariance matrix, and the updated covariance matrix is ​​subjected to positive definite constraints through Cholesky decomposition to obtain a stable covariance matrix. S344. Construct the model residual results based on the prediction bias and the stable covariance matrix, wherein the model residual results include the residual magnitude and the residual dispersion.

[0029] In this embodiment, S4 specifically includes: S41. Based on the model residual results of each filtering model, the Mahalanobis distance metric is used to jointly measure the residual magnitude and residual dispersion to obtain the residual matching distance for each filtering model, specifically including: The prediction bias and covariance matrix are extracted from the model residual results corresponding to each filtering model. The absolute deviation of the prediction bias is used as the residual amplitude, and the covariance component corresponding to the estimated term of the detected value is extracted from the covariance matrix as the residual dispersion. Based on the degree of residual dispersion, residual scaling constraints are constructed, and covariance weighting is performed on the residual amplitude to convert the residual amplitudes corresponding to different filtering models into residual metrics under the same comparable scale. The Mahalanobis distance metric is used to calculate the distance of the residual metric to obtain the residual matching distance of each filtering model in the current sampling period. The matching order of each filtering model and the short window detection queue is marked according to the magnitude of the residual matching distance, and the residual matching distance is used as the input of the Gaussian residual likelihood evaluation method. S42. The Gaussian residual likelihood evaluation method is used to perform likelihood mapping on the residual matching distance, converting the residual matching distance corresponding to each filtering model into the model residual likelihood value. Specifically, this includes: Input the residual matching distance corresponding to each filtering model into the Gaussian kernel function, and configure the scale parameter of the Gaussian kernel function according to the distribution range of the residual matching distance in the short window detection queue; A Gaussian kernel function is used to perform a squared decay operation on the residual matching distance, mapping the residual matching distance to the initial likelihood response value of the corresponding filter model; Embedded fixed-point quantization is performed on the initial likelihood response value, and the quantized initial likelihood response value is truncated according to the preset lower likelihood limit to obtain the restricted likelihood response value. The restricted likelihood response values ​​are sequentially encapsulated according to the model identifier of each filtering model to form the model residual likelihood values ​​corresponding to the steady-state noise filtering model, the slow drift filtering model, and the transient disturbance filtering model. S43. Using the forward probability recursion method, perform matrix recursion operation on the model probability weights and model transition probability matrix of the previous sampling period, and allocate the probability weights of each filter model in the previous sampling period to the current sampling period to obtain the prior probability weights of each filter model. S44. Multiply the model residual likelihood value with the prior probability weights to correct the model, and then reallocate the current probability weights of the steady-state noise filtering model, the slow drift filtering model, and the transient disturbance filtering model according to the product correction result.

[0030] In this embodiment, S43 specifically includes: S431. Based on the row and column correspondence of each filtering model in the model transition probability matrix, determine the transition path from each filtering model in the previous sampling period to each filtering model in the current sampling period. S432. Multiply the model probability weights of each filter model in the previous sampling period with the corresponding switching probabilities along the transfer path to form the probability components that each filter model in the previous sampling period transmits to each filter model in the current sampling period. S433. Aggregate the probability components in the same column according to the target filtering model of the current sampling period to obtain the prior probability weights corresponding to each filtering model. S434. Apply probability boundary constraints to the prior probability weights, configure the prior probability weights below the minimum probability threshold as lower limit weights, and perform proportional callbacks on the remaining prior probability weights to form prior probability weights for the redistribution of the current probability weights.

[0031] In this embodiment, S5 specifically includes: S51. Based on the current probability weights of each filtering model, perform posterior re-estimation of the error estimation results, rearrange the error estimation results of each filtering model according to the current probability weights, and configure the corresponding posterior participation coefficients for each error estimation result. S52. Based on the residual amplitude and residual dispersion in the model residual results, the chi-square gating method is used to gate each error estimation result, and the posterior participation coefficient is corrected according to the gating result to obtain the gated error estimation result, specifically including: Based on the residual magnitude and residual dispersion in the model residual results, the residual square ratio is constructed. The ratio of the square of the residual magnitude to the residual dispersion is calculated to obtain the chi-square gated statistic corresponding to each error estimation result. The degrees of freedom are determined based on the number of state terms involved in error estimation in the state vector, and the chi-square gate threshold is called from the preset chi-square threshold table according to the degrees of freedom. The degree of freedom is the number of state terms involved in the construction of the chi-square gate statistic, which is used to limit the index position of the chi-square gate threshold in the preset chi-square threshold table. The chi-square gating statistic is compared with the chi-square gating threshold. For error estimation results that do not exceed the chi-square gating threshold, the posterior participation coefficient is retained. For error estimation results that exceed the chi-square gating threshold, gating attenuation is performed according to the excess ratio. Based on the posterior participation coefficient after gating attenuation, the error estimation results are proportionally corrected to form the gating error estimation results that participate in bias compensation and disturbance compensation. S53. Based on the error estimation results after gating, construct the bias compensation amount and the disturbance compensation amount. The bias compensation amount is constructed with the error estimation results corresponding to the slow drift filter model, and the disturbance compensation amount is constructed with the error estimation results corresponding to the transient disturbance filter model. S54. Perform baseline offset correction on the original detection values ​​in the short window detection queue according to the offset compensation amount, and perform short window disturbance cancellation on the detection values ​​after baseline offset correction according to the disturbance compensation amount to form water quality detection results.

[0032] In this embodiment, S6 specifically includes: S61. Collect feedback data of water quality test results and match the feedback data with the water quality test results according to the sampling time scale to form feedback residuals, wherein the feedback data is the water quality test reference value after verification or the calibration test value under the same sampling period. S62. Construct least squares update samples based on feedback residuals, where least squares update samples include feedback residuals, bias compensation amount, disturbance compensation amount, and current probability weights; S63. Using the recursive least squares method with a forgetting factor, the bias compensation coefficient and disturbance compensation coefficient in each filtering model are incrementally estimated, and the update ratio of each filtering model participating in the incremental estimation is limited according to the current probability weight. S64. Update the error compensation parameters of the corresponding filtering model based on the incremental estimation results to form the filtering parameters for bias compensation and disturbance compensation in the next sampling period.

[0033] Example 1: To verify the feasibility of this invention in practice, it was applied to an error correction scenario for an online water quality monitoring terminal. This terminal is installed in a continuous water sample monitoring chain. During the monitoring process, water quality parameters need to be continuously sampled. However, after prolonged operation, the detected values ​​are affected by probe response hysteresis, sensor zero-point drift, short-term water sample disturbances, and fluctuations in the monitoring chain, causing some detection results to show continuous shifts or instantaneous jumps. If only a fixed compensation coefficient is used for correction, short-term disturbances may be mistaken for long-term drift, or the error caused by slow sensor drift may not be corrected in time, affecting the stability of the water quality monitoring results.

[0034] In this scenario, an embedded terminal is configured on the water quality testing equipment side. This embedded terminal receives test values, auxiliary status values, and sampling timestamps, and performs periodic alignment, validity screening, and sliding window caching on the multi-source data to form a short-window detection queue. Each window in the short-window detection queue contains continuously sampled test values, auxiliary status values ​​corresponding to the equipment's operating status, and a unified sampling timestamp, used for subsequent filtering estimation. The embedded terminal initializes an interactive multi-model Kalman filter bank based on the short-window detection queue, setting up a steady-state noise filtering model, a slowly varying drift filtering model, and a transient disturbance filtering model, enabling the three filtering models to run in parallel within the same sampling period.

[0035] During the detection process, each filtering model predicts the trend of the current detected value based on the state vector and covariance matrix, and compares the predicted detected value with the current detected value to form error estimation results and model residual results. For cases where the detected value slowly rises over a long period, the residual matching distance corresponding to the slow drift filtering model decreases, and the current probability weight increases. For cases where the detected value suddenly rises and then falls back in a short period, the residual likelihood value of the transient disturbance filtering model increases, and the embedded end adjusts the current probability weight to ensure that the transient disturbance does not directly bias the long-term drift parameters.

[0036] Subsequently, the embedded device performs a posteriori reestimation of the error estimation results based on the current probability weights, and performs chi-square gating in combination with the model residual results. Error estimation results exceeding the gating threshold are proportionally suppressed, and bias compensation and disturbance compensation are performed on the original detection values ​​to form the corrected water quality detection results.

[0037] 120 effective sampling windows were selected from the continuous detection samples for comparison, including 42 steady-state noise windows, 51 slowly varying drift windows, and 27 transient disturbance windows. Without this invention, the average absolute error of the original detection values ​​was 0.186, the maximum instantaneous deviation reached 0.512, and the average offset of the continuous drift segment was 0.243. After adopting this invention, the average absolute error decreased to 0.071, a reduction of approximately 61.8% compared to before correction, the maximum instantaneous deviation decreased to 0.219, and the average offset of the continuous drift segment decreased to 0.086.

[0038] For the steady-state noise window, the corrected error is mainly concentrated between 0.02 and 0.05; for the slowly drifting window, the corrected average error decreases from 0.238 to 0.074; for the transient disturbance window, the maximum deviation decreases from 0.512 to 0.219, and the impact range of sudden deviations is shortened from 4 to 6 consecutive sampling points to 1 to 2 sampling points. The average correction time for a single short window on the embedded end is 8.6ms, and the maximum time is 13.4ms, which can meet the local real-time correction requirements.

[0039] Table 1 Comparison of Water Quality Testing Error Correction Effects

[0040] As shown in Table 1, the present invention can effectively correct the detected values ​​under different error types. In sample segments A2 and A4, the slow drift error decreased from 0.25 to 0.06 and 0.07, respectively, indicating that the bias compensation can reduce continuous offset. In sample segment A3, the transient disturbance error decreased from 0.51 to 0.22, indicating that chi-square gating and disturbance compensation can suppress sudden anomalies. In sample segments A1 and A5, the steady-state noise error was controlled within 0.03. This embodiment demonstrates that the present invention can complete the localized identification, classification estimation, and dynamic correction of water quality detection errors on the embedded end, exhibiting good real-time performance, stability, and continuous adaptability.

[0041] The above description is only a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any equivalent substitutions or modifications made by those skilled in the art within the scope of the technology disclosed in the present invention, based on the technical solution and inventive concept of the present invention, should be covered within the scope of protection of the present invention.

Claims

1. A water quality detection error correction method based on embedded computing, characterized in that, Includes the following steps: S1. Acquire multi-source water quality testing data and preprocess it to form a short-window testing queue; S2. Initialize the interactive multi-model Kalman filter bank on the embedded end, load the state vector, assign the covariance matrix to each filter model and configure the model transition probability matrix to form a parallel filter calculation structure. S3. Based on the short window detection queue, the parallel filtering calculation structure performs synchronous operation, predicts the trend of detection value change according to the state vector and covariance matrix, and updates the error estimation state according to the prediction deviation to form the error estimation result and model residual result. S4. Based on the model residual results, the Gaussian residual likelihood evaluation method is used to match and calculate the residual amplitude and residual dispersion. Combined with the model transition probability matrix, the model probability weights of the previous sampling period are recursively pushed to the current sampling period to adjust the current probability weights of each filtering model. S5. Based on the current probability weight, perform posterior re-estimation on the error estimation result, and perform residual gating in combination with the model residual result. Based on the gated error estimation result, perform bias compensation and disturbance compensation on the original detection values ​​in the short window detection queue to form water quality detection results. S6. Collect feedback data of water quality test results and incrementally update the error compensation parameters of each filtering model using the least squares method; The interactive multi-model Kalman filter bank includes a steady-state noise filtering model, a slow-varying drift filtering model, and a transient disturbance filtering model. Among them, the steady-state noise filtering model is used to characterize the random fluctuation error of the detected value under the stable sampling state, the slow drift filtering model is used to characterize the gradual offset error of the detected value with the continuous sampling period, and the transient disturbance filtering model is used to characterize the sudden deviation error of the detected value in the short window detection queue. The state vector is used to record the error estimation state of each filter model in the current sampling period. The covariance matrix is ​​used to record the dispersion of the error estimation state. The model transition probability matrix is ​​used to record the switching probability of each filter model between adjacent sampling periods. The current probability weight is used to represent the weight of the error estimation result corresponding to each filter model in the water quality detection error correction.

2. The water quality detection error correction method based on embedded computing according to claim 1, characterized in that, The preprocessing specifically includes: configuring a unified sampling time stamp for multi-source water quality detection data on an embedded device, wherein the embedded device is a local computing environment set on the side of the water quality detection equipment and configured with a queue buffer area and a filtering operation area; The multi-source data are periodically aligned based on a unified sampling time scale, and the validity of the aligned multi-source data is screened based on the range boundary and the difference between adjacent samples. Valid sampled data is written into a queue cache according to a sliding window, and the sampling order within the window is indexed by a time stamp to form a short-window detection queue containing detection values, auxiliary status values, and sampling time stamps. The detection values ​​are the water quality parameter measurement values ​​output by the water quality detection equipment at the corresponding sampling time. The auxiliary status values ​​are the sensor temperature value, power supply voltage value, probe response time value, or equipment running time value, which are collected synchronously with the detection values ​​and used to characterize the detection process status. The sampling time stamp is the time index configured by the embedded terminal for the detection values ​​and auxiliary status values ​​according to a unified sampling period.

3. The water quality detection error correction method based on embedded computing according to claim 1, characterized in that, S2 specifically includes: S21. Establish the filtering period on the embedded end based on the sampling time of the short window detection queue, and allocate the steady-state noise filtering model, the slow drift filtering model and the transient disturbance filtering model to the parallel filtering channel. S22. Based on the continuous change of the detected value and the change of the auxiliary state value in the short window detection queue, load a state vector for each filter model, wherein the state vector includes a detected value estimation term, an error offset term, and a change trend term. S23. Based on the degree of dispersion and continuous offset of the detected values ​​in the short window detection queue, assign covariance matrix values ​​to each filtering model, and configure the corresponding covariance value ranges based on the steady-state noise filtering model, the slow drift filtering model, and the transient disturbance filtering model. S24. Based on each filtering model, configure the model transition probability matrix according to the switching relationship between adjacent sampling periods, and bind the state vector, covariance matrix and model transition probability matrix to the corresponding filtering model to form a parallel filtering calculation structure.

4. The water quality detection error correction method based on embedded computing according to claim 1, characterized in that, S3 specifically includes: S31. Synchronously trigger each parallel filtering channel according to the sampling time scale in the short window detection queue, and call the state vector, state transition matrix and covariance matrix of each filtering model within the same sampling period. The state transition matrix is ​​a matrix in each filtering model used to describe the state transmission relationship of the detection value estimation term, error offset term and change trend term within the same filtering period. S32. Each filtering model performs state prediction on the detection value estimation term, error offset term, and trend term in the state vector based on the state transition matrix, and uses the predicted detection value estimation term as the predicted detection value for the current sampling period. S33. Perform a difference calculation between the predicted detection value and the current detection value in the short window detection queue to form the prediction bias, and calculate the Kalman gain corresponding to each filtering model based on the covariance matrix and the prediction bias. S34. Based on Kalman gain, the prediction bias is allocated to the error offset term and the trend term in the state vector, and the covariance matrix is ​​updated using the Joseph stabilized covariance update method to form the error estimation results and model residual results corresponding to each filtering model.

5. The water quality detection error correction method based on embedded computing according to claim 4, characterized in that, S34 specifically includes: S341. Perform residual projection on the prediction bias based on Kalman gain, allocate the prediction bias to the error offset term and the trend term in the state vector, and update the detection offset of the current sampling period according to the allocated error offset term. S342. Based on the assigned trend term, correct the direction of change of the detected values ​​in the short window detection queue, and write the detection offset and the direction of change into the state vector to form the error estimation results corresponding to each filtering model. S343. The Joseph stable covariance update method is used to perform a stable update on the covariance matrix, and the updated covariance matrix is ​​subjected to positive definite constraints through Cholesky decomposition to obtain a stable covariance matrix. S344. Construct model residual results based on prediction bias and stable covariance matrix. The model residual results include residual magnitude and residual dispersion.

6. The water quality detection error correction method based on embedded computing according to claim 1, characterized in that, S4 specifically includes: S41. Based on the model residual results of each filtering model, the Mahalanobis distance metric is used to jointly measure the residual magnitude and residual dispersion to obtain the residual matching distance corresponding to each filtering model. S42. The Gaussian residual likelihood evaluation method is used to perform likelihood mapping on the residual matching distance, converting the residual matching distance corresponding to each filtering model into the model residual likelihood value. Specifically, this includes: Input the residual matching distance corresponding to each filtering model into the Gaussian kernel function, and configure the scale parameter of the Gaussian kernel function according to the distribution range of the residual matching distance in the short window detection queue; A Gaussian kernel function is used to perform a squared decay operation on the residual matching distance, mapping the residual matching distance to the initial likelihood response value of the corresponding filter model; Embedded fixed-point quantization is performed on the initial likelihood response value, and the quantized initial likelihood response value is truncated according to the preset lower likelihood limit to obtain the restricted likelihood response value. The restricted likelihood response values ​​are sequentially encapsulated according to the model identifier of each filtering model to form the model residual likelihood values ​​corresponding to the steady-state noise filtering model, the slow drift filtering model, and the transient disturbance filtering model. S43. Using the forward probability recursion method, perform matrix recursion operation on the model probability weights and model transition probability matrix of the previous sampling period, and allocate the probability weights of each filter model in the previous sampling period to the current sampling period to obtain the prior probability weights of each filter model. S44. Multiply the model residual likelihood value with the prior probability weights to correct the model, and then reallocate the current probability weights of the steady-state noise filtering model, the slow drift filtering model, and the transient disturbance filtering model according to the product correction result.

7. The water quality detection error correction method based on embedded computing according to claim 6, characterized in that, Specifically, S43 includes: S431. Based on the row and column correspondence of each filtering model in the model transition probability matrix, determine the transition path from each filtering model in the previous sampling period to each filtering model in the current sampling period. S432. Multiply the model probability weights of each filter model in the previous sampling period with the corresponding switching probabilities along the transfer path to form the probability components that each filter model in the previous sampling period passes to each filter model in the current sampling period. S433. Aggregate the probability components in the same column according to the target filtering model of the current sampling period to obtain the prior probability weights corresponding to each filtering model. S434. Apply probability boundary constraints to the prior probability weights, configure the prior probability weights below the minimum probability threshold as lower limit weights, and perform proportional callbacks on the remaining prior probability weights to form prior probability weights for the redistribution of the current probability weights.

8. The water quality detection error correction method based on embedded computing according to claim 1, characterized in that, S5 specifically includes: S51. Based on the current probability weights of each filtering model, perform posterior re-estimation of the error estimation results, rearrange the error estimation results of each filtering model according to the current probability weights, and configure the corresponding posterior participation coefficients for each error estimation result. S52. Based on the residual amplitude and residual dispersion in the model residual results, the chi-square gating method is used to gating the error estimation results, and the posterior participation coefficient is corrected according to the gating judgment results to obtain the gating error estimation results. S53. Based on the error estimation results after gating, construct the bias compensation amount and the disturbance compensation amount. The bias compensation amount is constructed with the error estimation results corresponding to the slow drift filter model, and the disturbance compensation amount is constructed with the error estimation results corresponding to the transient disturbance filter model. S54. Perform baseline offset correction on the original detection values ​​in the short window detection queue according to the offset compensation amount, and perform short window disturbance cancellation on the detection values ​​after baseline offset correction according to the disturbance compensation amount to form water quality detection results.

9. The water quality detection error correction method based on embedded computing according to claim 1, characterized in that, S6 specifically includes: S61. Collect feedback data of water quality test results, and match the feedback data with the water quality test results according to the sampling time scale to form feedback residuals. The feedback data is the water quality test reference value after verification or the calibration test value under the same sampling period. S62. Construct a least squares update sample based on the feedback residual, wherein the least squares update sample includes the feedback residual, the bias compensation amount, the disturbance compensation amount, and the current probability weight; S63. Using the recursive least squares method with a forgetting factor, the bias compensation coefficient and disturbance compensation coefficient in each filtering model are incrementally estimated, and the update ratio of each filtering model participating in the incremental estimation is limited according to the current probability weight. S64. Update the error compensation parameters of the corresponding filtering model based on the incremental estimation results to form the filtering parameters for bias compensation and disturbance compensation in the next sampling period.

Citation Information

Patent Citations

  • Clock synchronization method based on adaptive dynamic adjustment Kalman filter

    CN121217132A

  • Coal mine elevator cage attitude estimation method based on improved extended Kalman filtering

    CN121252746A