A method for online intelligent detection and dynamic compensation of pH for high-concentration organic solvents

By constructing a five-dimensional feature vector and a nonlinear regression model, the problems of accuracy and response lag in pH detection in high-concentration organic solvent systems were solved, achieving high-precision and safe online detection and dynamic compensation, adapting to changes in reaction conditions, and reducing system cost and complexity.

CN122084724BActive Publication Date: 2026-06-30ANHUI ZHONGKE WEIDE DIGITAL TECH CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
ANHUI ZHONGKE WEIDE DIGITAL TECH CO LTD
Filing Date
2026-04-23
Publication Date
2026-06-30

Smart Images

  • Figure CN122084724B_ABST
    Figure CN122084724B_ABST
Patent Text Reader

Abstract

This invention relates to the field of industrial automation testing technology, specifically disclosing a method for online intelligent detection and dynamic compensation of pH for high-concentration organic solvents. Based on only collecting the original pH reading and real-time temperature, the method reconstructs the solvent concentration, dielectric constant, and dynamic response factor, forming a five-dimensional feature vector with the aforementioned two measured values. This feature vector is input into a support vector regression or online sequential extreme learning machine model that dynamically switches according to the sample size, outputting the corrected true pH value to replace the original reading in closed-loop feedback control. Simultaneously, an incremental learning mechanism is built-in. When the residual between the model's predicted value and the offline test value exceeds the allowable range, the model parameters are automatically updated with new samples. Furthermore, by performing a cumulative sum test on the corrected residual sequence, the method actively senses electrode aging drift, requests offline testing in a targeted manner, and updates the model parameters online using a recursive least squares algorithm, achieving pH measurement without the need for additional hardware environmental sensing.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of industrial automation testing technology, and more specifically, to a method for online intelligent detection and dynamic compensation of pH for high-concentration organic solvents. Background Technology

[0002] In the pharmaceutical, fine chemical, and new materials industries, there are numerous non-aqueous reaction systems that use organic solvents such as alcohols and ketones as reaction media. pH value is one of the most critical process control parameters in these systems, directly affecting reaction selectivity, product purity, and production safety. Therefore, real-time and accurate online monitoring of pH value is of great significance.

[0003] However, the measurement principle of conventional pH composite electrodes (glass electrodes) is based on the Nernst equation, which requires the glass sensing membrane to maintain an intact hydrated gel layer and the hydrogen ion activity coefficient in the system to conform to the theoretical expectations of aqueous solutions. When the concentration of organic solvent increases, the above premises are simultaneously violated: the dielectric constant of the solution decreases significantly with increasing organic solvent concentration, the hydrogen ion activity coefficient changes, and the linear response relationship of the Nernst equation fails; at the same time, the hydrated layer on the surface of the glass membrane is dehydrated and damaged by the organic solvent, the electrode calibration slope decreases, and a significant nonlinear deviation occurs between the measured reading and the true pH value.

[0004] In low-temperature or high-viscosity non-aqueous systems, the ion diffusion rate at the reference electrode liquid interface decreases significantly, extending the time required for the electrode to reach electrochemical equilibrium from several seconds in aqueous solutions to several minutes. Existing instruments only display instantaneous readings at the time of acquisition and cannot predict steady-state pH values. This leads to severe response lag and continuous oscillations in automatic control systems that rely on pH feedback, which is particularly prominent in processes with rapidly changing reaction conditions.

[0005] Due to the lack of reliable online detection methods, existing production scenarios typically rely on manual, timed sampling and offline pH test strip readings. This method has poor accuracy and limited frequency, making continuous real-time monitoring impossible. Furthermore, operators must directly contact high concentrations of toxic and harmful organic solvents, posing significant occupational health and safety risks.

[0006] Therefore, existing technologies cannot simultaneously meet the basic requirements of sufficient accuracy, timely response, continuous online detection, and operational safety in high-concentration organic solvent systems, and a new method that can overcome the above-mentioned defects is urgently needed. Summary of the Invention

[0007] To overcome the aforementioned deficiencies of existing technologies, this invention provides an online intelligent detection and dynamic compensation method for pH of high-concentration organic solvents. The method reconstructs solvent concentration, dielectric constant, and dynamic response factor through software algorithms, constructs a five-dimensional feature vector with the original pH reading and real-time temperature, corrects the pH value through a dual-path nonlinear regression model, and continuously updates the model with an incremental learning mechanism. This solves the problems of large measurement deviations and control inaccuracies caused by the failure of the Nernst equation and electrode response lag in high-concentration organic solvent systems.

[0008] To achieve the above objectives, the present invention provides the following technical solution:

[0009] A method for online intelligent detection and dynamic compensation of pH for high-concentration organic solvents includes the following steps:

[0010] Step S1: Collect the raw pH reading output by the pH transmitter and the real-time temperature output by the temperature sensor;

