Compensation Method for High-Precision Temperature Measurement Using MSP430 Microcontroller
[Copy link]
For a long time, people have mostly used conventional measurement methods to measure temperature. When the detection accuracy is required to be high, the conditioning circuit is complex and the number of A/D bits is high, which makes the designed system cost high and difficult to popularize. With the development of electronic technology, many fully functional low-power, low-voltage large-scale integrated circuits have emerged, providing a hardware foundation for the design of portable high-precision temperature measurement systems. The high-precision portable thermometer introduced in this article uses the MSP430P325 of TI, which is very suitable for low-power portable test equipment, as the controller, and uses Pt500 platinum resistance to complete temperature detection. The detected temperature is displayed on the LCD display. The temperature measurement accuracy of this tester reaches 0.03℃.
Hardware circuit design The
MSP430P325 microcontroller integrates a switchable precision constant current source. The current size of the precision constant current source is determined by an external precision resistor, and at the same time, 6 14-bit A/D converters and liquid crystal controllers are integrated inside. Such an internal structure is suitable for driving sensors. Therefore, the expansion of the signal conditioning link and the display link can be reduced, which greatly simplifies the system structure and effectively reduces the system power consumption.
1. Temperature sensor mathematical model
The temperature sensitive element uses a platinum resistor Pt500. In the temperature range of ~630.75℃, the relationship between the resistance value of the platinum resistor and the temperature is
b=-5.847×10-7/(℃) 2
According to the above formula, the temperature calculation needs to solve the second-order equation. The calculation procedure is complicated and the accuracy is difficult to guarantee. For this reason, this paper uses the table method and linear interpolation method to transform the temperature scale. The method is as follows: First, 120 tables are established with the absolute resistance value corresponding to a temperature increase of 1℃. The A/D conversion result is compared with the resistance value in the table until Rn≤RM<Rn+1 stops comparing. The integer part of the temperature is obtained. The decimal part of the temperature is solved according to the ratio of R-Rn and Rn+1-Rn, and the temperature value can be obtained. This method is simple and convenient to calculate, and can also meet the accuracy requirements of the equipment.
2. A/D conversion principle of MSP430P325 microcontroller
The MSP430 series microcontroller has the advantages of low power consumption, high anti-interference, and high integration. Among them, the MSP430P325 single-chip computer has a 6-channel 14-bit A/D converter, as shown in Figure 1. Among the 6 channels, A0~A3 can be programmed to work as a constant current source, which is suitable for applications with external resistive and passive sensor elements. The SVCC terminal is the reference voltage terminal for A/D conversion, which can be connected to the AVCC inside the chip or provided by an external voltage regulator. The A/D conversion adopts the principle of successive approximation, which is realized by an internal resistor network generating a switch capacitor network in conjunction with D/A and comparator circuits, and the conversion process is controlled by the clock ADCLK. The conversion process goes through two cards. First, the range of the input signal voltage is determined by comparing the resistor array voltage divider value with the input signal. This voltage range is to divide the reference voltage into 4 equal parts, which are called ranges A, B, C, and D from low to high; then the switch capacitor array changes the capacitance bit by bit to search for the voltage value closest to the input signal. Since the capacitance is arranged in binary power, the on state of the switch after the search is completed is the A/D conversion value of the input signal. In fact, the upper 2 bits of the conversion value are determined by the resistor network, and the lower 12 bits of the conversion value are determined by the switch capacitor network.
When the conversion is started, the signal voltage range is set in ACTL, and the upper 2 bits of the conversion data are actually determined. The upper 2 bits of the resistor network do not need to be judged, so the conversion speed is faster, and its conversion speed is 96 ADCLK cycles. If the automatic search input voltage range is set in ACTL when the conversion is started, all 14 bits of conversion data will appear in ADAT, and the conversion time increases to 132 ADCLK cycles. The input signal at the input end is realized through the resistor-type sensor element. A0~A3 in the A/D input end can be programmed as the constant current source output end to power the sensor element. To realize this function, in addition to defining ACTL, an external resistor must be connected between pins SVCC and REXT to form a constant current source, and the constant current is output from the A/D input end. At this time, the detected signal is the voltage value on the sensor element. The relationship is VIN=0.25×Vsvcc×RSEN/REXT. Among them, Vsvcc is the reference voltage, RSEN is the sensor element resistance, REXT is the external resistor that constitutes the constant current source, and VIN is the voltage value detected on the sensor element. When the accuracy of A/D conversion is high, the possibility of interference with the low bit of data also increases. Therefore, the analog and digital power supplies of the MSP430P325 microcontroller are separate, including pins such as AVCC, AGND, DVCC, and DGND. To ensure the accuracy of A/D conversion, they should not be simply connected together in the circuit. It is ideal to divide the power supply into two groups, but it is often difficult to do in actual circuits. It can be isolated by adding an LC filtering decoupling circuit between AVCC and DVCC. Connecting a reverse-parallel diode in series between AGND and DGND can make the two points disconnected when the voltage is lower than 0.7V. When the idle input terminal is used as a digital channel, it is necessary to prevent interference with the adjacent analog channel. This interference is introduced through the capacitor between the channels. The way to avoid it is to avoid signal jumps in the digital channel during A/D conversion. Since the A/D conversion process utilizes a switched capacitor network, when the internal resistance of the signal source is too large, the conversion accuracy will be affected due to the large RC constant. The waiting input impedance of the A/D input terminal is approximately equivalent to a series circuit of a 2kΩ resistor and a 42pF capacitor. When ADCLK is 1MHz, the internal resistance of the signal source must be lower than 27KΩ to ensure conversion accuracy.
3. Relationship between external resistance and test accuracy
When using a platinum resistor for temperature measurement, the relationship between the external resistance and the constant current source current is
ISET=0.25×VSVCC/RSET (2)
Where: ISET is the constant current source current, VSVCC is the power supply voltage, and RSET is the external resistance.
The voltage VIN from the platinum resistor to the ground is
VIN=Rt(t) ×ISET (3)
It can be seen from formula (2) that there are two factors that affect the voltage detection accuracy of the two ends of the platinum resistor: one is the fluctuation of the power supply voltage, and the other is the accuracy and temperature stability of the external resistance. From the usage of the instrument, the voltage of the power supply battery of the instrument gradually decreases over time. If there is no corresponding compensation method, the temperature detection accuracy of the platinum resistor cannot be guaranteed. Therefore, this paper proposes the following compensation method.
MSP430P325 has 4 constant current source output A/D conversion channels (switchable). A resistor with the same resistance value as the external resistor RSET is connected to another channel. The resistor voltage reduction compensation is performed each time the A/D conversion is performed. The compensation method is as follows:
When the constant current source supplies power to the platinum resistor, the voltage across the platinum resistor is
VIN=0.25×VSVCC×Rt(t)/RSET (4)
V=0.25×VSVCC×R/RSET (5)
After A/D conversion, the digital value of the voltage across the platinum resistor is Nx, and the digital value of the voltage across the fixed resistor is N. Because the conversion accuracy and number of bits of A/D are consistent, the following result is obtained:
Nx/N=Rt(t)/R (6)
It can be seen from formula (6) that the A/D conversion result of the voltage across the platinum resistor has nothing to do with the power supply voltage. This method can also compensate for the discreteness of the reference voltage of the chip. To ensure the detection accuracy, the accuracy of the external fixed resistor R is the key factor. If the temperature detection range is 0-100°C, how should the accuracy of the external fixed resistor R be selected? The following is a quantitative analysis.
Nx/(N±ΔN)=Rt(t)/(R±ΔR) (7)
Dividing equation (6) and equation (7) yields the following result:
(N±ΔN)/N=(R±ΔR)/R (8)
If the resistance values of the external resistors RSET and R are both 500Ω, the resistance accuracy is required to affect the digital value by 1LSB (temperature detection accuracy 0.03℃), then the accuracy of the resistor R is 0.02%.
Starting from the A/D conversion principle of MSP430P325, the influence of power supply voltage fluctuation on detection accuracy is discussed in detail, and the compensation principle and the accuracy selection method of compensation resistor are analyzed, providing an excellent application example for other precision temperature measurement occasions. The compensation method proposed in this article has been successfully applied in an electronics company, and the compensation effect is satisfactory.
|