Application skills/compensation method for high-precision temperature measurement based on MSP430 microcontroller[Copy link]
Abstract : The A/D converter of the MSP430P315 microcontroller is used to realize the resistance detection of the resistive temperature sensor. The algorithm structure of the scale conversion is simplified by combining the table lookup and linear interpolation. The reduction of the battery voltage is compensated and the influence of the accuracy of the compensation resistor on the temperature detection is analyzed.
Keywords : single chip microcomputer linear interpolation compensation temperature detection
introduction
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, an American company, 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 a liquid crystal 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 of the precision constant current source is determined by an external precision resistor. At the same time, six 14-bit A/D converters and a liquid crystal controller 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
To calculate the temperature according to the above formula, it is necessary to solve the second-order equation. The calculation procedure is complicated and the accuracy is difficult to guarantee. For this reason, this article 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°C. The A/D conversion result is compared with the resistance value in the table until Rn≤RM<Rn+1. The comparison is stopped, and 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 of microcontrollers have the advantages of low power consumption, high anti-interference, and high integration. Among them, the MSP430P325 microcontroller 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 on 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 voltage range of the input signal 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, called range A, B, C, and D from low to high. Then the switched 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 high 2 bits of the conversion value are determined by the resistor network, and the low 12 bits of the conversion value are determined by the switched capacitor network.
When the conversion is started, the signal voltage range is set in ACTL. In fact, the upper 2 bits of the conversion data have been determined. The upper 2 bits of the resistor network do not need to be judged. Therefore, the conversion speed is faster, and its conversion speed is 96 ADCLK cycles. If the input voltage range is set to automatically search 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 achieve 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 separated, 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 the ADCLK is 1MHz, the internal resistance of the signal source must be less 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 resistor 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 resistor. The voltage VIN from the platinum resistor to ground is VIN=Rt(t) ×ISET (3)
From formula (2), it can be seen 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 resistor. From the use 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). Connect a resistor with the same resistance value as the external resistor RSET to another channel, and perform resistor voltage reduction compensation every time 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 A/D conversion accuracy and the number of bits are consistent, the following result is obtained: Nx/N=Rt(t)/R (6)
From equation (6), it can be seen 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 to 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Ω, and 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%.
Conclusion
Starting from the A/D conversion principle of MSP430P325, the influence of power supply voltage fluctuation on detection accuracy is discussed in detail. At the same time, 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.