[0011] Step S2: Based on the original pH reading and real-time temperature, the solvent concentration, dielectric constant, and dynamic response factor are reconstructed through software algorithms to build a five-dimensional feature vector containing the original pH reading, real-time temperature, solvent concentration, dielectric constant, and dynamic response factor.

[0012] Step S3: Input the five-dimensional feature vector into the nonlinear regression function. The nonlinear regression function outputs the corrected true pH value based on the relationship between the historical effective sample size and the preset threshold using a dual-path strategy.

[0013] Step S4: The corrected true pH value is used instead of the original pH reading to participate in PID control, controlling the start-up, shutdown and flow rate of the acid metering pump or the alkali metering pump.

[0014] Step S5: Receive the true value of the offline test, calculate the prediction residual between the predicted value of the nonlinear regression function for the current sample and the true value of the offline test, and when the absolute value of the prediction residual exceeds the preset allowable range, trigger the incremental learning mechanism to fine-tune the parameters of the nonlinear regression function online.

[0015] Step S6: Using the difference between the corrected true pH value and the original pH reading in each measurement as the correction residual, perform a cumulative sum test on the correction residual sequence. When the cumulative sum statistic is greater than the drift detection threshold, select the sampling time with the largest absolute value of the correction residual deviating from the benchmark mean within the backtracking window composed of a preset number of sampling points before the triggering time as the active query time, request offline testing of the sample corresponding to the active query time, and update the output weight matrix of the online sequential extreme learning machine with the obtained offline test true value through the recursive least squares algorithm.

[0016] As a further aspect of the present invention, step S2, the construction of the five-dimensional feature vector includes the following steps:

[0017] Step S21: The raw pH reading calculated based on the conventional aqueous solution model output by the pH transmitter and the real-time temperature measured by the temperature sensor are directly obtained as measured physical quantities.

[0018] Step S22: Read the current process formula or operator preset value in the DCS system through the communication interface to obtain the solvent concentration of the current reaction system;

[0019] Step S23: Call the organic solvent dielectric property database built into the embedded controller, and query the dielectric constant of the current reaction system online according to the real-time temperature and solvent concentration. The organic solvent dielectric property database stores the dielectric constants of typical organic solvents under different solvent concentrations and different temperature conditions.

[0020] Step S24: Perform first-order difference operation or fluctuation variance operation on the original pH reading sequence within the sliding time window, and use the operation result as a dynamic response factor; the first-order difference value is the difference between the original pH readings at adjacent sampling times within the sliding time window, and the fluctuation variance value is the statistical variance of the original pH reading sequence within the sliding time window.

[0021] Step S25: Construct a five-dimensional feature vector ,in, This is the raw pH reading. Solvent concentration, For real-time temperature, Where is the dielectric constant. It is a dynamic response factor.

[0022] As a further aspect of the present invention, in step S3, the dual-path strategy is as follows: when the number of historical valid samples is less than a preset threshold, the nonlinear regression function adopts a support vector regression model; when the number of historical valid samples is greater than or equal to the preset threshold, the nonlinear regression function adopts an online sequential extreme learning machine. The online sequential extreme learning machine initializes parameters using a batch-initialized sample set, the activation function is the Sigmoid function, the hidden layer weights and biases remain fixed after initialization, and the initial values ​​of the output weight matrix and inverse autocorrelation matrix are determined by the batch-initialized sample set. When receiving new labeled samples, the output weight matrix is ​​updated only through a recursive least squares algorithm. The corrected true pH value is calculated using the following formula:

[0023] ,

[0024] in, This is the corrected true pH value. It is a nonlinear regression function. These are the model parameters for the nonlinear regression function. Online adjustments are made through the incremental learning mechanism in step S5 or the recursive least squares update in step S6.

[0025] As a further aspect of the present invention, in step S6, the mean of the corrected residual statistics during the stable operation phase after the deployment of the online sequential extreme learning machine is used as the benchmark mean, 0.5 times the standard deviation of the corrected residuals during the stable operation phase is used as the allowable relaxation amount, and 5 times the standard deviation of the residuals is used as the drift detection threshold. The cumulative sum control chart algorithm is used to calculate the cumulative sum statistic step by step on the corrected residual sequence, with an initial value of zero. When the cumulative sum statistic is greater than the drift detection threshold, an active query is triggered.

[0026] As a further aspect of the present invention, in step S6, the hidden layer output vector is calculated using the five-dimensional feature vector corresponding to the active query time, and the single-sample parameter update is completed using the recursive least squares method: the gain vector is calculated based on the current inverse autocorrelation matrix and the hidden layer output vector, and the inverse autocorrelation matrix and the output weight matrix are updated sequentially. After receiving the offline verification true value, the single-step correction of the output weight matrix is ​​completed.

[0027] As a further aspect of the present invention, in step S4, the PID controller uses the deviation between the corrected actual pH value and the preset process setting value as the control input, and controls the start-up, shutdown and flow rate of the acid metering pump or the alkali metering pump according to the magnitude and direction of the deviation.

[0028] As a further aspect of the present invention, in step S5, the incremental learning mechanism includes the following steps:

