Method for realizing zero drift and temperature compensation of pressure sensor based on PC (Personal Computer)-assisted singlechip
Through the temperature calibration and pressure fitting of PC-assisted microcontroller, combined with the least squares method and linear interpolation method, the zero-point drift problem of pressure sensor under temperature changes is solved, accurate correction and compensation is achieved, measurement accuracy and flexibility are improved, and measurement accuracy and flexibility are simplified. The circuit design is designed to meet the needs of wide temperature applications.
Patent Information
- Application Number
- CN202411217428.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-02
- Publication Date
- 2024-12-27
AI Technical Summary
Pressure sensors are prone to zero point drift and sensitivity drift when temperature changes, resulting in a reduction in measurement accuracy. The compensation range of existing hardware compensation methods is limited, and the software compensation method is large in calculation and is easily affected by environmental factors, making it difficult to meet the needs of wide temperature applications.
Using PC-assisted microcontroller, through temperature calibration and pressure fitting, combined with least squares method and linear interpolation method, the precise correction and compensation of the pressure sensor is achieved, the linear relationship curve parameters at standard temperature are saved, and mixed calculations are performed at random temperatures. To calculate the compensation pressure value.
Improve measurement accuracy, simplify circuit design, reduce costs, enhance flexibility and scalability, easy to implement and maintain, and adapt to the needs of different application scenarios.
Smart Images

