A sensor intelligent compensation method
By curve fitting and parameter correction of the data of the pressure sensor at different temperatures, the support vector regression model is constructed and trained, the problem of local optimal solution in sensor compensation is solved, and high-precision pressure sensor compensation is achieved.
Patent Information
- Application Number
- CN202510065773.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-16
- Publication Date
- 2025-04-04
- Estimated Expiration
- 2045-01-16
AI Technical Summary
When the prior art optimizes the parameters of the support vector regression model through particle swarm optimization algorithm to compensate the sensor, it is easy to fall into the local optimal solution, resulting in inaccurate compensation.
By obtaining the pressure value of the pressure sensor at different temperatures, performing curve fitting, determining the local similarity of the pressure curve, correcting the penalty parameters, and building and training the support vector regression model to achieve real-time compensation for the pressure sensor.
The accuracy, stability and adaptability of the model are improved, the problem of local optimal solution is avoided, and the high accuracy compensation for the pressure sensor is achieved, which enhances the measurement accuracy and reliability of the sensor under different temperature environments.
Smart Images

Figure CN119533757B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of pressure measurement, and in particular to an intelligent compensation method for a sensor. Background Art
[0002] A sensor is a device that converts physical, chemical or biological quantities into electrical signals. It can be used to measure various parameters, such as temperature, pressure, humidity, light intensity, sound, etc. In practical applications, the environment in which the sensor is located will be affected by various factors, the most significant of which is temperature. Temperature changes will cause drift in the sensor output signal. For example, pressure sensors often have temperature drift. This drift will cause large errors in the raw data collected by the sensor, and these errors may directly lead to application failure or safety hazards.
[0003] The main purpose of sensor compensation technology is to compensate for the error of sensor output so that the sensor can maintain high accuracy under various external conditions. For example, in the existing Chinese patent document with announcement number CN110146215B, a pressure sensor with temperature compensation and parameter setting measures is disclosed. The pressure sensor uses particle swarm optimization combined with SVR (support vector regression) model to establish temperature compensation to compensate for the temperature drift problem caused by low-cost pressure sensitive components.
[0004] However, since the above technical solution mainly optimizes the parameters of the SVR model through the particle swarm optimization algorithm, the particle swarm optimization algorithm has low computational efficiency, especially in the case of high-dimensional data or large data volume. Although the particle swarm optimization can effectively search the parameter space, it is easy to fall into the local optimal solution when the parameter space is complex or the initial particle distribution is uneven. As a result, the parameter combination obtained by the particle swarm algorithm is not the global optimal solution, which affects the fitting accuracy of the support vector regression model and makes it impossible to accurately compensate the sensor according to the fitting results of the model. Summary of the invention
[0005] In order to solve the problem that when optimizing the parameters of a support vector regression model by a particle swarm optimization algorithm to compensate a sensor, the particle swarm optimization easily falls into a local optimal solution, resulting in the inability to accurately compensate the sensor according to the fitting result of the model, the present invention proposes a sensor intelligent compensation method, comprising:
[0006] Obtaining pressure values of the pressure sensor at different temperatures, and performing curve fitting on all pressure values of the pressure sensor at each temperature to obtain a pressure curve at each temperature;
[0007] According to the difference in the size of the area enclosed by the pressure curve at each temperature and the pressure curve at the adjacent temperature, the local similarity of the pressure curve at each temperature is determined, and the initial penalty parameter of the SVR model is determined according to the local similarity of the pressure curves at all temperatures;
[0008] The fluctuation degree of all pressure values at each temperature is obtained through data fluctuation analysis, and the initial penalty parameters of the SVR model are corrected by using the fluctuation degree of all pressure values at each temperature to obtain the final penalty parameters of the SVR model;
[0009] The SVR model is modeled based on the final penalty parameters, and the pressure values of the pressure sensor at different temperatures are used to train the SVR model. The trained SVR model is placed in the compensation module of the pressure sensor to perform real-time compensation for the pressure values collected by the pressure sensor.
[0010] The above technical solution can intuitively present the changing trend of pressure values at a specific temperature by collecting pressure data at different temperatures and performing curve fitting, and can clearly sort out the law of pressure change with temperature, which is helpful to discover the potential characteristics in the data and provide data basis for accurately determining model parameters. Moreover, measuring local similarity by the difference in the integral area between the pressure curve and the adjacent pressure curve is a unique quantitative method. Based on this, the initial penalty parameter of the SVR model is determined, which fully considers the impact of temperature change on pressure data and the local correlation between data, so that the determination of the penalty parameter is more in line with the actual data characteristics of the pressure sensor at different temperatures, improves the rationality of the initial parameter setting of the model, and is conducive to better convergence of the model in subsequent training. In addition, the fluctuation degree of pressure data at each temperature is analyzed to explore the detailed characteristics of the data, which is used to correct the penalty parameter, and the model parameters can be adjusted more accurately to adapt to the dynamic changes of the data, effectively making up for the possible deficiencies of determining parameters based on local similarity alone, further optimizing the penalty parameter of the SVR model, enhancing the adaptability of the model to complex changes in data, and improving the accuracy and stability of the model. And based on the optimized penalty parameters, the SVR model is constructed and trained, and finally applied to the compensation link of the pressure sensor, realizing the complete process from data processing to model construction and then to practical application. The trained model can effectively compensate for the pressure sensor measurement error caused by temperature change, improve the measurement accuracy of the pressure sensor in different temperature environments, enhance the reliability and stability of the sensor, and enable it to work accurately under a wider range of temperature conditions. In summary, the above technical solution analyzes and processes the data from multiple aspects to determine the penalty parameters of the SVR model, and finally realizes high-precision compensation for the pressure sensor, effectively avoiding the problem of inaccurate compensation caused by falling into local optimality when the traditional particle swarm optimization algorithm is used to optimize the parameters of the SVR model.
[0011] Preferably, the final penalty parameter satisfies the following relationship:
[0012] ;
[0013] in, is the final penalty parameter, is the initial penalty parameter, For the The degree of fluctuation of all pressure values at a temperature, is the total number of temperatures, is the natural exponential function, The round-up symbol.
[0014] The above technical solution combines the degree of pressure value fluctuation at all temperatures and the total number of temperature values, which means that the fluctuation of pressure values at different temperatures in the entire temperature range is comprehensively considered. By summarizing the degree of pressure value fluctuation at each temperature, the overall characteristics of pressure data changes in different temperature environments are fully explored to determine the final penalty parameters, so that the parameters can reflect the comprehensive performance of pressure sensor data under different temperature conditions.
[0015] Preferably, the initial penalty parameter satisfies the following relationship:
[0016] ;
[0017] In the formula, is the initial penalty parameter, For the The local similarity of the pressure curves at different temperatures, For the The local similarity of the pressure curves at different temperatures, is the total number of temperatures.
[0018] The above technical solution determines the initial parameters based on the local similarity of the pressure curves at different temperatures, which means that the model has incorporated the consideration of the impact of temperature factors on pressure data from the very beginning. In this way, when facing the data collected by pressure sensors in different temperature environments in the future, the model can better adapt to the pressure data fluctuations and characteristic changes caused by temperature changes, improve the model's ability to cope with temperature differences in actual application scenarios, and thereby improve the model's accuracy and reliability in compensating pressure sensors.
[0019] Preferably, the method for obtaining the degree of fluctuation of all pressure values at various temperatures through data fluctuation analysis is:
[0020] Calculate the The first-order difference of all pressure values at a temperature;
[0021] No. The degree of fluctuation of all pressure values at a temperature The calculation formula is:
[0022] ;
[0023] In the formula, For the of all pressure values at the temperature The first-order difference value, For the The total number of pressure values at each temperature, For the The maximum value of all pressure values at a temperature, For the The minimum value of all pressure values at a given temperature.
[0024] The comprehensive consideration method of the above technical solution comprehensively considers multiple factors such as the accumulation of changes in pressure values, the amount of data, and the overall span of values, so that the measurement of the degree of fluctuation is no longer limited to a single dimension, but fully reflects the fluctuation characteristics of the pressure value at a specific temperature from multiple angles.
[0025] Preferably, the calculation method of the local similarity of the pressure curve at each temperature is:
[0026]
[0027] In the formula, For the The local similarity of the pressure curves at different temperatures, For the The pressure curve at different temperatures, For the The pressure curve at different temperatures, For the The pressure curve at different temperatures, is the natural exponential function, For the The first pressure value of the pressure curve at a certain temperature corresponds to the acquisition time. For the The collection time corresponding to the last pressure value of the pressure curve at a certain temperature.
[0028] The above technical solution can measure the difference between the pressure curve at the current temperature and the pressure curve at the adjacent temperature within a specific interval from an overall perspective. The integral operation accumulates the point-by-point difference between the curves. Compared with simply comparing the differences between a few discrete points, this method more comprehensively reflects the overall deviation of the two curves within a continuous interval, and reflects the intrinsic correlation between the pressure curves at different temperatures.
[0029] Preferably, the method for obtaining the pressure value of the pressure sensor at different temperatures is:
[0030] A pressure sensor is installed in the high and low temperature box. Starting from the lower limit of the temperature range of the high and low temperature box, the temperature is gradually increased by N degrees Celsius each time until it reaches the upper limit of the temperature range of the high and low temperature box. After each temperature increase, the pressure value of the pressure sensor at the increased temperature is collected according to a preset time, and N is a preset value.
[0031] Preferably, the method for performing real-time compensation on the pressure value collected by the pressure sensor is:
[0032] The compensation module of the sensor receives the pressure value collected by the pressure sensor and the temperature value corresponding to the pressure value in real time, and inputs the temperature value into the trained In the model, The model outputs an ideal pressure value of the pressure sensor at the temperature value; the ideal pressure value is a predicted value;
[0033] Then, a compensation amount is calculated based on the pressure value collected by the pressure sensor and the ideal pressure value, and the compensation amount is equal to the ideal pressure value minus the pressure value;
[0034] If the compensation amount is positive, the compensation amount is added to the pressure value to obtain the compensated pressure value; if the compensation amount is negative, the pressure value is subtracted from the absolute value of the compensation amount to obtain the compensated pressure value.
[0035] Preferably, performing real-time compensation on the pressure value collected by the pressure sensor also includes:
[0036] A compensation effect evaluation module is integrated in the compensation module of the sensor, and the compensation effect evaluation module is used to collect and record the pressure values before and after each real-time compensation; the mean square error or mean absolute error is used based on the pressure value sequence before compensation and the pressure value sequence after compensation within a period of time to evaluate the compensation effect of the compensation module of the sensor within the period of time. When the mean square error or the mean absolute error is the smallest, the compensation effect of the compensation module is the best.
[0037] The present invention has the following effects:
[0038] The present invention overcomes the problem that when particle swarm optimization supports vector regression model parameters to compensate sensors, it is easy to fall into the local optimal solution and cause compensation inaccuracy. Starting from data processing, through model construction to practical application, the model parameter settings are closely matched with data characteristics and dynamic changes, improving the accuracy, stability and adaptability of the model, avoiding local optimal defects, accurately compensating for measurement errors caused by temperature, and effectively enhancing the measurement accuracy of pressure sensors in different temperature scenarios, ensuring that they operate stably, reliably and accurately in a wide temperature range. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] The above and other objects, features and advantages of the exemplary embodiments of the present invention will become readily understood by reading the detailed description below with reference to the accompanying drawings. In the accompanying drawings, several embodiments of the present invention are shown in an exemplary and non-limiting manner, and the same or corresponding reference numerals represent the same or corresponding parts, wherein:
[0040] Figure 1 It is a schematic flow chart of the method of the present invention. DETAILED DESCRIPTION
[0041] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0042] The specific embodiments of the present invention are described in detail below with reference to the accompanying drawings.
[0043] Reference Figure 1 The present invention provides a sensor intelligent compensation method, comprising steps S1 to S7:
[0044] S1: Collect the pressure values of the pressure sensor at different temperatures and generate a pressure curve at each temperature.
[0045] A pressure sensor is installed in the high and low temperature box. The sensor acquisition frequency is 1Hz. The temperature range of the high and low temperature box is -20℃ to 60℃. The pressure values under different temperature conditions are collected and the pressure curves corresponding to each temperature are drawn. The specific operation process is to start from -20℃ and gradually increase the amplitude of N degrees Celsius each time until the upper limit of the temperature range is reached. After each temperature increase, the pressure value is continuously collected for 1 minute. N is the preset value and the empirical value is 1.
[0046] Most pressure sensors rely on some special materials (such as semiconductors, metals, piezoelectric materials, etc.) to sense pressure changes. The physical properties of these materials, such as resistance, elastic modulus, piezoelectric coefficient, etc., often change with temperature. If the temperature change causes the sensor's response to change, resulting in different output signals at the same pressure, the pressure measurement will be inaccurate, which means that temperature drift has occurred. When eliminating temperature drift, the SVR model is often used. This model can map data to a high-dimensional space by using kernel functions (such as Gaussian kernels, radial basis functions RBF), thereby better capturing the complex nonlinear relationship between temperature and pressure sensor output, so as to better eliminate the impact of temperature drift.
[0047] Therefore, in order to analyze the change of pressure with temperature, this step uses the acquisition time as the horizontal coordinate and the pressure value as the vertical coordinate to construct a coordinate system, in which multiple curves correspond to different temperature values, the horizontal coordinate of each curve is the acquisition time, and the vertical coordinate is the pressure value at a specific acquisition time at the corresponding temperature. The cubic spline interpolation method is used for curve fitting to obtain the pressure curve at each temperature.
[0048] S2: Calculate the local similarity of the pressure curves at each temperature.
[0049] Eliminating temperature drift means eliminating or reducing the influence of temperature on the sensor measurement results, so that the output results of the pressure sensor at different temperatures can remain consistent or close to the actual pressure value. In other words, it is necessary to pay attention to the overall influence trend of different temperatures on the output results of the pressure sensor. In addition, under ideal conditions without considering temperature drift, the pressure change curves at different temperatures are similar. Therefore, the influence of different temperatures on the pressure sensor can be described by analyzing the degree of change between the pressure curves at different temperatures. If the degree of change between the pressure curves at different temperatures is large, it means that the influence of temperature changes on the pressure sensor is greater, and the nonlinear relationship between temperature and pressure is more complex. A larger penalty parameter is required to capture this complex linear relationship.
[0050] Therefore, this step is to describe the degree of change of the pressure curves at different temperatures through the similarity between the pressure curves at different temperatures. The higher the similarity between the pressure curves, the smaller the degree of change of the pressure curves at different temperatures.
[0051] Therefore, in this step, the local similarity of the pressure curve at each temperature is measured according to the difference in the size of the area enclosed by the pressure curve at each temperature and the pressure curve at the adjacent temperature, and the size of the area can be expressed by an integral.
[0052] Therefore, this step calculates the local similarity of the pressure curve at each temperature according to the following formula:
[0053]
[0054] In this formula, For the The local similarity of the pressure curves at different temperatures reflects the similarity in the pressure value change trend between the pressure curve at each temperature and the pressure curve at the adjacent temperature. Value means in [ ] interval, The pressure curve at one temperature has a similar change trend to the pressure curve at the adjacent temperature, that is, they have similar pressure change rules in the local range; while the smaller The value indicates that the changing trends between the curves are quite different, which helps to intuitively understand the local similarities of the pressure curves at different temperatures. For the The first pressure value of the pressure curve at a certain temperature corresponds to the acquisition time. For the The collection time corresponding to the last pressure value of the pressure curve at a certain temperature.
[0055] In this formula, For the The pressure curve at different temperatures, For the The pressure curve at different temperatures, For the The pressure curve at different temperatures, is the natural exponential function, and As the lower and upper limits of the integral, respectively, here , , that is, to integrate the pressure curve corresponding to the pressure value within one minute.
[0056] In this formula, by calculating the The pressure curve at one temperature and the pressure curve at the adjacent temperature and The difference between them is quantified by the difference of the integral over the interval. This difference is measured based on the overall change of the curve within a certain interval rather than the comparison of a single point.
[0057] This formula converts the difference between the two integrals into a similarity index by taking the natural exponential function. , when the difference between the two integrals is smaller, The value of will be larger, indicating that The pressure curve at one temperature and the pressure curve at the adjacent temperature are in the local interval [ ] have a higher similarity, on the contrary, The pressure curve at one temperature and the pressure curve at the adjacent temperature are in the local interval [ ] have a lower similarity, The value will be smaller.
[0058] In summary, this formula helps to analyze the variation of pressure curves with temperature by calculating the local similarity of pressure curves at each temperature. For example, it can be found out in which temperature ranges the pressure curves have higher similarity and in which ranges the similarity is lower, thus providing valuable information for further data mining, model building or anomaly detection.
[0059] S3: Determine the initial penalty parameters of the SVR model based on the local similarity of the pressure curves at all temperatures.
[0060] In the process of building the SVR model, the penalty parameter is an important parameter that determines the final fitting effect of the model. The prior art proposes a method of using a particle swarm optimization algorithm to obtain the penalty parameter. However, the particle swarm optimization algorithm consumes computing resources and easily causes a local optimal solution, which affects the final model fitting effect and thus reduces the elimination effect of temperature drift.
[0061] Therefore, the present invention constructs a sample set based on pressure data at different temperatures, and analyzes the pressure change characteristics at different temperatures to obtain penalty parameters, which helps the model to better understand the changing relationship between temperature and pressure, thereby better eliminating temperature drift.
[0062] This step determines the initial penalty parameter according to the following relationship:
[0063]
[0064] In the formula, is the initial penalty parameter, For the The local similarity of the pressure curves at different temperatures, For the The local similarity of the pressure curves at different temperatures, is the total number of temperatures.
[0065] In this formula, is the variance of the local similarity of the pressure curves at all temperatures. The larger the variance, the greater the degree of change between the pressure curves at different temperatures, which means that the greater the impact of temperature on the pressure sensor, the more complex the nonlinear relationship between temperature and pressure, and the larger the penalty parameter to better capture the relationship between pressure and temperature.
[0066] In summary, this formula determines the initial penalty parameter of the SVR model by considering the local similarity of the pressure curves at all temperatures, making full use of the similarity information of the pressure curves at different temperatures. This makes the determination of the penalty parameter no longer blind or random, but closely related to the intrinsic characteristics of the data, which helps to improve the model's ability to fit the data.
[0067] Dynamically adjusting the initial penalty parameters according to the local similarity of the pressure curve can enable the model to better adapt to the changes in pressure data at different temperatures. For temperature ranges with high similarity, the model can appropriately reduce the penalty intensity to make full use of these similar data for learning. For ranges with low similarity, the penalty parameters can be increased to avoid model overfitting, thereby improving the generalization ability of the model.
[0068] S4: Analyze the fluctuation degree of all pressure values at each temperature.
[0069] When obtaining the degree of fluctuation of all pressure data at any temperature, it can be reflected by the change in the first-order difference value of all pressure values at that temperature. The larger the first-order difference value, the greater the difference between the pressure values and the higher the degree of fluctuation.
[0070] Therefore, this step first obtains The first-order difference of all pressure values at a temperature. Since the first-order difference is the difference between every two adjacent pressure values, A pressure value will be generated The first-order difference value. The degree of fluctuation of all pressure values at a temperature The calculation formula is:
[0071]
[0072] In the formula, For the of all pressure values at the temperature The first-order difference value, For the The total number of pressure values at each temperature, For the The maximum value of all pressure values at a temperature, For the The minimum value of all pressure values at a given temperature.
[0073] This formula measures the change in pressure value: by calculating the The first-order difference of all pressure values at a temperature can intuitively reflect the change range between adjacent pressure values. Add all first-order difference values and divide by , what is obtained is the average amplitude of the pressure value change at that temperature, thereby measuring the fluctuation of the pressure value at that temperature.
[0074] This formula takes into account the influence of temperature range, and multiplying by , is to associate the fluctuation degree of pressure value with the value range at that temperature. This means that under the same average fluctuation amplitude, the larger the temperature range, the greater the overall fluctuation degree will be, which reflects the relativity between the fluctuation degree and the temperature range.
[0075] In summary, this formula can quantify the fluctuation of pressure value at each temperature and obtain a specific value, which is convenient for subsequent comparison and analysis of the degree of fluctuation at different temperatures.
[0076] Can reflect data stability: larger The value is expressed in The fluctuation of pressure value at different temperatures is large, and the stability of data is poor; on the contrary, the smaller The value indicates that the pressure value fluctuates less and the data is relatively stable. This helps to intuitively understand the characteristics of the data at different temperatures.
[0077] Can provide a basis for parameter correction: calculated The value serves as an important basis for the subsequent correction of the penalty parameters of the SVR model, which can make the penalty parameters adaptively adjusted according to the fluctuation characteristics of the pressure values at different temperatures, thereby improving the accuracy and adaptability of the model.
[0078] S5: The initial penalty parameter of the SVR model is corrected to the final penalty parameter using the fluctuation degree of all pressure values at each temperature.
[0079] In order to avoid the overfitting phenomenon caused by excessively large penalty parameters, the penalty parameters can be corrected to a certain extent based on the fluctuation degree of pressure data at the same temperature, so that the model pays more attention to the difference in pressure data at different temperatures when fitting the data, rather than focusing too much on the fluctuation of pressure data at the same temperature.
[0080] The final penalty parameter satisfies the following relationship:
[0081]
[0082] in, is the final penalty parameter, is the initial penalty parameter, For the The degree of fluctuation of all pressure values at a temperature, is the total number of temperatures, is the natural exponential function, The use of the ceiling symbol ensures that It is an integer, which makes it easier to set and adjust parameters in actual model training, and also avoids non-integer parameter values that are too complex or difficult to handle.
[0083] This formula introduces the key factor of the fluctuation degree of pressure value at different temperatures, aiming to build an adaptive adjustment mechanism so that the penalty parameter can closely fit the intrinsic characteristics of the data and the actual situation. is the average value of the fluctuation of pressure values at all temperatures, is the degree of correction of the initial penalty parameter. When the pressure value fluctuates at different temperatures, the penalty parameter will be dynamically adjusted. Specifically:
[0084] If the pressure value fluctuates greatly, that is, The larger the value, according to the properties of the natural exponential function, will be smaller, The closer it is to 0, the is closer to 1, so Relative to There will be a greater reduction, that is, a greater (downward) correction of the initial penalty parameter.
[0085] If the pressure fluctuation is small, that is, The smaller the value, according to the properties of the natural exponential function, The bigger it will be, The closer it is to 1, the is closer to 0, so Relative to There will be a smaller reduction, that is, a smaller (downward) correction of the initial penalty parameter.
[0086] In-depth analysis from the dimensions of physical meaning and model performance:
[0087] When the pressure value shows large fluctuations, it is particularly important to implement a more significant reduction adjustment on the penalty parameter. This is because large fluctuations in pressure values usually indicate that there are more random interference factors or noise components in the pressure data. In this case, if the penalty parameter is too large, the model will be overly obsessed with data details during the fitting process and try to accurately match each sample data point, which undoubtedly greatly increases the risk of overfitting. By significantly reducing the penalty parameter, the model can be given greater adaptability and flexibility when fitting data, making it more tolerant of noise or anomalies in the data, and no longer obsessed with accurate and correct fitting of each sample, thereby effectively avoiding the dilemma of overfitting and improving the model's processing capabilities and generalization performance for complex and noisy data.
[0088] When the pressure value fluctuates relatively small, a smaller fluctuation amplitude often means that the change trend of the pressure value is relatively stable and reliable. At this time, the fitting effect achieved by the initially set penalty parameters is relatively close to the ideal state. Even if there are some minor anomalies in the data, it is only necessary to make appropriate fine-tuning of the penalty parameters, that is, to reduce them to a small extent. In this way, it can not only correct the fitting deviations that may be caused by minor anomalies to a certain extent, but also retain the model structure and fitting characteristics determined by the initial penalty parameters to the greatest extent, ensure the high-precision prediction ability and good stability of the model in a stable data environment, maintain the effective learning and inference ability of the model under normal data distribution, and avoid unnecessary fluctuations or degradation of model performance due to excessive adjustment of parameters.
[0089] In summary, this formula achieves a balance between model complexity and fitting effect to a certain extent. By flexibly adjusting the penalty parameters according to the degree of fluctuation of pressure values at different temperatures, the model can better adapt to the differences in data distribution under different temperature conditions, and effectively improve its accuracy and stability when making predictions in the entire temperature range. During the training process for temperature compensation, the model focuses more on the changes in sample pressure data at different temperatures, while reducing the focus on fluctuations in sample pressure data at the same temperature, thereby achieving the purpose of optimizing model performance.
[0090] S6: Modeling and training are performed based on the final penalty parameters through the SVR model, and the trained SVR model is placed in the compensation module of the pressure sensor to compensate the pressure value in real time.
[0091] S61: First, the SVR model is modeled based on the modified penalty parameter. The modeling method is:
[0092] S611: Determine the kernel function type of the SVR model.
[0093] Since the goal of the SVR model is to find a suitable functional relationship to perform regression analysis on the input data (here, the temperature and pressure values) and predict the output (ideal pressure value) as accurately as possible. However, in the actual data space, the temperature and pressure values may present a complex nonlinear relationship, and it is often difficult to directly construct such a regression relationship in the original data space. The kernel function plays a key role at this time. It can map the temperature and pressure values in the original input space to a high-dimensional space. In this high-dimensional space, the nonlinear relationship in the original space may become linearly separable or easier to be approximated by a linear function, which makes it easier to build a regression model. Common kernel functions include linear kernel functions, polynomial kernel functions, radial basis functions, etc. Here, the radial basis function is selected as the kernel function.
[0094] S612: Construct the basic structure of the SVR model according to the selected kernel function and the modified penalty parameter.
[0095] The SVR model consists of an objective function and the constraints of the objective function. The objective function is:
[0096]
[0097] The constraints of the objective function are:
[0098]
[0099] In this formula, Indicates the minimum operation, which means to calculate the minimum value of the expression that follows. Optimize and find In the case of the smallest value, the subscript Points out the variables that need to be adjusted and find the optimal value. is the weight vector, is the bias term, It is The slack variable for samples, It is The upper slack variables of samples, that is, the entire objective function is minimized by changing the values of these variables.
[0100] In this formula, middle, is a weight vector, each element of which corresponds to the weight of a different input feature. For example, if the input features have multiple variables such as temperature and humidity, then Each component in determines the importance of features such as temperature and humidity in calculating the predicted value of the model. express The norm of This item is used to measure the complexity of the model in the objective function. The goal is to make the norm of the weight vector not too large, so that the model is relatively simple and avoid overfitting. That is, the model does not rely too much on complex weight combinations when fitting data, so as to enhance the generalization ability of the model.
[0101] In this formula, is the final penalty parameter, also known as the regularization parameter, which is used to control the degree of penalty for model fitting error, that is, in the model complexity (given by ) and the fitting error to the training data (reflected by the following When When the value is large, the model will pay more attention to reducing the fitting error and tend to allow the weight vector becomes larger, making the model more complex, so as to make each sample point close to the fitting hyperplane; on the contrary, when If the value is smaller, the model tends to remain simpler and is relatively more tolerant of the fitting errors of some sample points.
[0102] The formula part, It is The slack variable for samples, It is The upper slack variable of samples, where Represents the total number of samples. This item is the sum of the slack variables and the upper slack variables of all samples. It measures the fitting error of the model for all samples. The slack variables and the upper slack variables reflect the degree to which the sample points deviate from the fitting hyperplane. Therefore, this part reflects the degree to which the model fits the training data poorly. After that, you can The value of determines the importance of this fitting error.
[0103] The constraints of this formula are: part, It is The true output value of the sample (the actual pressure value), It is The input features (temperature values) of samples, Yes After being mapped to high-dimensional space through the kernel function, Mapping values in high-dimensional space. Represents the weight vector and The inner product operation, plus the bias term back, The model is The predicted value of a sample. is a pre-set positive number, called the insensitive loss parameter, which defines a " -band" area, the sample points in this area are considered to be well-fitted and do not need to generate slack variables (i.e. ), and when the true value of the sample point Less than the predicted value minus When , we need to introduce slack variables To measure the degree of deviation, that is, to constrain this deviation. The value of If the data has a certain degree of noise or uncertainty, but the overall distribution still has a certain regularity, it can generally be taken in this range. While allowing the model to have a certain fitting error, it can better balance the complexity of the model, so that the model will not be too complex or too simple. It is suitable for many conventional data regression scenarios and can enable the model to capture the main change trend of the data without being overly affected by noise. Here, it is set is 0.1.
[0104] The constraints of this formula are: , similar to the above, here is used to measure the true value of the sample point Greater than the predicted value plus When the deviation occurs, the upper slack variable To record the degree of deviation, ensure that the model complies with the corresponding constraint rules when processing sample points that are above the fitting hyperplane and deviate.
[0105] The constraints of this formula are: , explicitly specifying the slack variables and upper slack variables The value range of is non-negative, because they represent the degree to which the sample points deviate from the fitting hyperplane. From a practical point of view, the degree of deviation cannot be negative, so it must satisfy the condition of being greater than or equal to 0.
[0106] S62: For the built The model is trained using the following method:
[0107] Get different temperature values and corresponding pressure values, and divide the entire data set into training set, validation set, and test set according to a certain ratio. A common division ratio can be 70% as training set, 15% as validation set, and 15% as test set. The training set is used to train and update model parameters; the validation set is used to evaluate the performance of the model during the training process and help adjust the model's hyperparameters (such as the final penalty parameter C1, parameters in the radial basis function, etc.) to prevent overfitting; the test set is used to finally evaluate the generalization ability of the trained model on unknown data.
[0108] In order to find the parameters that minimize the objective function , it is necessary to use a suitable optimization algorithm, commonly used ones are SMO (Sequential Minimum Optimization) algorithm or gradient descent method.
[0109] Here, we take the SMO algorithm as an example to illustrate the general training steps:
[0110] Initialization parameters: Assign initial values, usually all 0 or a random small value (but be sure to meet the corresponding constraints). At the same time, set the algorithm-related parameters, such as the maximum number of iterations (such as 1000 times), the threshold for stopping iterations (such as the change in the objective function value is less than 0.000001), etc. Here, the change in the objective function value is less than 0.000001 as the condition for stopping iterations.
[0111] Iterative training: In each iteration: according to the current parameter value, calculate the predicted value of the sample point under the model , and based on the predicted value and the true value The differences and current (insensitive loss parameter) to determine the corresponding and The value of .
[0112] According to the rules of the SMO algorithm, two Lagrange multipliers are selected for optimization and update. The new values of the two multipliers are obtained by solving a quadratic programming subproblem, and then the weight vector is updated. , bias term And parameters such as slack variables corresponding to all samples.
[0113] Check whether the stopping conditions are met. If the maximum number of iterations is reached or the change in the objective function value is less than the set threshold, the training is stopped and the model training is completed. Otherwise, continue to the next round of iterations.
[0114] S63: Place the trained SVR model in the compensation module of the pressure sensor to perform real-time compensation on the pressure value, the method is:
[0115] The compensation module of the pressure sensor will obtain the pressure value collected by the pressure sensor and its corresponding temperature value in real time, and then input the temperature value into the trained SVR model. The SVR model calculates based on the input temperature value, and outputs the ideal pressure value that the pressure sensor should collect at that specific temperature. This ideal pressure value is essentially the predicted value given by the model based on existing data and training results.
[0116] After obtaining the actual pressure value collected by the pressure sensor and the ideal pressure value output by the SVR model, the compensation amount can be calculated. The compensation amount is calculated by subtracting the actual pressure value from the ideal pressure value. When the compensation amount is a positive number, it means that the actual pressure value is lower than the ideal pressure value. At this time, the compensation amount is superimposed on the actual pressure value to obtain the compensated pressure value, so as to make a positive correction to the measured value of the pressure sensor; if the compensation amount is a negative number, it means that the actual pressure value is higher than the ideal pressure value. It is necessary to subtract the actual pressure value from the compensation amount to obtain the compensated pressure value, so as to achieve a reverse correction to the measured value of the pressure sensor.
[0117] Here are two examples: In the first example, assuming that the pressure value collected by the pressure sensor is 80kPa, the ideal pressure value calculated by the SVR model based on the corresponding temperature value is 85kPa. At this time, the compensation amount is equal to 85-80=5kPa. Since the compensation amount is a positive value, the pressure value after compensation is 80+5=85kPa.
[0118] In the second example, if the pressure value collected by the pressure sensor is 90kPa, and the ideal pressure value output by the SVR model is 88kPa, then the compensation amount is equal to 88-90=-2kPa, which is a negative value, so the pressure value after compensation is 90-2=88kPa. Through such a compensation mechanism, the accuracy of the pressure sensor's measurement value under different temperature environments can be effectively improved.
[0119] Furthermore, a compensation effect evaluation module is integrated in the compensation module of the sensor, and the compensation effect evaluation module is used to collect and record the pressure values before and after each real-time compensation. The pressure value sequence before compensation and the pressure value sequence after compensation within a period of time are collected, and the mean square error or mean absolute error is used to evaluate the compensation effect of the compensation module of the sensor during the period of time. When the mean square error or mean absolute error is the smallest, the compensation effect of the compensation module is the best.
[0120] In the description of this specification, "multiple" or "several" means at least two, such as two, three or more, etc., unless otherwise clearly and specifically defined.
[0121] Although this specification has shown and described a number of embodiments of the present invention, it will be apparent to those skilled in the art that such embodiments are provided by way of example only. Those skilled in the art will conceive of many modifications, changes and alternatives without departing from the ideas and spirit of the present invention. It should be understood that in the practice of the present invention, various alternatives to the embodiments of the present invention described herein may be employed.
Claims
1. A sensor intelligent compensation method, characterized in that: include: Obtaining pressure values of the pressure sensor at different temperatures, and performing curve fitting on all pressure values of the pressure sensor at each temperature to obtain a pressure curve at each temperature; The local similarity of the pressure curve at each temperature is determined based on the difference in the size of the area enclosed by the pressure curve at each temperature and the pressure curve at the adjacent temperature. The calculation method is: ; For the The local similarity of the pressure curves at different temperatures, For the The pressure curve at different temperatures, For the The pressure curve at different temperatures, For the The pressure curve at different temperatures, is the natural exponential function, For the The acquisition time corresponding to the first pressure value of the pressure curve at a certain temperature, For the The acquisition time corresponding to the last pressure value of the pressure curve at a certain temperature; The initial penalty parameter of the SVR model is determined based on the local similarity of the pressure curves at all temperatures, and the relationship is: ; is the initial penalty parameter, For the The local similarity of the pressure curves at different temperatures, is the total number of temperatures; The fluctuation degree of all pressure values at each temperature is obtained by data fluctuation analysis. The method is: calculate the The first-order difference of all pressure values at the temperature; The degree of fluctuation of all pressure values at a temperature The calculation formula is: ; For the of all pressure values at the temperature The first-order difference value, For the The total number of pressure values at each temperature, For the The maximum value of all pressure values at a temperature, For the The minimum value of all pressure values at a temperature; The initial penalty parameters of the SVR model are modified by using the fluctuation degree of all pressure values at various temperatures to obtain the final penalty parameters of the SVR model. The relationship is: ; is the final penalty parameter, is the rounding symbol; The SVR model is modeled based on the final penalty parameters, and the pressure values of the pressure sensor at different temperatures are used to train the SVR model. The trained SVR model is placed in the compensation module of the pressure sensor to perform real-time compensation for the pressure values collected by the pressure sensor.
2. A sensor intelligent compensation method according to claim 1, characterized in that: The method for obtaining the pressure value of the pressure sensor at different temperatures is: A pressure sensor is installed in the high and low temperature box. Starting from the lower limit of the temperature range of the high and low temperature box, the temperature is gradually increased by N degrees Celsius each time until it reaches the upper limit of the temperature range of the high and low temperature box. After each temperature increase, the pressure value of the pressure sensor at the increased temperature is collected according to a preset time, and N is a preset value.
3. A sensor intelligent compensation method according to claim 1, characterized in that: The method for real-time compensation of the pressure value collected by the pressure sensor is: The compensation module of the sensor receives the pressure value collected by the pressure sensor and the temperature value corresponding to the pressure value in real time, and inputs the temperature value into the trained In the model, The model outputs an ideal pressure value of the pressure sensor at the temperature value; the ideal pressure value is a predicted value; Then, a compensation amount is calculated based on the pressure value collected by the pressure sensor and the ideal pressure value, and the compensation amount is equal to the ideal pressure value minus the pressure value; If the compensation amount is positive, the compensation amount is added to the pressure value to obtain the compensated pressure value; if the compensation amount is negative, the pressure value is subtracted from the absolute value of the compensation amount to obtain the compensated pressure value.
4. A sensor intelligent compensation method according to claim 1, characterized in that: The pressure value collected by the pressure sensor is compensated in real time, and also includes: A compensation effect evaluation module is integrated in the compensation module of the sensor, and the compensation effect evaluation module is used to collect and record the pressure values before and after each real-time compensation; the mean square error or mean absolute error is used based on the pressure value sequence before compensation and the pressure value sequence after compensation within a period of time to evaluate the compensation effect of the compensation module of the sensor within the period of time. When the mean square error or the mean absolute error is the smallest, the compensation effect of the compensation module is the best.
Citation Information
Patent Citations
A barometric pressure sensor with temperature compensation and parameter tuning measures
CN110146215B
Method and device for establishing network traffic prediction model, and storage medium
CN115134252A
Intelligent temperature compensation method for oil well pressure sensor
CN118228119A