[0029] Step S51: Calculate the prediction residual between the predicted value of the nonlinear regression function for the current sample and the true value of the offline test.

[0030] Step S52: Determine whether the absolute value of the predicted residual exceeds the preset allowable range;

[0031] Step S53: When the absolute value of the predicted residual exceeds the preset allowable range, update the training set of the nonlinear regression function with the current sample and fine-tune the parameters of the nonlinear regression function online.

[0032] Step S5 is triggered by passively received offline test data, and step S6 is triggered by the cumulative sum statistic exceeding the drift detection threshold. The two steps are executed independently for different trigger conditions, and the correction of the nonlinear regression function parameters does not interfere with each other.

[0033] As a further embodiment of the present invention, the pH transmitter and temperature sensor are integrated on the pH composite electrode installed in the detection container, and the nonlinear regression function is embedded in the embedded controller in the form of a software algorithm package. The embedded controller and the PLC controller work together to implement steps S1 to S6.

[0034] As a further aspect of the present invention, after step S4 is completed, the PLC controller controls the cleaning water pump to clean the pH composite electrode. After cleaning, the pH composite electrode is immersed in the buffer solution for maintenance. Steps S5 and S6 are executed during the process of cleaning and buffer solution maintenance of the pH composite electrode by the PLC controller.

[0035] As a further aspect of the present invention, in step S6, the drift detection threshold and the allowable relaxation amount are set such that, under the condition that the electrode characteristics are stable, the expected sampling point interval where the cumulative sum and statistics exceed the drift detection threshold is not less than 2000 sampling points.

[0036] Compared with existing technologies, the beneficial effects of this invention's method for online intelligent detection and dynamic compensation of pH for high-concentration organic solvents are as follows:

[0037] This invention reconstructs a five-dimensional feature vector, including solvent concentration, dielectric constant, and dynamic response factor, using software to acquire only the raw pH reading and real-time temperature. This explicitly incorporates key physicochemical parameters affecting pH measurement accuracy in organic solvent systems into the model input. Compared to existing technologies that rely solely on a single pH reading for control, this invention eliminates the need for additional physical sensors, effectively capturing the impact of dielectric constant changes and electrode response hysteresis on measurement results, thus significantly reducing system hardware costs and installation complexity.

[0038] This invention employs a dual-path strategy based on historical sample size. When sample size is insufficient, a support vector regression model is used; when sample size is sufficient, it switches to an online sequential extreme learning machine (OS-ELM) model. This ensures high prediction accuracy during both the initial deployment and stable operation phases. Existing machine learning pH correction schemes typically use a single model structure, leading to large prediction errors during the cold start phase due to insufficient samples. This invention's dual-path switching strategy effectively solves this problem. Compared to static multilayer perceptrons, OS-ELM keeps its hidden layer parameters fixed after initialization, only updating the output weight matrix online using a recursive least squares algorithm. Each update does not require access to historical training data, resulting in low computational complexity and meeting the real-time computational constraints of industrial embedded controllers.

[0039] This invention features an incremental learning mechanism based on offline laboratory test results. When the residual between the model's predicted value and the laboratory test result exceeds a preset allowable range, the training set is automatically updated with the current samples, and the model parameters are fine-tuned online. Existing pH correction models, once deployed, have fixed parameters and cannot adapt to drift caused by changes in the reaction system's operating conditions. The adaptive update mechanism of this invention enables the model to continuously correct itself, ensuring long-term operational accuracy.

[0040] This invention features an active electrode drift sensing and targeted compensation mechanism based on cumulative sum testing. By continuously monitoring the mean shift of the correction residual sequence, an alarm is automatically triggered upon drift occurrence. A maximum deviation active query strategy is used to selectively request offline testing at the moment with the most information, and a recursive least squares algorithm is employed to complete the single-sample online update of the OS-ELM output weight matrix. Compared to the passive waiting for laboratory data feedback in existing technologies, this invention can actively sense electrode aging drift and achieve targeted compensation with minimal annotation, effectively suppressing the decline in correction accuracy caused by long-term electrode use without increasing the frequency of offline testing. Attached Figure Description

[0041] Figure 1 This is a schematic flowchart of a method for online intelligent detection and dynamic compensation of pH for high-concentration organic solvents according to the present invention. Detailed Implementation

[0042] The technical solutions of this embodiment will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this invention, and not all embodiments. Based on the embodiments of this invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this invention.

[0043] Example 1

[0044] like Figure 1 As shown, this invention provides a method for online intelligent detection and dynamic compensation of pH in high-concentration organic solvents. This embodiment uses the fully automated pH measurement system for suspensions in a reaction vessel disclosed in the applicant's application number CN202210638112.4 as the hardware carrier. Relying on its bypass circulation detection architecture, it achieves accurate detection and control of pH values ​​in complex non-aqueous systems. The pH transmitter and temperature sensor are integrated on a pH composite electrode installed in a small detection container. The nonlinear regression function of this invention is embedded in the embedded controller as a software algorithm package. The embedded controller and the PLC controller work together to implement steps S1 to S6.

