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:

R_{T} = R_{O }exp\[B(1/T − 1/T_{O})\] (1)

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

This equation gives an error of about 0.3°C in a 50°C span^{1,2}. Such NTC behavior can be easily linearized using a loading resistor, R_{LIN}, placed across the analog input. For this arrangement, the resulting output voltage V_{O}(T) is:

V_{O}(T) = 5R_{LIN}/(R_{T} + R_{LIN}) (2)

The V_{O} versus T dependence has an S-shaped appearance (V_{O} 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, V_{O} 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 T_{C} (K), then an optimal linearizing resistor (R_{LIN}) can be added. The selection of the value of R_{LIN} is a critical step. This value can be calculated using the following equation^{1,2}:

R_{LIN} = R_{C}(B − 2T_{C})/(B + 2T_{C}) (3)

For illustration purposes, if an application requires temperature measurements over a range of 0°C to 40°C, then T_{C} = 293K. Suppose an NTC is chosen with R_{O} = 10k and B = 4400K^{2 }(T_{O }= 298K). Then, from equation 3, R_{LIN} = 9841 Ω, and from equation 1, the NTC resistance values (R_{T}) at 0°C and 40°C are derived. From equation 2, the circuit outputs (V_{O}) at 0°C and 40°C are calculated.

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

V_{O}(T) = 1.015 + 0.058T

where V_{O} is in volts and T is in degrees Celsius. Then:

T = 17 V_{O }

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* (V_{O} 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 R_{LIN} with a potentiometer for error compensation.

References:

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