Figure CN119197884A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the field of temperature compensation implementation methods, and in particular to a method for implementing zero drift and temperature compensation of a pressure sensor based on a PC-assisted single-chip microcomputer. Background Art
[0002] As an important tool for measuring and monitoring pressure, pressure sensors are widely used in many industries. However, due to the temperature sensitivity of semiconductor materials, pressure sensors are often affected by temperature changes during use, resulting in zero drift and sensitivity drift, thereby reducing the measurement accuracy. Traditional compensation methods, such as hardware compensation and software compensation, have their own limitations. Although the hardware compensation method is easy to process and low in cost, the compensation range is limited and cannot meet the requirements of wide temperature applications; while the software compensation method is flexible, it has a large amount of calculation, is easily affected by environmental factors, and is not easy to promote.
[0003] In order to solve the above problems, this application proposes a method for realizing zero drift and temperature compensation of a pressure sensor based on a PC-assisted single-chip microcomputer. Summary of the invention
[0004] (I) Purpose of the invention
[0005] In order to solve the technical problems existing in the background technology, the present invention proposes a method for realizing zero drift and temperature compensation of a pressure sensor based on a PC-assisted single-chip microcomputer. The present invention combines the powerful data processing capability of the PC and the real-time control capability of the single-chip microcomputer, and realizes accurate correction and compensation of the pressure sensor through a specific compensation algorithm.
[0006] (II) Technical solution
[0007] In order to solve the above problems, the present invention provides a method for realizing zero drift and temperature compensation of a pressure sensor based on a PC-assisted single-chip microcomputer, comprising the following steps:
[0008] S1. Temperature calibration:
[0009] Place the temperature sensor in a constant temperature box, control the temperature of the constant temperature box through the PC software, evenly cover the range of the temperature sensor, and test 5-7 standard temperature points;
[0010] Measure and record the actual temperature value and the corresponding measured temperature value at each standard temperature point, and then save these paired data into the non-volatile memory of the microcontroller;
[0011] S2. Zero point calibration and pressure fitting at standard temperature:
[0012] S2.1. At each standard temperature, keep the temperature constant, apply different pressure values to the pressure sensor through a pressure pump, and measure the corresponding voltage value;
[0013] S2.2. Use the least squares method to linearly fit the measured voltage values and pressure values to obtain a linear relationship curve of pressure-voltage, and calculate the parameters of this curve;
[0014] S2.3. Save the linear relationship curve parameters (including standard temperature, zero voltage, slope, intercept) at each standard temperature to the single-chip microcomputer;
[0015] S3. Pressure compensation calibration at random temperature:
[0016] When the temperature sensor detects the current ambient temperature, find the two closest standard temperature points by linear interpolation;
[0017] According to the linear relationship curve parameters at these two standard temperature points, use a hybrid calculation method to calculate the compensated pressure value at the current temperature.
[0018] Preferably, in S2.2, the parameters of the curve include:
[0019] Slope and intercept.
[0020] Preferably, the curve parameters include:
[0021] Standard temperature, zero voltage, slope and intercept.
[0022] Preferably, the pressure compensation calibration algorithm is as follows:
[0023] Piecewise fitting processing. Select 5-7 standard temperature points evenly distributed over the full range. Calibrate 5-7 pressure points at each standard temperature point. Use the least squares method to fit (the linear relationship between pressure and voltage, with pressure represented by Y and voltage represented by X) a pressure straight line, and save the temperature value, zero voltage, and straight line parameters at each temperature point. The four-dimensional parameters (T, Z, K, B) saved respectively represent: calibration point temperature, zero voltage, straight line slope, straight line offset.
[0024] Preferably, 5 groups of values are obtained through piecewise fitting: (T1, Z1, K1, B1), (T2, Z2, K2, B2), (T3, Z3, K3, B3), (T4, Z4, K4, B4), (T5, Z5, K5, B5). And T1 < T2 < T3 < T4 < T5, T1 is close to the lowest point of the temperature range of the pressure sensor, and T5 is close to the highest point of the temperature range of the pressure sensor. Assume that a random standard temperature T and a pressure-generated voltage V are obtained through measurement;
[0025] Calculation of zero drift voltage at random temperature. The algorithm for the zero drift voltage Z is as follows:
[0026]
[0027] Temperature compensation at random temperatures. The algorithm for compensating the pressure value P at random temperatures is as follows:
[0028]
[0029] Else if (T > T3 && T <= T4) {omitted}
[0030] Else if (T > T4 && T < T5) {omitted}
[0031] Else if (T >= T5) {if (V <= Z5) P = 0; else P = K5 * V + B5;}
[0032] The above technical solution of the present invention has the following beneficial technical effects:
[0033] Improve measurement accuracy: By precise temperature calibration, pressure fitting, and a flexible compensation algorithm, the influence of temperature on the measurement accuracy of the pressure sensor is effectively eliminated.
[0034] Simplify circuit design: Adopting a software compensation method to replace the traditional hardware compensation method simplifies the circuit design and reduces costs.
[0035] Flexibility and scalability: Users can adjust the number of standard temperature points and the accuracy of the fitting curve according to actual needs to adapt to different application scenarios and requirements.
[0036] Easy to implement and maintain: The PC-side host computer software is simple and intuitive to operate, easy to learn and use; the single-chip microcomputer control program is stable and reliable, facilitating maintenance and upgrade. Description of the Drawings
[0037] Figure 1 It is a diagram of the host computer tool interface of the present invention. Detailed Implementation Modes
[0038] To make the objectives, technical solutions, and advantages of the present invention clearer and more understandable, the present invention will be further described in detail below in conjunction with the detailed implementation modes and with reference to the accompanying drawings. It should be understood that these descriptions are exemplary and are not intended to limit the scope of the present invention. In addition, in the following descriptions, the descriptions of well-known structures and technologies are omitted to avoid unnecessarily confusing the concepts of the present invention.
[0039] As Figure 1 shown, a method for realizing zero drift and temperature compensation of a pressure sensor based on a PC-assisted single-chip microcomputer proposed by the present invention includes a PC-side host computer software: responsible for generating compensation parameters, transmitting data with the single-chip microcomputer through a communication interface (such as UART), and providing a user interface for operators to perform calibration and calibration.
[0040] Single chip microcomputer: As the control core, it is responsible for collecting data from temperature sensors and pressure sensors, executing compensation algorithms, and outputting corrected pressure values.
[0041] Temperature sensor: monitors ambient temperature in real time and provides data support for temperature compensation.
[0042] Pressure sensor: A sensor to be calibrated and compensated that is used to measure pressure.
[0043] Other auxiliary equipment: including constant temperature box, multimeter, pressure pump, used to provide stable environmental conditions and accurate pressure values during the calibration and calibration process.
[0044] Reference Figure 1 The following is the specific operation process of the host computer:
[0045] Prepare the temperature sensor and pressure sensor, and control the two sensors through the single-chip microcomputer. Prepare the constant temperature box and pressure pump, and place both sensors in the constant temperature box. Connect the pressure sensor to the pressure pump.
[0046] Open the host computer tool on the PC, and establish a wired connection with the MCU via UART or other means;
[0047] Temperature calibration and pressure segment fitting can be performed in any order or even at the same time;
[0048] The temperature is calibrated by adjusting the constant temperature box, and this is repeated many times to calibrate multiple temperature points. Finally, the PC end sends the corresponding measured temperature (calculated by table lookup or formula) and the standard temperature (constant temperature box) to the microcontroller for storage.
[0049] After fitting the pressure curve at each standard temperature, the PC end records the standard temperature, zero point voltage, and fitting parameters at the standard temperature;
[0050] Continuously fit the pressure curves of multiple standard temperature points by repeating step 5.
[0051] The PC sends the curve parameters under multiple standard temperatures, as well as the temperature and zero-point voltage values, to the microcontroller for storage.
[0052] The specific steps are as follows:
[0053] Temperature Calibration:
[0054] Place the temperature sensor in a constant temperature box, control the temperature of the constant temperature box through PC software, evenly cover the range of the temperature sensor, and test 5-7 standard temperature points.
[0055] Measure and record the actual temperature values and the corresponding measured temperature values at each standard temperature point, and then save these paired data to the non-volatile memory of the microcontroller.
[0056] Zero calibration and pressure fitting at standard temperature:
[0057] At each standard temperature, keep the temperature constant, apply different pressure values to the pressure sensor through a pressure pump, and measure the corresponding voltage values.
[0058] Use the least squares method to linearly fit the measured voltage values and pressure values to obtain a linear relationship curve of pressure-voltage, and calculate the parameters (slope, intercept) of this curve.
[0059] Save the linear relationship curve parameters (including standard temperature, zero voltage, slope, intercept) at each standard temperature to the microcontroller.
[0060] Pressure compensation calibration at random temperature:
[0061] In actual applications, when the temperature sensor detects the current ambient temperature, find the two closest standard temperature points by linear interpolation.
[0062] According to the linear relationship curve parameters at these two standard temperature points, use a hybrid calculation method to calculate the compensated pressure value at the current temperature.
[0063] The pressure compensation calibration algorithm is as follows:
[0064] 1) Piecewise fitting process. Select 5 - 7 standard temperature points evenly distributed over the full range. Calibrate 5 - 7 pressure points at each standard temperature point, and use the least squares method to fit a pressure straight line (linear relationship between pressure and voltage, with pressure represented by Y and voltage represented by X), and save the temperature value, zero voltage, and straight line parameters at each temperature point. The four-dimensional parameters (T, Z, K, B) saved respectively represent: calibration point temperature, zero voltage, straight line slope, and straight line offset.
[0065] 2) Assume that the following 5 groups of values are obtained through piecewise fitting: (T1, Z1, K1, B1), (T2, Z2, K2, B2), (T3, Z3, K3, B3), (T4, Z4, K4, B4), (T5, Z5, K5, B5), and T1 < T2 < T3 < T4 < T5, T1 is close to the lowest point of the temperature range of the pressure sensor, and T5 is close to the highest point of the temperature range of the pressure sensor. Assume that a random standard temperature T and the voltage V generated by the pressure are measured;
[0066] 3) Calculation of zero drift voltage at random temperature. The algorithm for the zero drift voltage Z is as follows:
[0067] If (T<=T1) Z=T1;
[0068] Else if(T>T1&&T<=T2)Z=Z1+(Z2-Z1)(T-T1) / (T2-T1);
[0069]
[0070] 4) Temperature compensation at random temperature, the algorithm of random temperature compensation pressure value P is as follows:
[0071]
[0072] By using this solution to perform temperature compensation on the pressure sensor, the measurement accuracy and linearity can be effectively improved, and zero point offset and temperature drift can be eliminated. The more temperature calibration points there are (the more pressure fitting curves there are), the higher the accuracy and effect will be.
[0073] Algorithm model:
[0074] The present invention adopts the least square method to fit the pressure-voltage linear relationship, thereby ensuring that an accurate linear equation can be obtained at each standard temperature.
[0075] The linear interpolation rule is used to calculate the current compensated pressure value at random temperature based on the linear equation parameters of two adjacent standard temperature points.
[0076] In addition, the present invention also allows the user to adjust the number of standard temperature points and the accuracy of the fitting curve according to actual needs to further improve the measurement accuracy.
[0077] In the present invention, the measurement accuracy and stability of the pressure sensor in a wide temperature range are effectively improved through accurate temperature calibration and pressure fitting and a flexible compensation algorithm. The method has the advantages of simple operation, low cost, easy implementation and maintenance, and has broad application prospects and important practical value in the fields of industrial automation, environmental monitoring, and medical equipment.
[0078] It should be understood that the above specific embodiments of the present invention are only used to illustrate or explain the principles of the present invention, and do not constitute a limitation of the present invention. Therefore, any modifications, equivalent substitutions, improvements, etc. made without departing from the spirit and scope of the present invention should be included in the protection scope of the present invention. In addition, the appended claims of the present invention are intended to cover all changes and modifications that fall within the scope and boundaries of the appended claims, or the equivalent forms of such scope and boundaries.
Claims
1. A method for realizing zero drift and temperature compensation of pressure sensor based on PC-assisted single-chip microcomputer, characterized in that: It includes the following steps: S1. Temperature calibration: Place the temperature sensor in an incubator, control the temperature of the incubator through the software on the PC side, evenly cover the range of the temperature sensor, and test 5 - 7 standard temperature points; Measure and record the actual temperature values and the corresponding measured temperature values at each standard temperature point, and then save these paired data to the non - volatile memory of the single - chip microcomputer; S2. Zero - point calibration and pressure fitting at standard temperatures: S2.
1. At each standard temperature, keep the temperature constant, apply different pressure values to the pressure sensor through a pressure pump, and measure the corresponding voltage values; S2.
2. Use the least - squares method to perform linear fitting on the measured voltage values and pressure values to obtain a linear relationship curve of pressure - voltage, and calculate the parameters of this curve; S2.
3. Save the parameters of the linear relationship curve at each standard temperature to the single - chip microcomputer; S3. Pressure compensation calibration at random temperatures: When the temperature sensor detects the current ambient temperature, find the two closest standard temperature points through linear interpolation; According to the parameters of the linear relationship curves at these two standard temperature points, use a hybrid calculation method to calculate the compensated pressure value at the current temperature.
2. According to claim 1, a method for realizing zero drift and temperature compensation of a pressure sensor based on a PC-assisted single-chip microcomputer, characterized in that: In S2.2, the parameters of the curve include: Slope and intercept.
3. According to claim 2, a method for realizing zero drift and temperature compensation of a pressure sensor based on a PC-assisted single-chip microcomputer, characterized in that: The curve parameters include: Standard temperature, zero - point voltage, slope and intercept.
4. According to claim 3, a method for realizing zero drift and temperature compensation of a pressure sensor based on a PC-assisted single-chip microcomputer is characterized in that: The pressure compensation calibration algorithm is as follows: Piece - wise fitting processing, select 5 - 7 standard temperature points evenly distributed over the full range, calibrate 5 - 7 pressure points at each standard temperature point, and fit with the least - squares method: a pressure straight line, and save the temperature value, zero - point voltage and straight - line parameters at each temperature point; The four - dimensional parameters saved: T, Z, K, B, respectively represent: calibration point temperature, zero - point voltage, straight - line slope, straight - line offset.
5. According to claim 4, a method for realizing zero drift and temperature compensation of a pressure sensor based on a PC-assisted single-chip microcomputer, characterized in that: Five groups of values are obtained through piece - wise fitting processing: (T1, Z1, K1, B1), (T2, Z2, K2, B2), (T3, Z3, K3, B3), (T4, Z4, K4, B4), (T5, Z5, K5, B5), and T1 < T2 < T3 < T4 < T5, T1 is close to the lowest point of the temperature range of the pressure sensor, T5 is close to the highest point of the temperature range of the pressure sensor. Assume that a random standard temperature T and a pressure - generated voltage V are obtained through measurement; Calculation of zero - drift voltage at random temperatures, the algorithm for the zero - drift voltage Z is as follows: If(T <= T1) Z = T1; Else if(T > T1 && T <= T2) Z = Z1+(Z2 - Z1)(T - T1) / (T2 - T1); Else if(T > T2 && T <= T3) Z = Z2+(Z3 - Z2)(T - T2) / (T3 - T2); Else if(T > T3 && T <= T4) Z = Z3+(Z4 - Z3)(T - T3) / (T4 - T3); Else if(T > T4 && T < T5) Z = Z4+(Z5 - Z4)(T - T4) / (T5 - T4); Else if(T >= T5) Z = T5; Temperature compensation at random temperatures, the algorithm for the random - temperature compensated pressure value P is as follows: If(T <= T1){if(V <= Z1)P = 0; else P = K1*V + B1;} Else if(T > T1 && T <= T2) { Calculate the zero drift voltage Z; if(V <= Z) P=0; else { P1 = K1*V + B1; P2 = K2*V + B2; P = P1 + (P2 - P1)*(T - T1) / (T2 - T1) } } Else if(T > T2 && T <= T3){Omitted} Else if(T > T3 && T <= T4){Omitted} Else if(T > T4 && T < T5){Omitted} Else if(T >= T5){if(V <= Z5)P = 0; else P = K5*V + B5;}。