[0045] Step S1 involves acquiring the raw pH reading from the pH transmitter and the real-time temperature from the temperature sensor. Before the pH composite electrode comes into contact with the reaction solution, the PLC controller controls a pump to filter the reaction solution in the reactor through a filter head and inject it into the detection container until the liquid level in the detection container stabilizes and submerges the pH composite electrode. Simultaneously, the PLC controller controls a drain pump to return excess reaction solution from the detection container back to the reactor, creating a dynamic circulation of liquid between the reactor and the detection container. The filter head effectively removes suspended particles from the reaction solution, providing a clean and real-time updated bypass detection environment for the pH composite electrode, ensuring the representativeness and stability of subsequent data acquisition. Once the liquid level in the detection container stabilizes, the embedded controller acquires the raw pH reading from the pH transmitter and the real-time temperature from the temperature sensor, serving as the input for step S2. The raw pH reading is the initial value calculated and output by the pH transmitter based on a conventional aqueous solution model. In high-concentration organic solvent reaction systems, the introduction of organic solvents alters the hydrogen ion activity coefficient and damages the hydration layer on the glass electrode surface, which is essential for establishing the Nernst response. Under these conditions, the traditional linear Nernst equation fails, resulting in a significant nonlinear deviation between the initial pH reading and the actual pH value of the reaction system, making it unsuitable for direct PID control. Furthermore, in low-temperature or high-viscosity non-aqueous systems, the time required for the pH composite electrode to reach chemical equilibrium is significantly longer compared to aqueous solutions, leading to a dynamic response lag in the initial pH reading.

[0046] Step S2: The dynamic error correction module inside the embedded controller, based on the original pH reading and real-time temperature, reconstructs the solvent concentration, dielectric constant, and dynamic response factor through a software algorithm, constructing a five-dimensional feature vector containing the original pH reading, real-time temperature, solvent concentration, dielectric constant, and dynamic response factor. Specifically, the construction of the five-dimensional feature vector includes the following steps:

[0047] Step S21: The raw pH reading output by the pH transmitter and the real-time temperature measured by the temperature sensor are directly obtained as measured physical quantities. The two constitute the basic physical components in the five-dimensional feature vector, reflecting the directly observable state of the reaction system at the current moment.

[0048] In step S22, the embedded controller reads the current process formula or operator preset value from the DCS system via the communication interface to obtain the solvent concentration of the current reaction system. The solvent concentration is uniformly managed by the DCS system and is virtually reconstructed through communication reading, eliminating the need for additional concentration sensors in the detection loop.

[0049] In step S23, the embedded controller calls the built-in organic solvent dielectric property database to estimate the dielectric constant of the current reaction system online based on the real-time temperature and solvent concentration. The organic solvent dielectric property database stores the dielectric constants of typical organic solvents under different solvent concentrations and temperatures. The embedded controller queries the database based on the current solvent concentration and real-time temperature and outputs the estimated dielectric constant value of the current reaction system as the dielectric constant component in the five-dimensional feature vector. The dielectric constant is a thermodynamic parameter describing the polarity and electric field response characteristics of a solution. Its value directly affects the activity coefficient of ions in the solution and the slope factor in the Nernst equation. It is one of the indispensable characteristic quantities for characterizing the electrochemical environment of non-aqueous systems. Introducing the dielectric constant helps the nonlinear regression function to quantitatively correct the Nernst slope deviation.

[0050] In step S24, the embedded controller performs a first-order difference operation or a fluctuation variance operation on the original pH reading sequence within a sliding time window, and uses the result as a dynamic response factor. When performing a first-order difference operation on the original pH reading sequence within the sliding time window, the first-order difference value is the difference between the original pH readings at adjacent sampling times within the sliding time window; when performing a fluctuation variance operation on the original pH reading sequence within the sliding time window, the fluctuation variance value is the statistical variance of the original pH reading sequence within the sliding time window; the above first-order difference value or fluctuation variance value is used as the dynamic response factor input to the five-dimensional feature vector. The dynamic response factor is used to quantify the hysteresis degree of the pH composite electrode at the current moment: the larger the value, the more the electrode is in a non-steady-state transition process, and the more powerful the dynamic compensation needs to be applied to the nonlinear regression function in step S3; the value approaches zero, indicating that the electrode is close to steady-state equilibrium and the reading reliability is high.

[0051] Step S25: Combine the above five components to construct a five-dimensional feature vector. , in, This is the raw pH reading. Solvent concentration, For real-time temperature, Where is the dielectric constant. This is a dynamic response factor. Two components of the five-dimensional feature vector are derived from direct measurement, and three components are obtained through software reconstruction. The entire construction process requires no additional hardware, fully demonstrating the economic efficiency and convenience of this invention in engineering implementation.

