Electronic Design

# Microcontroller Makes Linear Temperature Measurement Simple

Many microcontroller units include an internal analog-to-digital converter (ADC). For instance, most of Motorola's M68HC11 family members have an analog-to-digital subsystem, including an 8-bit ADC, an analog multiplexer, and an analog port (port E) with eight analog input channels. Any available analog-to-digital port pins can be used to implement a simple thermometer with a temperature span of about 40°C to 50°C, minimal incremental cost, and only 24 bytes of additional code in a 68HC11-based system.

In this circuit, a low-cost negative-temperature-coefficient (NTC) thermistor is used as the sensor element (Fig. 1). It's well known that NTC resistors have a highly nonlinear resistance versus temperature characteristic. This is usually modeled as:

RT = RO exp\[B(1/T − 1/TO)\]      (1)

where T is the absolute temperature (in degrees Kelvin), and TO is a reference temperature (usually 298K). RO is the resistance at TO, in ohms, while B represents the material constant of the NTC sensor, in degrees Kelvin. Both RO and B are sensor parameters provided by manufacturers.

This equation gives an error of about 0.3°C in a 50°C span1,2. Such NTC behavior can be easily linearized using a loading resistor, RLIN, placed across the analog input. For this arrangement, the resulting output voltage VO(T) is:

VO(T) = 5RLIN/(RT + RLIN)      (2)

The VO versus T dependence has an S-shaped appearance (VO rises when T increases). This S-shaped curve can be considered linear over a temperature range of about 40°C to 50°C. Due to the large NTC sensitivity, VO varies several volts at typical room temperatures (e.g., from about 1 to 4 V), eliminating the need for an amplifier.

If a linear behavior is expected in a temperature range centered around TC (K), then an optimal linearizing resistor (RLIN) can be added. The selection of the value of RLIN is a critical step. This value can be calculated using the following equation1,2:

RLIN = RC(B − 2TC)/(B + 2TC)      (3)

For illustration purposes, if an application requires temperature measurements over a range of 0°C to 40°C, then TC = 293K. Suppose an NTC is chosen with RO = 10k and B = 4400K2 (TO = 298K). Then, from equation 3, RLIN = 9841 Ω, and from equation 1, the NTC resistance values (RT) at 0°C and 40°C are derived. From equation 2, the circuit outputs (VO) at 0°C and 40°C are calculated.

With these values, we can find the approximate linear dependence:

VO(T) = 1.015 + 0.058T

where VO is in volts and T is in degrees Celsius. Then:

T = 17 VO

approximating to integer values.

For instance, if the ADC voltage references are 0 V and +5 V, then 1 bit is approximately 20 mV. When the 68HC11 internal ADC returns a binary result in variable hex (VO converted to a digital word), then the temperature this value represents is T = 17 × (0.020 × hex) − 18. This expression can be rewritten as T = (17 × hex/50) − 18. This can be easily programmed into a 68HC11 microcontroller by making use of the 68HC11's MUL (integer multiply) and IDIV (integer divide) instructions (see the listing).

The error achieved with this procedure is always less than 1.3°C in a 40°C range (including NTC tolerances). It can be further reduced, however, by implementing RLIN with a potentiometer for error compensation.

References:

1. R. Pallas-Areny and J.G. Webster, Sensors and Signal Conditioning, John Wiley & Sons, 1991.
2. Thermistors Catalogue, Therrnometrics Inc., Somerset, U.K., 1993.