A seawater pH spectral analysis device and method
The seawater pH spectral analysis device, which utilizes visible-near-infrared spectral analysis technology and PLS/LS-SVM modeling, solves the problems of large errors, long time consumption, and high cost in existing seawater pH detection technologies, and achieves rapid, accurate, and economical seawater pH measurement.
Patent Information
- Application Number
- CN202310689749.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-12
- Publication Date
- 2025-10-31
- Estimated Expiration
- 2043-06-12
AI Technical Summary
Existing methods for detecting seawater pH are prone to large errors, are time-consuming, costly, and cannot achieve rapid and accurate detection, thus failing to meet the requirements for rapid, accurate, and economical seawater pollution detection.
The visible-near-infrared spectroscopy analysis technology, combined with PLS and LS-SVM modeling methods, is used to detect the pH of seawater through a spectral analysis device. The device includes a light source module, an optical path length adjustment module, a constant temperature module, and a photoelectric detection module. It utilizes a characteristic wavelength light source and a PID algorithm for precise temperature control, enabling rapid and accurate pH measurement.
It enables rapid and accurate measurement of seawater pH, reduces testing costs, simplifies sample processing, and allows for real-time monitoring and elimination of errors caused by temperature and long optical path length.
Smart Images

Figure CN116793973B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of seawater spectral analysis, and in particular to a seawater pH spectral analysis device and method. Background Technology
[0002] Marine food is an essential source of nutrition for people. With the improvement of modern living standards, the demand for marine food is increasing, which has also promoted the rapid development of mariculture in recent years. However, near-shore aquaculture is gradually becoming one of the main causes of seawater pollution. Therefore, the detection technology for seawater pollution is particularly important for protecting marine ecosystems and ensuring the safety of marine food.
[0003] In marine testing, multiple quality parameters such as pH, turbidity, and oxygen content must be measured. Changes in pH play a crucial role in nearshore aquaculture and environmental pollution monitoring; excessive pH fluctuations can lead to mass mortality of farmed organisms and further pollution of seawater.
[0004] Currently, there are three main methods for detecting seawater pH: One common method is using pH indicators. This method involves adding a pH indicator to the solution to be tested. Different pH indicators will change color depending on the pH value of the solution, and the pH range can be determined based on the indicator. This method has a relatively large error, can only roughly measure the pH range, cannot accurately determine the pH value, and is time-consuming, inefficient, and consumes a lot of reagents. It is only suitable for situations where high pH accuracy is not required. Another method relies on manual observation using pH test strips. This method is intuitive but inefficient, depends on the experience of the measurement personnel, is time-consuming, and cannot provide real-time monitoring. A third method relies on electrochemical methods, using glass electrodes to measure pH. This method yields relatively accurate results, but it is usually time-consuming, and the glass electrodes need to be replaced and maintained regularly, increasing the cost. This method does not meet the requirements for rapid, accurate, and economical water quality testing. Summary of the Invention
[0005] The main objective of this invention is to overcome the aforementioned deficiencies in the prior art and to propose a seawater pH spectral analysis device and method that does not require special sample preparation and can be directly placed into the device for measurement. Furthermore, it employs visible-near-infrared spectral analysis technology, which has the advantages of fast detection speed, real-time measurement, and high accuracy.
[0006] The present invention adopts the following technical solution:
[0007] A seawater pH spectral analysis device, characterized in that it comprises a support, a light source module, an optical path length adjustment module, a constant temperature module, a photoelectric detection module, and a control and processing module; the support is provided with a fixing component, a moving component, and a support plate, the support plate being used to place the sample, the fixing component being fixed to the support plate and located on one side of the sample, and the moving component being movably positioned relative to the fixing component on the other side of the sample; the light source module is mounted on the moving component to sequentially emit multiple characteristic wavelengths of light onto the sample; the photoelectric detection module is disposed on the fixing component to sequentially detect light signals and process and convert them into voltage signals; the optical path length adjustment module is connected to drive the moving component to adjust the optical path length; the constant temperature module is used to provide a constant temperature; the control and processing module is connected to the light source module, the photoelectric detection module, the optical path length adjustment module, and the constant temperature module to convert the voltage signal into a spectral signal and input it into a spectral model to calculate the pH value, the spectral model being a spectral model constructed using the PLS modeling method or the LS-SVM modeling method.
[0008] Preferably, the light source module includes a plurality of LEDs and a driving module. The plurality of LEDs serve as light sources, the driving module is connected to the LEDs, and the light sources are selected using a wavelength optimization algorithm. The plurality of light sources are arranged in a circular array.
[0009] Preferably, the wavelength optimization algorithm includes a continuous projection algorithm or an improved competitive adaptive reweighted sampling method, or a combination of the continuous projection algorithm and the improved competitive adaptive reweighted sampling method.
[0010] Preferably, the photoelectric detection module includes a photoelectric sensor and a processing circuit; the photoelectric sensor is mounted on the fixing component to detect light signals, process them, and output current signals; the processing circuit is connected to the photoelectric sensor to amplify, filter, and convert the current signals into voltage signals; the control processing module is connected to the operational amplifier circuit to process the voltage signals and convert them into spectral signals.
[0011] Preferably, the constant temperature module includes a thermoelectric cooler, a temperature sensor, and a temperature control module; the temperature sensor is mounted on the bracket to collect ambient temperature, the thermoelectric cooler is mounted on the bracket to perform heating or cooling, and the temperature control module is connected to the thermoelectric cooler and the temperature acquisition module to control the constant temperature using a PID algorithm.
[0012] Preferably, the optical path length adjustment module includes a lead screw, a slider, and a motor; the lead screw is mounted on the bracket; the slider and the lead screw are threaded together to achieve transmission; the moving part is fixed on the slider; the motor drives the lead screw to rotate, causing the moving part to move relative to the fixed part to adjust the optical path length; the control processing module is connected to the motor.
[0013] Preferably, it also includes a display interaction module, which is connected to the control processing module to realize parameter input and display pH value and temperature information.
[0014] Preferably, it also includes a power supply module; the power supply module is connected to the light source module, the optical path length adjustment module, the constant temperature module, the photoelectric detection module and the control processing module to supply power.
[0015] A method for seawater pH spectral analysis, characterized by being based on the aforementioned seawater pH spectral analysis device, comprising the following steps:
[0016] 1) Input the required optical path length and temperature into the control processing module;
[0017] 2) The control processing module controls the moving part to move relative to the fixed part to reach the input optical path length, and controls the constant temperature module to work according to the temperature information to provide a constant temperature environment;
[0018] 3) Place the sample in the holder and control the light source module to emit light of characteristic wavelengths in sequence. The light passes through the sample and is emitted to the photoelectric detection module, which processes the light signal and converts it into a voltage signal.
[0019] 4) The control processing module processes and converts the voltage signal into a spectral signal, and inputs the spectral signal into the spectral model to calculate the pH value.
[0020] Preferably, the calculated pH value of the sample and the current ambient temperature are displayed or sent to a mobile terminal.
[0021] As can be seen from the above description of the present invention, compared with the prior art, the present invention has the following beneficial effects:
[0022] 1. The seawater spectral detection device provided by this invention does not require special sample processing and can be directly placed into the device for measurement. It can realize online measurement of seawater acidity and alkalinity (pH value), while taking into account and eliminating environmental errors caused by temperature and long optical path, and has the advantages of being pollution-free and economical.
[0023] 2. In this invention, the light source module adopts a characteristic wavelength LED light source that has been optimized for wavelength. Compared with common visible-near infrared spectral light sources, this light source is less expensive, greatly simplifies the dimensions of spectral data, and simplifies subsequent data acquisition and processing. At the same time, this light source provides a certain basis for subsequent instrument design.
[0024] 3. In this invention, by selecting a suitable optical path length and establishing a corresponding measurement model, the optical path length error can be reduced, thus making it suitable for the spectral detection of seawater acidity and alkalinity. This provides a good idea for the manufacture of instruments and improves the detection accuracy of seawater acidity and alkalinity (pH value).
[0025] 4. In this invention, the constant temperature module is equipped with a temperature control unit, etc. While acquiring the temperature information of the seawater measurement environment, the temperature information is used as an input. Through PID algorithm adjustment, the temperature control module is driven to keep the entire system at a constant temperature, eliminating the detection error caused by different temperatures and improving the detection accuracy.
[0026] 5. This invention provides a spectral detection method for seawater parameters, based on spectral data modeling methods. It includes several common spectral data modeling methods, including commonly used linear and nonlinear models: Partial Least Squares (PLS) and Least Squares Support Vector Machine (LS-SVM), which can improve the prediction accuracy of seawater pH to a certain extent. At the same time, supporting host computer software and WeChat mini-program have been developed, which can display the data acquisition and control the operation of the device in real time. Attached Figure Description
[0027] Figure 1 This is a block diagram of the device components of the present invention;
[0028] Figure 2 This is a structural diagram of the device of the present invention;
[0029] Figure 3 This is a structural diagram related to the optical path adjustment of the present invention;
[0030] Figure 4 for Figure 3 A partial sectional view;
[0031] Figure 5 This is a temperature acquisition circuit;
[0032] Figure 6 For temperature control circuit;
[0033] Figure 7 This is the circuit diagram of the photoelectric detection module;
[0034] Figure 8 This is a PID control graph;
[0035] Figure 9 This is a cross-sectional view of the host computer.
[0036] Figure 10 This is a schematic diagram of a serial port debugging assistant;
[0037] Figure 11 This is a schematic diagram of the PID debugging assistant;
[0038] Figure 12 This is a schematic diagram of the spectrum adjustment assistant;
[0039] Figure 13 This is a screenshot of the WeChat mini-program interface.
[0040] Figure 14 This is a flowchart of the present invention;
[0041] Figure 15 The original pH spectrum is shown in the visible-near infrared spectrum.
[0042] Figure 16 The spectrum is the result of S-G+SNV preprocessing.
[0043] Figure 17 Root mean square error plots for different wavelength combinations;
[0044] Figure 18 To filter characteristic wavelength distribution maps for continuous projection;
[0045] Figure 19 Root mean square error plot for F-CARS wavelength selection;
[0046] Figure 20 Frequency selection diagram for F-CARS wavelengths;
[0047] Figure 21 To improve the competitive adaptive reweighted sampling characteristic wavelength distribution map;
[0048] Figure 22 Root mean square error plots for different combinations of characteristic wavelengths;
[0049] Figure 23 The algorithm fuses the characteristic wavelength distribution map;
[0050] Figure 24 A correlation graph showing the relationship between actual and predicted values;
[0051] in:
[0052] 10. Bracket, 11. Frame, 12. Fixing component, 13. Moving component, 14. Support plate, 15. Housing, 16. Track, 20. Light source module, 21. LED light, 22. Drive module, 30. Optical path length adjustment module, 31. Lead screw, 32. Slider, 33. Motor, 34. Mounting base, 40. Constant temperature module, 41. Semiconductor cooling chip, 42. Temperature sensor, 43. Temperature control module, 44. Heat sink, 45. Fan, 50. Photoelectric detection module, 51. Photoelectric sensor, 52. Processing circuit, 60. Control processing module, 61. Switch, 70. Power supply module, 80. Communication module, 90. Display interaction module, 100. Sample.
[0053] The present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments. Detailed Implementation
[0054] The present invention will be further described below through specific embodiments.
[0055] In this invention, the terms "first," "second," and "third," etc., are used only to distinguish similar objects and are not necessarily used to describe a specific order or sequence, nor should they be construed as indicating or implying relative importance. The use of terms such as "upper," "lower," "left," "right," "front," and "rear" to indicate orientation or positional relationships is based on the orientation or positional relationships shown in the accompanying drawings and is only for the convenience of describing the invention, not to indicate or imply that the device referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, it should not be construed as a limitation on the scope of protection of this invention. Those skilled in the art can understand the specific meaning of the above terms in this application according to the specific circumstances.
[0056] Furthermore, in the description of this application, unless otherwise stated, "multiple" means two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone. The character " / " generally indicates that the preceding and following related objects have an "or" relationship.
[0057] See Figures 1 to 8 A seawater pH spectral analysis device includes a support frame 10, a light source module 20, an optical path length adjustment module 30, a temperature control module 40, a photoelectric detection module 50, and a control and processing module 60. A housing 15 can be provided to integrate all modules of the device and provide a suitable detection environment. Specifically, the support frame 10, light source module 20, optical path length adjustment module 30, temperature control module 40, and photoelectric detection module 50 are all located within the housing 15.
[0058] The support frame 10 includes a frame body 11, a fixing member 12, a movable member 13, and a support plate 14. The support plate 14 is located on the top surface of the frame body 11 for placing the sample 100. The fixing member 12 is fixed to the support plate 14 and located on one side of the sample 100. The movable member 13 is movably positioned relative to the fixing member 12 on the other side of the sample 100. The sample 100 to be tested can be seawater, which is placed in a cuvette and then placed on the support plate 14 between the fixing member 12 and the movable member 13.
[0059] The light source module 20 is mounted on the movable component 13 to sequentially emit multiple characteristic wavelengths of light to the sample 100. For example, four LEDs 21 are sequentially lit to emit light of corresponding wavelengths. The light source module 20 includes several LEDs 21 and a driving module 22. The LEDs 21 serve as the light source, and the driving module 22 is connected to the LEDs 21 to drive the light source to emit light. The light source of this invention is selected using a wavelength optimization algorithm, and the light sources are arranged in a ring array, for example, four LEDs forming a ring. To ensure the stability of the entire system's light source, a constant current source driving method is adopted. Specifically, a PAM2808 high-current driver chip is used as the core of this module to output a stable current.
[0060] The wavelength optimization algorithm includes a continuous projection algorithm, an improved competitive adaptive reweighted sampling method, or a combination of the continuous projection algorithm and the improved competitive adaptive reweighted sampling method. Specifically, this invention uses a wavelength optimization algorithm to screen wavelengths suitable for visible-near-infrared spectral detection of seawater pH values. LEDs containing these wavelengths are used as the system light source. The initial spectral acquisition equipment can be the Flame miniature fiber optic spectrometer from Ocean Insight (USA). This spectrometer is connected to an external sample cell to collect the transmission spectrum of the liquid. The sample cell is connected to the spectrometer via optical fiber. Finally, the spectrometer transmits the collected spectral data to a compatible host computer via a USB interface. The collected raw spectra are shown below. Figure 15 As shown. Due to the different pH values of different samples, the absorbance values of the measured sample spectra also vary.
[0061] Overall, the spectra of all samples showed roughly the same trend. The absorbance spectra clearly showed low and decreasing absorbance values in the 400nm-500nm range, increasing absorbance values in the 500nm-750nm range, and decreasing slowly in the 750nm-850nm range. The absorbance increased rapidly in the 850nm-970nm range, and then decreased rapidly after 970nm. Three characteristic absorption peaks were clearly observed at 750nm, 850nm, and 970nm.
[0062] Spectral data was partitioned into sample sets using the KS method. Spectral data acquired by spectrometers typically contains irrelevant noise, stray light, and other data that affect prediction accuracy. To mitigate and eliminate the impact of this interference on modeling, a combination of SG smoothing and Standard Normal Transform (SNV) was used to preprocess the acquired spectra. The processed spectral data is shown below. Figure 16 As shown, the reason why this method is optimal is probably because SG smoothing eliminates background noise, and SNV eliminates errors and effects caused by scattering. The combination of the two methods improves the signal-to-noise ratio of the spectral data.
[0063] Visible-near-infrared spectral data is characterized by its large volume and strong collinearity. Spectral data typically consists of thousands of wavelength variables, many of which contain useless noise and redundant information. Modeling with full-wavelength data not only results in high model complexity, computational burden, and long training times, but the addition of irrelevant noise and redundant information also negatively impacts the model's predictive performance. This invention employs a feature wavelength optimization algorithm that not only removes irrelevant variable information, reducing the spatial dimensionality of the spectral data and minimizing collinearity, but also simplifies the model's complexity and effectively improves its predictive accuracy and stability.
[0064] Furthermore, the Continuous Projection Algorithm (SPA) is a characteristic wavelength selection method that can effectively reduce collinearity among spectral wavelength variables. Using SPA to select characteristic wavelengths from the preprocessed spectrum, the selection results are as follows... Figure 17 As shown in the figure. According to the root mean square error plots for different wavelength combinations, the wavelength combinations selected with 7 variables as characteristic wavelengths are 638.15nm, 676.04nm, 689.33nm, 694.21nm, 729.51nm, 748.23nm, and 818.65nm. The wavelength distribution is as follows. Figure 18 As shown. The Competitive Adaptive Reweighted Sampling (CARS) method calculates the absolute value weight of the regression coefficients of each wavelength variable through adaptive weighted sampling, removes wavelength variables with smaller weights, and retains the wavelength variables with larger weights as the selected feature wavelengths. However, since the Competitive Adaptive Reweighted Sampling method is based on Monte Carlo sampling and has a certain degree of randomness, to reduce the error caused by randomness, 500 experiments were conducted to improve the Competitive Adaptive Reweighted Sampling method, denoted as F-CARS. This method selects the wavelengths with the highest frequency as feature wavelengths and is verified through extensive PLS modeling. Figure 19 Based on the model parameters shown, 151 wavelength variables with a probability greater than 0.086 were ultimately selected as feature wavelengths. The frequency and distribution of wavelength occurrence are shown below. Figure 20 and Figure 21As shown, using two algorithms in series is one of the most common strategies for feature wavelength selection algorithms, combining the advantages of both. The F-CARS algorithm can select wavelength variables with large absolute values of regression coefficients in the PLS model, but it selects relatively many variables. SPA can minimize redundant information and spatial collinearity in wavelength variables. The improved competitive adaptive reweighting algorithm combined with the continuous projection algorithm (F-CARS-SPA) combines the advantages of both algorithms to select the wavelength variable with the largest absolute value of PLS regression coefficients while having the least redundant information and the least collinearity.
[0065] Therefore, according to Figure 22 The root mean square error of different wavelength combinations was used to select five wavelengths as characteristic wavelengths: 735.46 nm, 537.96 nm, 760.71 nm, 666.67 nm, and 724.23 nm. The wavelength distribution is shown in Figure 23. To compare and evaluate the characteristic wavelengths selected by the three wavelength optimization algorithms, a PLS model was established using the selected variables as input. The results are shown in Table 1. Through comparison, it was found that the characteristic wavelength combinations extracted by the F-CARS+SPA algorithm performed well on both the calibration and validation sets. Combined with the LED processing technology, four characteristic wavelengths were finally determined: 530 nm, 670 nm, 730 nm, and 760 nm.
[0066] Table 1
[0067]
[0068] The optical path length adjustment module 30 is connected to drive the moving component 13 to adjust the optical path length. This module 30 is mounted on the frame 11 and includes a lead screw 31, a slider 32, and a motor 33. The lead screw 31 is mounted on the frame 11 of the bracket 10. The slider 32 is threadedly engaged with the lead screw 31 for transmission. The moving component 13 is fixed to the slider 32, allowing the slider 32 to slide rapidly. The motor 33 is fixed to the frame 11 via a motor mounting assembly and is connected to drive the lead screw 31 to rotate, causing the moving component 13 to move relative to the fixed component 12 to adjust the optical path length. The motor mounting assembly includes a mounting base 34 and a coupling. The motor 33 is fixed to the mounting base 34, and its output shaft is connected to the lead screw 31 via the coupling. A track 16 may also be provided on the frame 11, allowing the slider 32 to slide against the track 16 for more stable movement of the moving component 13. The motor 33 of the present invention can be a stepper motor. When the motor 33 drives the lead screw 31 to rotate, the slider 32 can convert the circumferential rotation of the lead screw 31 into the linear movement of the slider 32, thereby adjusting the distance between the moving part 13 and the fixed part 12, that is, adjusting the optical path length of the light source.
[0069] The optical path length adjustment module 30 of the present invention adjusts to the position of the optimal optical path length obtained in the acid-alkalinity spectrum detection calibration experiment of the seawater sample to be tested. Because if the distance between the light source and the photoelectric detection module 50 is too close, the light source will be too strong, causing the measurement to be in a saturated state. If the distance is too far, the signal will be weak, and the accurate data cannot be measured well, resulting in measurement error. Therefore, appropriate optical path length information is input before measurement, and the drive motor moves to make the entire device measure at the optimal optical path length.
[0070] The photoelectric detection module 50 is mounted on the fixture 12 to sequentially detect light signals and process them to convert them into voltage signals. The photoelectric detection module 50 includes a photoelectric sensor 51 (photodiode) and a processing circuit 52. The photoelectric sensor 51 is mounted on the fixture 12 to detect light signals transmitted through the sample 100 and illuminating the photoelectric sensor 51. After processing the detected light signals, a current signal is output. This current signal is weak. The processing circuit 52 is connected to the photoelectric sensor 51 to amplify, filter, and convert the weak current signal into a voltage signal. The processing circuit 52 mainly includes an operational amplifier circuit, see [link to relevant documentation]. Figure 7 The photoelectric sensor 51 uses the Hamamatsu S1336-44BK, and its photoelectric characteristics include a spectral response wavelength of 320-1100nm and a photosensitive area of 3.6x3.6mm.
[0071] The temperature control module 40 provides a constant temperature and includes a thermoelectric cooler 41, a temperature sensor 42, and a temperature control module 43. The temperature sensor 42 is mounted on the bracket 10 to collect ambient temperature data, the thermoelectric cooler 41 is mounted on the housing 15 for heating or cooling, and the temperature control module 43 is connected to the thermoelectric cooler 41 and the temperature sensor 42 to control the temperature using a PID algorithm. In practical applications, the temperature control module 40 may also include a heat sink 44 and a fan 45.
[0072] Specifically, the thermoelectric cooler, in conjunction with a driving circuit, can switch between heating and cooling by changing the direction of current flow. The driving circuit mainly consists of two IR2140S half-bridge driver chips combined with a high-power NMOS to form a full-bridge driving circuit. The temperature sensor of this invention can use a PT100 + ADS1220. The PT100 temperature sensor has a range of -200 to 850℃, and the ADS1220 is a 24-bit high-precision ADC with an overall measurement accuracy higher than 0.1℃, which can well meet the measurement requirements. Furthermore, this ADC is controlled via an SPI bus, which is simple and offers fast full-duplex communication. The temperature electrical signal measured by the temperature sensor is converted into a digital signal by an A / D conversion module. The temperature control module 43 can use an IR2104S combined with a high-power NMOS to form a full-bridge driving circuit. Through a related control processing module 60, PWM waves in different directions are output to control the current direction, thereby controlling the heating and cooling of the thermoelectric cooler 41. The circuit is as follows: Figure 5 , Figure 6 As shown.
[0073] Because the heating and cooling devices, i.e., the semiconductor cooling chip 41, exhibit a certain overshoot phenomenon (i.e., after heating stops, the heating device continues to heat even though its temperature has not yet dropped), this causes the overall system temperature to be unstable and also wastes resources. To reduce or even eliminate this phenomenon, PID control is used throughout the heating process. PID stands for Proportional-Integral-Derivative. Due to its high reliability, ease of operation, and simple structure, the PID algorithm is widely used in most process control systems, and under normal circumstances, it can achieve the required control effect. The traditional positional PID calculation formula is shown below:
[0074] PID=K p *Error1+K i *(Error1+Error2+…+Error n )+K d (Error1 + Error2)
[0075] Where K p ,K i ,K d These are the proportional coefficient, integral coefficient, and derivative coefficient, respectively. Error2 represents the current error (i.e., the error between the most recent set value and the actual value), Error2 represents the previous error, ... Error nThis refers to the initial error. When the deviation between the target temperature value and the actual temperature value is still relatively large, the system can control the relay to be in the open state, keeping the heating and cooling device in the heating (cooling) phase. When the temperature rises (falls) and approaches the target temperature value, the system then enters a precise temperature control process. First, a switching cycle of the heating (cooling) device must be determined. The control variable specifically represents the duty cycle of the heating (cooling) device. Changing the value of the control variable changes the duty cycle of the heating device, thereby changing the heating (cooling) time within one cycle. When the temperature is close to the target temperature, while keeping the cycle width constant, the value of the control variable is reduced, making the duty cycle of the heating (cooling) device smaller and smaller within one cycle. Therefore, during this process, the time the heating (cooling) device is in the heating (cooling) working state will also become shorter and shorter. It will gradually use residual heat to reach the target temperature value, thus ensuring that the temperature overshoot is not large. Therefore, it can be seen that during the process of heating up to constant temperature, the present invention can be set to use PID control when the error is less than 10℃. By adjusting the above-mentioned proportional coefficient, integral coefficient, derivative coefficient and other parameters, the temperature transition is made more stable, and the effect of precise temperature control can be achieved to avoid large overshoot.
[0076] The control processing module 60 is connected to the light source module 20, the processing circuit 52 of the photoelectric detection module 50, the motor 33 of the optical path length adjustment module 30, and the constant temperature module 40 to convert the voltage signal into a spectral signal and input it into the spectral model to calculate the pH value. The spectral model is a spectral model constructed using the PLS modeling method or the LS-SVM modeling method. The control processing module 60 can be used to control the optical path length adjustment module 30, acquire, calculate, store, and display data during the detection process. It can use the STMicroelectronics STM32F407 microcontroller, which uses a Crotex-M4 core, has a maximum clock frequency of 168MHz, includes a single-precision floating-point arithmetic unit, supports single-precision floating-point calculations, and has multiple peripherals, which can well meet the system requirements. Its related control circuit also includes a switch 61 and various module circuits, providing interfaces and hardware support for each module of the entire detection device.
[0077] PLS (Partial Least Squares Structural Equation Modeling) is a commonly used multiple linear regression method in spectral data analysis. It effectively correlates spectral data with sample index data. By decomposing the spectral matrix and the matrix of the properties to be measured, it extracts latent variables between the matrices, reduces data dimensionality, solves multicollinearity of independent variables, and achieves excellent model prediction results. As a linear method, PLS is mainly applied to the detection of simple seawater samples (i.e., without the influence of turbidity or other parameters). LS-SVM, on the other hand, is a nonlinear modeling method that can model in a high-dimensional space with fewer sample variables. Furthermore, this method uses a set of linear equations instead of a quadratic programming problem to obtain support vectors, avoiding overfitting and achieving satisfactory prediction accuracy. LS-SVM, as a nonlinear method, is applied to the detection of complex seawater samples.
[0078] In this invention, after obtaining the spectral signal through hardware, due to the numerous nonlinear factors in seawater, a method for establishing a spectral nonlinear model, namely least squares support vector machine (LS-SVM), is applied. This can improve the prediction accuracy to a certain extent and meet the requirements.
[0079] Specifically, a spectral model is constructed using the least squares support vector machine method to detect seawater pH values. The specific steps are as follows:
[0080] 1. The obtained spectral signals of the samples are divided into a calibration set (training set) and a validation set (prediction set), and the seawater pH spectral dataset is preprocessed, i.e., smoothed and subjected to multivariate orthogonal scattering. This sample can be the sample used to construct the spectral model.
[0081] 2. Extract characteristic wavelengths from the preprocessed spectral dataset to reduce the difficulty and time required for modeling.
[0082] 3. Use the feature wavelength vectors of the calibration set (training set) as an input to the least squares support vector machine to train the model and finally obtain the required spectral model.
[0083] 4. Input the validation set (prediction set) as a vector into our trained spectral model, and finally evaluate the model to determine whether it meets the requirements.
[0084] The least squares support vector machine of this invention mainly transforms the problem into a system of linear equations. The problem is solved by solving these equations. For a given training set, A = (Xtrain, Ytrain), the decision function model f(x) can be expressed as follows:
[0085]
[0086] Where ω T =[ω 1 ,ω2 ... T It is a vector of weight coefficients for each factor. is a nonlinear mapping function, which is solved by transforming the nonlinear function of the input sample into a linear function in a high-dimensional space, and b is the bias.
[0087] The least squares method is used to constrain and solve the above equation (1) as shown in equations (2) and (3), and the function fitting error and function complexity are taken into account.
[0088]
[0089] γ>0
[0090]
[0091] Where γ is the regularization function, which can adjust the error and give the function better generalization ability, and ω and e are formal parameters, e i Define the regression error.
[0092] The transformation problem of objective optimization in equation (2) is solved using the Lagrangian function, as shown in equation (4).
[0093]
[0094] Where α i is the Lagrange multiplier.
[0095] To find the minimum value of the Lagrange function, we take the partial derivatives with respect to the independent variable and set the partial derivatives to 0, which is the KKT condition.
[0096]
[0097] Based on the Mercer conditions, the least squares support vector machine fitting function can be obtained. Where K(x) i ,x j ) is the kernel function, α i b are the parameters of the model, n is the number of training samples, and x is the value of x. i The training samples are f(x), which is the model output and the predicted value.
[0098]
[0099] The kernel function K(x) used in this application i ,x j ) is the radial basis kernel function (RBF), as shown in equation (7).
[0100]
[0101] The present invention also includes a display interaction module 90, which is connected to the control processing module 60 to realize parameter input and display pH value and temperature information. The display interaction module 90 mainly provides an interactive interface, which can complete operations such as sample measurement according to the prompts on the interactive interface, and display the current temperature value, optical path length value, and measurement results output by the control processing module 60.
[0102] It also includes a power supply module 70 and a communication module 80. The power supply module 70 is connected to the light source module 20, the optical path length adjustment module 30, the constant temperature module 40, the photoelectric detection module 50, and the control processing module 60 to provide power. The communication module 80 includes communication between the device and a host computer. The host computer includes three interfaces, such as... Figures 9-12 As shown, these are a serial port assistant, a PID debugging assistant, and a spectral debugging assistant. Communication between the host computer and the device is based on a serial port; a serial port debugging assistant was designed and developed to facilitate debugging. Temperature control is based on a PID algorithm; a PID debugging assistant was designed and developed to facilitate PID parameter debugging. Finally, there is a spectral debugging assistant, which includes spectral data acquisition and display, model selection, and real-time pH data display. Additionally, a WeChat mini-program was designed and developed to achieve long-distance communication, such as... Figure 13 As shown. Communication between the WeChat mini-program and the device of this invention is achieved in real time via the MQTT protocol based on the ESP8266. The MQTT protocol primarily involves the entire device acting as the sender and the WeChat mini-program on the mobile terminal acting as the receiver, both subscribing to the same topic on the cloud platform to achieve long-distance communication. It mainly includes two interfaces: a login interface and a main interface. The login interface allows for registration, password retrieval, and other operations. The main interface includes temperature acquisition, pH value acquisition and display, and LED control.
[0103] See Figure 14 A method for analyzing the pH of seawater using spectral methods, based on the aforementioned seawater pH spectroscopic analysis device, includes the following steps:
[0104] 1) Input the required optical path length and temperature into the control processing module 60.
[0105] In this step, the device power is turned on, the system is initialized, and appropriate optical path length and temperature information can be input via the buttons on the display interaction module 90. The control processing module 60 acquires the input optical path length and temperature information and displays it on the display interaction module 90. Furthermore, the control processing module 60 establishes communication with the ADS1220 via the SPI interface, and the resulting digital signal from the temperature sensor is displayed on the display interaction module 90.
[0106] 2) The control processing module 60 controls the moving part 13 to move relative to the fixed part 12 to reach the input optical path length, and controls the constant temperature module 40 to work according to the temperature information to provide a constant temperature environment.
[0107] Specifically, the control module controls the motor 33 to drive the lead screw to rotate, and the slider 32 drives the moving part 13 and the light source to move to the input optical path length distance. The temperature control module 43 compares the current temperature value collected by the temperature sensor with the set temperature value, performs PID temperature control through calculation, so that the entire device is kept at the set constant temperature. Finally, the data is transmitted to the display and interaction module 90 for display and is saved.
[0108] 3) Place sample 100 into holder 10, that is, place the cuvette containing the seawater to be tested into holder 10, and then standby, waiting for the detection signal. Control the light source module 20 to emit light of characteristic wavelengths in sequence. The light passes through sample 100 and is emitted to photoelectric detection module 50. Photoelectric detection module 50 processes the light signal and converts it into a voltage signal.
[0109] 4) The control processing module 60 processes and converts the voltage signal into a spectral signal, and inputs the spectral signal into the spectral model to calculate the pH value.
[0110] In this step, for the light signal emitted by each LED 21, the control processing module 60 obtains the corresponding digital signal after passing through the A / D conversion module, collects it 10 times, calculates the average value, and performs mean filtering to obtain the spectral signal; then it controls the next characteristic wavelength LED to emit light, until all characteristic wavelength light sources have finished emitting light, and finally calculates the spectral signal from the collected data.
[0111] The control module then inputs the spectral signal into the spectral model to calculate the pH value, and finally transmits it to the display and interaction module 90 for display. The displayed content may include the data measured at each characteristic wavelength and the pH value. Furthermore, the information collected is displayed on the host computer and the WeChat mini-program on the mobile terminal through the communication module 80.
[0112] Once the current sample 100 has been tested, sample 100 can be removed for the measurement of the next sample 100. The above steps can be repeated.
[0113] In this invention, the pH value of simulated seawater samples was adjusted using 0.1 mol / L sodium hydroxide and 0.1 mol / L dilute hydrochloric acid standard solutions, with a pH range of 2–11. After outlier removal, a training set of 42 samples and a validation set of 12 samples were retained. Using the apparatus and method of this invention, the actual and predicted values of the 12 validation set seawater samples are listed in Table 2. The root mean square error of the prediction (RMSECP) was 0.866, and the correlation coefficient (R) was 0.9473. (See also...) Figure 24Because the spectral model of the detection method of the present invention takes into account the effects of optical path length and temperature, the detection accuracy of the device can be improved.
[0114] Table 2
[0115] True value Predicted value 9.9 9.78 9.7 11.55 8.8 9.64 10 9.42 3 3.79 3.2 3.12 3.2 4.34 3.3 3.87 4.5 5.74 5.3 5.61 5.5 6.11 6.3 6.79
[0116] The above are merely specific embodiments of the present invention, but the design concept of the present invention is not limited thereto. Any non-substantial modifications made to the present invention using this concept shall be considered as infringing upon the protection scope of the present invention.
Claims
1. A seawater pH spectral analysis device, characterized in that: The system includes a support frame, a light source module, an optical path length adjustment module, a constant temperature module, a photoelectric detection module, and a control and processing module. The support frame has a fixing component, a moving component, and a support plate. The support plate is used to place the sample. The fixing component is fixed to the support plate and located on one side of the sample. The moving component is movable relative to the fixing component and is located on the other side of the sample. The light source module is mounted on the moving component to emit multiple characteristic wavelengths of light sequentially onto the sample. The photoelectric detection module is mounted on the fixed component to sequentially detect light signals and process and convert them into voltage signals; the optical path length adjustment module is connected to drive the moving component to adjust the optical path length; the constant temperature module is used to provide a constant temperature; the control processing module is connected to the light source module, the photoelectric detection module, the optical path length adjustment module, and the constant temperature module to convert the voltage signal into a spectral signal and input it into the spectral model to calculate the pH value. The spectral model is a spectral model constructed using the PLS modeling method or the LS-SVM modeling method. The constant temperature module includes a thermoelectric cooler, a temperature sensor, and a temperature control module. The temperature sensor is mounted on the bracket to collect ambient temperature data. The thermoelectric cooler is mounted on the bracket for heating or cooling. The temperature control module is connected to the thermoelectric cooler and the temperature acquisition module to control the constant temperature using a PID algorithm. The optical path length adjustment module includes a lead screw, a slider, and a motor. The lead screw is mounted on the bracket. The slider and the lead screw are threaded together to achieve transmission. The moving part is fixed on the slider. The motor drives the lead screw to rotate, causing the moving part to move relative to the fixed part to adjust the optical path length. The control processing module is connected to the motor.
2. The seawater pH spectral analysis device as described in claim 1, characterized in that: The light source module is equipped with several LEDs and a driving module. The LEDs serve as light sources, and the driving module is connected to the LEDs. The light sources are selected using a wavelength optimization algorithm, and the light sources are arranged in a circular array.
3. The seawater pH spectral analysis device as described in claim 2, characterized in that: The wavelength optimization algorithm includes a continuous projection algorithm, an improved competitive adaptive reweighted sampling method, or a combination of the continuous projection algorithm and the improved competitive adaptive reweighted sampling method.
4. The seawater pH spectral analysis device as described in claim 1, characterized in that: The photoelectric detection module includes a photoelectric sensor and a processing circuit; the photoelectric sensor is mounted on the fixing component to detect light signals, process them, and output current signals; the processing circuit is connected to the photoelectric sensor to amplify, filter, and convert the current signals into voltage signals; the control processing module is connected to the processing circuit to process the voltage signals and convert them into spectral signals.
5. The seawater pH spectral analysis device as described in claim 1, characterized in that: It also includes a display interaction module, which is connected to the control processing module to realize parameter input and display pH value and temperature information.
6. The seawater pH spectral analysis device as described in claim 1, characterized in that: It also includes a power supply module; the power supply module is connected to the light source module, optical path length adjustment module, constant temperature module, photoelectric detection module and control processing module to provide power.
7. A method for spectral analysis of seawater pH, characterized in that: The seawater pH spectral analysis device according to any one of claims 1 to 6 comprises the following steps: 1) Input the required optical path length and temperature into the control processing module; 2) The control processing module controls the moving part to move relative to the fixed part to reach the input optical path length, and controls the constant temperature module to work according to the temperature to provide a constant temperature environment; 3) Place the sample in the holder and control the light source module to emit light of characteristic wavelengths in sequence. The light passes through the sample and is emitted to the photoelectric detection module, which processes the light signal and converts it into a voltage signal. 4) The control processing module processes and converts the voltage signal into a spectral signal, and inputs the spectral signal into the spectral model to calculate the pH value.
8. The seawater pH spectral analysis method as described in claim 7, characterized in that: The calculated pH value of the sample and the current ambient temperature can be displayed or sent to a mobile terminal.
Citation Information
Patent Citations
Device applied to seawater pH value detection
CN220063847U