[0052] Step S3: The five-dimensional feature vector is input into a nonlinear regression function constructed based on machine learning. This nonlinear regression function uses the dielectric constant to correct the Nernst slope deviation caused by changes in the dielectric constant and uses a dynamic response factor to compensate for the response hysteresis of the pH composite electrode, outputting the corrected true pH value. The nonlinear regression function employs a dual-path strategy based on the relationship between the historical effective sample size N and a preset threshold: when the historical effective sample size N is less than the preset threshold, the system is in a cold start phase with fewer available training samples, and the nonlinear regression function uses a support vector regression model; when the historical effective sample size N is greater than or equal to the preset threshold, the nonlinear regression function switches to an online sequential extreme learning machine (OS-ELM). OS-ELM is a single-hidden-layer feedforward neural network with a sigmoid activation function. Its hidden layer weights and biases are randomly generated during initialization and remain fixed thereafter. Only the output weight matrix is ​​updated online using a recursive least squares algorithm. OS-ELM also maintains an inverse autocorrelation matrix. The initial output weight matrix and the initial inverse autocorrelation matrix are determined by the batch initialization sample set through Moore-Penrose generalized inverse operation. The OS-ELM's structure allows it to update parameters in a single recursive calculation upon receiving new labeled samples, eliminating the need to store all historical training data. The computational load is independent of the historical sample size, meeting the real-time computational constraints of industrial embedded controllers. Support vector regression models exhibit good generalization ability and anti-overfitting characteristics under small sample conditions, making them suitable for the initial system deployment phase. Online sequential extreme learning machines (SELMs) possess stronger high-dimensional nonlinear fitting capabilities when the sample size is sufficient and support single-sample recursive parameter updates, making them suitable for the stable operation phase. Switching between the two models is automatically completed by the embedded controller based on the historical effective sample size N, requiring no manual intervention. The corrected true pH value is calculated using the following formula:

[0053] ,

[0054] in, This is the corrected true pH value. It is a nonlinear regression function. These are the model parameters for the nonlinear regression function. Online adjustments are made through the incremental learning mechanism in step S5 or the recursive least squares update in step S6.

[0055] Step S4 involves replacing the original pH reading with the corrected true pH value in PID control to control the start / stop and flow rate of the acid or alkali metering pump. Specifically, the embedded controller uploads the corrected true pH value to the DCS system in real time. The PLC controller precisely controls the start / stop and flow rate of the acid or alkali metering pump based on the deviation between the corrected true pH value and the process setpoint, ensuring that the pH value of the reaction system stably converges to the process setpoint, effectively avoiding misjudgments and control oscillations caused by nonlinear deviations in the original reading.

[0056] After step S4 is completed, the PLC controller controls the cleaning water pump to clean the pH composite electrode. After cleaning, the pH composite electrode is immersed in the buffer solution for maintenance, so as to extend the service life of the pH composite electrode and maintain its long-term measurement performance.

[0057] Step S5: During the cleaning and buffer solution maintenance of the pH composite electrode, the embedded controller receives the offline test results and calculates the prediction residual between the predicted value of the current sample and the offline test results using the nonlinear regression function. When the absolute value of the prediction residual exceeds a preset allowable range, an incremental learning mechanism is triggered to fine-tune the parameters of the nonlinear regression function online. The execution of the incremental learning mechanism specifically includes the following steps:

[0058] Step S51: Calculate the prediction residual between the predicted value of the nonlinear regression function for the current sample and the true value of the offline test.

[0059] Step S52: Determine whether the absolute value of the prediction residual exceeds the preset allowable range;

[0060] Step S53: When the absolute value of the predicted residual exceeds the preset allowable range, update the training set of the nonlinear regression function with the current sample and fine-tune the model parameters of the nonlinear regression function online.

[0061] Step S5 uses passively received offline test data as the trigger condition. Through the above-mentioned incremental learning mechanism, the system can continuously absorb new offline test data, adaptively offset the aging drift of the pH composite electrode caused by long-term use, and maintain the long-term correction accuracy of the nonlinear regression function without stopping the system.

[0062] In step S6, during the same cleaning and buffer conditioning phase as in step S5, the embedded controller performs a cumulative sum test on the correction residual sequence to achieve active sensing and targeted compensation for aging drift of the pH composite electrode. Step S6 is triggered when the cumulative sum statistic exceeds the drift detection threshold, and it is executed independently of the passive receiving trigger mechanism of step S5, without interfering with the correction of the nonlinear regression function parameters. The execution of step S6 includes the following sub-steps:

[0063] Step S61: The embedded controller calculates each sampling moment within the current measurement period. Correction residuals It is defined as the difference between the corrected true pH value and the original pH reading at that moment:

[0064] ,

[0065] The correction residual reflects the amount of compensation applied by the model to the original readings at the current moment. Under stable electrode characteristics, the correction residual statistically follows a pattern with respect to the baseline mean. The steady-state distribution centered on the electrode; when the electrode undergoes aging drift, causing its response characteristics to deviate from the electrode state during model training, the sequence mean of the correction residual will produce a systematic shift.

[0066] Step S62: The embedded controller uses the statistical mean of the correction residuals during the stable operation phase after the online sequential extreme learning machine is deployed as the benchmark mean. The standard deviation of the corrected residuals at this stage 0.5 times is the allowable relaxation amount ,by Five times the drift detection threshold The above parameters are calculated from data obtained during the stable operation phase and pre-stored in the embedded controller. The embedded controller then progressively calculates the one-sided cumulative sum statistic for the corrected residual sequence. :

[0067] ,

[0068] Wherein, initial value The cumulative sum is zero. When the cumulative sum exceeds the drift detection threshold, the CUSUM test determines that the electrode has experienced statistically significant drift at the current moment, triggering step S63. The above parameters are set such that the average false alarm running length under steady-state conditions is no less than 2000 sampling points, ensuring the reliability of drift detection.

[0069] Step S63, Active query for maximum deviation: When drift is determined to have occurred in step S62, the embedded controller selects the sampling moment with the largest absolute value of the correction residual deviating from the baseline mean from the backtracking window W consisting of a preset number of sampling points before the triggering time when the accumulated sum and statistics exceed the drift detection threshold. As the moment of active query.

[0070] The embedded controller sends a labeling request to the operator, requesting time... The corresponding batch of reaction solution samples were retained and sent to the laboratory to determine the true pH value. The test results were recorded as follows: The aforementioned maximum deviation proactive query strategy ensures that each annotation request points to the moment when the model prediction deviation is greatest. Compared to the laboratory's method of random sampling at fixed periods, the same number of labeled samples contain more information about the current drift state, improving the efficiency of parameter updates for each offline test.

[0071] Step S64, OS-ELM output weight matrix recursively updated: upon receiving the offline test true values ​​returned by the laboratory. Subsequently, the embedded controller actively queries the timing. The corresponding five-dimensional feature vector Calculate the hidden layer output vector Then, the inverse autocorrelation matrix of OS-ELM is updated sequentially according to the following recursive least squares formula. and output weight matrix :

[0072] First, calculate the gain vector using the following formula:

[0073] ,

[0074] Secondly, update the inverse autocorrelation matrix as follows:

[0075] ,

[0076] Finally, receive the offline test results. Then, perform a single-step correction of the output weight matrix using the following formula:

[0077] .

[0078] The updated inverse autocorrelation matrix and output weight matrix replace the original inverse autocorrelation matrix and output weight matrix, serving as the OS-ELM model parameters for the next measurement cycle. This recursive update process requires only a single matrix-vector multiplication and a single rank-one matrix correction, without needing to access or store historical training samples, resulting in a computational complexity of O(L²), where L is the number of hidden layer nodes in the OS-ELM, satisfying the real-time computational constraints of industrial embedded controllers.

[0079] The application scenario of this embodiment is an organic synthesis workshop in a pharmaceutical factory. The reaction system is a 70wt% acetone-water solution with a large number of suspended particles. The reaction temperature is controlled at 20℃ and the process setting is a target pH value of 4.50.

[0080] First, the PLC controller starts the pump, and the reaction liquid in the reactor is filtered through a filter head and injected into the small detection container, immersing the pH composite electrode. Simultaneously, the PLC controller starts the drain pump to return excess reaction liquid to the reactor, creating a dynamic circulation of liquid inside and outside the reactor. Once the liquid level stabilizes, the embedded controller acquires basic physical quantities at a frequency of 10Hz: the initial pH reading of the pH transmitter is 4.85, and the measured temperature of the temperature sensor is 20℃. This initial pH reading of 4.85 is based on a conventional aqueous solution model. Due to changes in the hydrogen ion activity coefficient and liquid junction potential drift caused by the low-temperature organic solvent, this reading is higher than the true value and cannot be directly used for PID control.

[0081] Subsequently, the dynamic error correction module receives the above signals and constructs a five-dimensional feature vector. The original pH reading of 4.85 and the measured temperature of 20℃ are directly input into the five-dimensional feature vector as measured physical quantities. The embedded controller reads data from the DCS system through the communication interface and obtains that the solvent type of the current batch is acetone and the solvent concentration is 70%. It calls the organic solvent dielectric property database and finds that the dielectric constant of 70% acetone at 20℃ is 36.51. This value is much lower than the dielectric constant of pure water at 20℃ (about 80.1), reflecting the physicochemical environment of the current system with significantly reduced polarity and large deviation of Nernst slope. The algorithm extracts the time series of the original pH readings for the most recent 15 seconds and calculates the dynamic response factor through fluctuation variance calculation. Its value reflects the degree of non-steady state of the pH composite electrode at the current moment. In this embodiment... Thus, the five-dimensional feature vector... Construction complete.

[0082] Furthermore, since the system has accumulated a sufficient number of historical valid samples, the historical valid sample size... For values ​​greater than or equal to a preset threshold, the nonlinear regression function employs an online sequential extreme learning machine (OS-ELM) model. The batch initialization sample set for the OS-ELM model consists of valid labeled data from the first 7 days after system deployment. The initial output weight matrix and initial inverse autocorrelation matrix are determined from this sample set using Moore-Penrose generalized inverse operations. After the five-dimensional feature vector is input into the pre-initialized OS-ELM model, the model identifies the Nernst slope deviation caused by the low-polarity solvent environment reflected by the dielectric constant 36.51, as well as the electrode non-steady-state characteristics indicated by the dynamic response factor. It automatically performs comprehensive compensation calculations based on the formula... The corrected actual pH value is 4.12.

[0083] In the closed-loop control phase, the PLC controller compares the corrected actual pH value of 4.12 (4.12) with the process setpoint of 4.50 instead of the original pH reading of 4.85. If the system determines that 4.12 < 4.50, the DCS controls the alkali metering pump to start, precisely adding liquid alkali until the corrected actual pH value stabilizes and converges to the process setpoint of 4.50. If the uncorrected original reading of 4.85 were used in the PID control, the system would incorrectly determine that the pH has exceeded the setpoint of 4.50, thereby driving the acid metering pump to start and causing a serious loss of pH control in the reaction system. This invention, through precise correction, adjusts the pH value used for control from 4.85 to 4.12, effectively avoiding the aforementioned risk of misjudgment.

[0084] After the measurement is completed, the PLC controller controls the cleaning water pump to clean the pH composite electrode. After cleaning, the pH composite electrode is immersed in the buffer solution for maintenance, in preparation for the next measurement cycle.

[0085] At this point, the laboratory returns the offline true value of 4.11 for this batch of samples. The embedded controller automatically calculates the predicted value of the nonlinear regression function, 4.12. The prediction residual between this value and the offline true value of 4.11 is 0.01, which does not exceed the preset allowable range. Therefore, the incremental learning mechanism in step S5 is not triggered, and the model parameters... The prediction accuracy remains unchanged and meets process requirements. Simultaneously, the embedded controller performs CUSUM drift detection in step S6. During the first 7 days of stable operation after system deployment, the mean of the corrected residual baseline has been calculated and pre-stored as −0.73, and the steady-state standard deviation has been pre-stored as 0.04, thereby determining the allowable relaxation amount. Drift detection threshold During normal system operation, the correction residual at each sampling time fluctuates around the baseline mean, with a deviation... If the value remains below the allowable slack, the cumulative sum statistic remains at 0, the CUSUM test does not trigger a drift alarm, and step S6 does not perform an active query.

[0086] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

[0087] In conclusion, the above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.

Claims

1. A method for online intelligent detection and dynamic compensation of pH for high-concentration organic solvents, characterized in that, Includes the following steps: Step S1: Collect the raw pH reading output by the pH transmitter and the real-time temperature output by the temperature sensor; Step S2: Based on the original pH reading and the real-time temperature, reconstruct the solvent concentration, dielectric constant, and dynamic response factor to construct a five-dimensional feature vector containing the original pH reading, the real-time temperature, the solvent concentration, the dielectric constant, and the dynamic response factor. Step S3: Input the five-dimensional feature vector into a nonlinear regression function. The nonlinear regression function uses a dual-path strategy to output the corrected true pH value. The dual-path strategy is obtained by comparing the relationship between the historical effective sample size and the preset threshold. Step S4: The corrected true pH value is used instead of the original pH reading to participate in PID control, controlling the start-up, shutdown, and flow rate of the acid metering pump or the alkali metering pump. Step S5: Receive the offline test true value, calculate the prediction residual between the predicted value of the nonlinear regression function for the current sample and the offline test true value, and when the absolute value of the prediction residual exceeds the preset allowable range, trigger the incremental learning mechanism to fine-tune the parameters of the nonlinear regression function online. Step S6: Using the difference between the corrected true pH value and the original pH reading in each measurement as the correction residual, perform a cumulative sum test on the correction residual sequence. When the cumulative sum statistic is greater than the drift detection threshold, select the sampling time with the largest absolute value of the deviation of the correction residual from the benchmark mean within a backtracking window composed of a preset number of sampling points before the triggering time as the active query time, request offline testing of the sample corresponding to the active query time, and update the output weight matrix of the online sequential extreme learning machine with the obtained offline test true value through a recursive least squares algorithm.

2. The method for online intelligent detection and dynamic compensation of pH for high-concentration organic solvents according to claim 1, characterized in that, In step S2, the construction of the five-dimensional feature vector includes the following steps: Step S21: The raw pH reading calculated based on the conventional aqueous solution model output by the pH transmitter and the real-time temperature measured by the temperature sensor are directly obtained as measured physical quantities. Step S22: Read the current process formula or operator preset value in the DCS system through the communication interface to obtain the solvent concentration of the current reaction system; Step S23: Call the organic solvent dielectric property database built into the embedded controller, and query the dielectric constant of the current reaction system online according to the real-time temperature and the solvent concentration. The organic solvent dielectric property database stores the dielectric constants of typical organic solvents under different solvent concentrations and different temperature conditions. Step S24: Perform first-order difference operation or fluctuation variance operation on the original pH reading sequence within the sliding time window, and use the operation result as a dynamic response factor; the first-order difference value is the difference between the original pH readings at adjacent sampling times within the sliding time window, and the fluctuation variance value is the statistical variance of the original pH reading sequence within the sliding time window. Step S25: Construct a five-dimensional feature vector ,in, This is the raw pH reading. Solvent concentration, For real-time temperature, Where is the dielectric constant. It is a dynamic response factor.

3. The method for online intelligent detection and dynamic compensation of pH for high-concentration organic solvents according to claim 1, characterized in that, In step S3, the dual-path strategy is as follows: when the number of historical valid samples is less than a preset threshold, the nonlinear regression function adopts a support vector regression model; when the number of historical valid samples is greater than or equal to the preset threshold, the nonlinear regression function adopts an online sequential extreme learning machine. The online sequential extreme learning machine initializes parameters using a batch initialization sample set, uses the sigmoid function as the activation function, keeps the hidden layer weights and biases fixed after initialization, and determines the initial values ​​of the output weight matrix and inverse autocorrelation matrix by the batch initialization sample set. When receiving new labeled samples, the output weight matrix is ​​updated only through a recursive least squares algorithm. The corrected true pH value is calculated using the following formula: , in, This is the corrected true pH value. It is a nonlinear regression function. These are the model parameters for the nonlinear regression function. Online adjustments are made through the incremental learning mechanism in step S5 or the recursive least squares update in step S6.

4. The method for online intelligent detection and dynamic compensation of pH for high-concentration organic solvents according to claim 1, characterized in that, In step S6, the mean of the corrected residual statistics during the stable operation phase after the deployment of the online sequential extreme learning machine is used as the benchmark mean. 0.5 times the standard deviation of the corrected residuals during the stable operation phase is used as the allowable relaxation amount, and 5 times the standard deviation of the residuals is used as the drift detection threshold. The cumulative sum control chart algorithm is used to calculate the cumulative sum statistic step by step on the corrected residual sequence. The initial value is zero. When the cumulative sum statistic is greater than the drift detection threshold, an active query is triggered.

5. The method for online intelligent detection and dynamic compensation of pH for high-concentration organic solvents according to claim 4, characterized in that, In step S6, the hidden layer output vector is calculated using the five-dimensional feature vector corresponding to the active query time. The single-sample parameter update is completed using the recursive least squares method: the gain vector is calculated based on the current inverse autocorrelation matrix and the hidden layer output vector, and the inverse autocorrelation matrix and the output weight matrix are updated sequentially. After receiving the offline verification true value, the single-step correction of the output weight matrix is ​​completed.

6. The method for online intelligent detection and dynamic compensation of pH for high-concentration organic solvents according to claim 1, characterized in that, In step S4, the PID controller uses the deviation between the corrected actual pH value and the preset process setting value as the control input, and controls the start / stop and flow rate of the acid metering pump or the alkali metering pump according to the magnitude and direction of the deviation.

7. The method for online intelligent detection and dynamic compensation of pH for high-concentration organic solvents according to claim 1, characterized in that, In step S5, the incremental learning mechanism includes the following steps: Step S51: Calculate the prediction residual between the predicted value of the nonlinear regression function for the current sample and the true value of the offline test. Step S52: Determine whether the absolute value of the predicted residual exceeds a preset allowable range; Step S53: When the absolute value of the predicted residual exceeds the preset allowable range, update the training set of the nonlinear regression function with the current sample and fine-tune the parameters of the nonlinear regression function online. Step S5 is triggered by passively received offline test data, and step S6 is triggered by the cumulative sum statistic exceeding the drift detection threshold. The two steps are executed independently for different trigger conditions, and the correction of the nonlinear regression function parameters does not interfere with each other.

8. The method for online intelligent detection and dynamic compensation of pH for high-concentration organic solvents according to claim 1, characterized in that, The pH transmitter and temperature sensor are integrated on a pH composite electrode installed inside the detection container. The nonlinear regression function is embedded in the embedded controller in the form of a software algorithm package. The embedded controller works in conjunction with the PLC controller to jointly implement steps S1 to S6.

9. The method for online intelligent detection and dynamic compensation of pH for high-concentration organic solvents according to claim 8, characterized in that, After step S4 is completed, the PLC controller controls the cleaning water pump to clean the pH composite electrode. After cleaning, the pH composite electrode is immersed in buffer solution for maintenance. Steps S5 and S6 are executed during the cleaning and buffer solution maintenance process of the pH composite electrode by the PLC controller.

10. The method for online intelligent detection and dynamic compensation of pH for high-concentration organic solvents according to claim 4, characterized in that, In step S6, the drift detection threshold and the allowable relaxation amount are set such that, under the condition that the electrode characteristics are stable, the expected sampling point interval where the cumulative sum and statistics exceed the drift detection threshold is not less than 2000 sampling points.