### A/D Conversion Using the ADC0838 - Differential MeasurementsUse of an NTC Thermistor in a Bridge to Measure Temperature

copyright, Christine M. Samuels, Peter H. Anderson
Department of Electrical Engineering
Morgan State University
Baltimore, MD 21239
August 15, '96

Introduction.

This is a continuation of the discussion of the operation of the ADC0838 analog to digital converter. It is set in the context of measuring temperature using a negative temperature coefficient (NTC) thermistor and deals specifically with making differential measurements.

This piece first briefly treats negative temperature coefficient (NTC) thermistors and then the use of a bridge and finally the use of an ADC0838 in making a differential measurement.

Assume the goal is to develop a system using NTC thermistors to measure temperatures in the range of 50 to 100 degrees F.

All parts in this discussion; 10K NTC thermistor, LM324 quad operational amplifier and ADC0838 analog to digital converter are available from Jameco.

Temperature Measurement Using NTC Thermistors.

[Much of the material relating to thermistors is taken from, Peter H. Anderson, Applications of Thermodynamics to Electrical Engineering, March, 96, ISBN 0-965337-2-0 \$7.00.]

Although this discussion is confined to measuring temperature, this is an excellent example of why electrical engineering has become a field which is interwoven with all others; manufacturing, the environment, medicine; etc. Electrical engineers can inexpensively and accurately measure voltage (or resistance) and time. Thus, any parameter; e.g., wind speed or direction, blood pressure, hydro carbon pollution, pH or temperature which can be converted to a voltage or a time varying voltage can then be measured electronically.

Basic Theory.

NTC thermistors have a predictable resistance characteristic which is a function of temperature. Thus, electrical engineers can measure resistance and calculate the temperature.

The thermistors we use are relatively small and therefore have low thermal lag. That is, temperature changes are quickly reflected in a varying resistance as the mass of the thermistor is small and it heats and cools quickly. Of course, "quickly" is a relative term.

Thermistors may be used in the open air. They may be epoxied to all manner of equipment; e.g., metal bars, metal pipes or to ICS to measure surface temperature. They may be placed inside a piece of plastic tubing and sealed so as to make immersion measurements.

Thermistors are inexpensive, typically less than \$1.00 and thus they are expendable.

The largest limiting factor is thermistors are made of plastic and thus cannot be used at high temperatures such as in an open flame. However, past students have used them up to 250 degrees F.

Two Point Model.

An expression for the resistance at any temperature is;

(1) R = R_o * exp (Beta (1/T - 1/T_o))

where Beta is a constant for a particular thermistor. Temperature T_o and T are usually in degrees Kelvin. Typical values for R_o and T_o are 10.0 KOhms and 300.0 degrees K. Values of Beta are typically in the range of 3000 - 4000. Note that T_kelvin = (T_f -32.0) / 1.8 + 273.0.

For this discussion, assume; R_o = 8870.0 Ohms, T_o = 300.9 degrees K and Beta = 3423. These values are based on actual calibrations performed at Morgan State University.

In Figure #1, expression 1 is plotted over the range of 50 to 100 degrees F. Note that at 50 degrees F, R_therm is about 18.0K and at 200 degrees F it is about 6.0 K. Lets assume a swing from 5.0 K to 20 K.

A general expression for temperature (T) as a function of resistance (R) is developed.

(2) 1/T = 1/Beta * ln(R) - 1/Beta * ln(R_o) + 1/T_o

Substituting R_o = 8870.0, T_o = 300.9 and Beta = 3423;

(3) 1/T = 0.292e-6 * ln(R) + 6.6906e-4

Note that this expression is in degrees K. Thus, if the thermistor's resistance is known, the temperature in degrees K may be calculated. From this, the temperature in degrees F may be calculated using the relation;

(4) T_f = (T_k - 273.0) * 1.8 + 32.0

Thus, if the resistance of a thermistor is known, the temperature in degrees F may be calculated.

Bridge Circuit.

Consider the bridge circuit illustrated in Figure #2A. Note that the voltages at nodes x and y are

(5) V_x = 20.0e3 / (20.0e3 + R_therm) * V_bridge

(6) V_y = 0.5 * V_bridge

(7) V_xy = V_x - V_y = (1/(1+R_therm/20.0e3) - 0.5) * V_bridge

(8) V_xy / V_bridge = (1/(1+R_therm/20.0e3) - 0.5)

V_xy / V_bridge is plotted in Figure #2B. Note that as the temperature varies from 50 to 100 degrees F, V_xy / V_bridge goes from near 0.0 to something less than 0.286.

See Figure #3. Note the voltage divider is adjusted such that V_ref = 0.28695 * V_bridge. Thus, in performing a differential measurement at xy; the voltage may be calculated from the A/D quantizing band as;

(9) V_xy = band * 0.28695 * V_bridge / 256

or

(10) V_xy / V_bridge = band * 0.28695 / 256 = 1.121e-3 * band

Substituting (10) into equation (8) and doing some algebra;

(11) R_therm = 20.0e3 (1- x) / x

where x = 1.121e-3 * band + 0.5

Knowing R_therm, the temperature may be determined using expressions 3 and 4.

A/D Differential Measurements.

Differential measurements may be made between adjacent channels on the ADC0838. That is, rather than having eight single ended channels, there are four differential channels, consisting of Ch 0 and Ch 1, Ch 2 and Ch 3, etc. For convenience, let us term these four differential channels, Ch_0_di ff, Ch_2_diff, Ch_4_diff and Ch_6_diff. That is, we understand that Ch_0_diff refers to the Ch 0 and Ch 1 pair. In each case, it is assumed that the designated channel is the more positive. That is, Ch_0_diff refers to the Ch_0 and Ch_1 pair with Ch_0 being the more positive channel.

Let us go further and define Ch_1_diff, Ch_3_diff, Ch_5_diff and Ch_7_diff as being the same channel pairs with the designated channel being the more positive. That is, Ch_1_diff refers to the Ch_0 and Ch_1 pair with Ch_1 being the more positive.

(This departs a bit from National's designation and you can see my pencil marks in the following table).

The multiplexer is set up for the differential mode and the specific channel pair is selected using the five bit control word discussed in previous sections.

Recall that the first bit of the control word is the Start Bit and is always a logic one. However, unlike single end measurements where the next bit, SGL/DIF, bit was a logic one, this bit is a logic zero for differential measurements.

Note that the next bit, the sign bit refers to which of the channels is the more positive. Thus, in considering the Ch_0 and Ch_1 pair, a logic zero indicates Ch_0 is the more positive and a logic one indicates Ch_1 is the more positive.

In Program AD0838_4.C, a differential measurement is performed on each of the four differential channels and the temperature in degrees F is determined.

Function, make_control_word is the same as in AD0838_1.C (or AD0838_2.C), except that the SGL/DIFF bit is set to a logic 0 (line 41).

```/*
**
** Program makes 4 temperature measurements.  See text.
**
** Illustrates how to make differential measurements.  Note that this
** is the same as program AD0838_1 except for the main and function
** make_control_word(int channel) and only these portions are included
** below.
**
** Christine Samuels, MSU, 15 August '96
*/

#include <stdio.h>                                            /* 1 */
#include <dos.h>                                              /* 2 */
/* 3 */
#define DATA 0x03bc                                           /* 4 */
#define STATUS DATA+1                                         /* 5 */
#define CONTROL DATA+2                                        /* 6 */
/* 7 */
int data = 0x00; /* note global */                            /* 8 */
/* 9 */
int make_measurement(int channel);                            /* 10 */
int get_val(void);                                            /* 11 */
int make_control_word(int channel);                           /* 12 */
void send_control_word (int word);                            /* 13 */
void clock();                                                 /* 14 */
void CS_high(void);                                           /* 15 */
void CS_low(void);                                            /* 16 */
/* 17 */
void main(void)                                               /* 18 */
{                                                             /* 19 */
int n, band;                                               /* 20 */
float x, R_therm, T_K, T_F;                                /* 21 */
/* 22 */
for(n=0; n<4; n++)                                         /* 23 */
/* make measurements at each of 4 differential channels */ /* 24 */
{                                                           /* 26 */
band = make_measurement(2*n);                            /* 27 */
/*Ch_0_diff, Ch_1_diff, etc */                           /* 28 */
x=1.121e-3 * band + 0.5;                                 /* 29 */
R_therm = 20.0e3*(1-x)/x;                                /* 30 */
T_K = 1.0/(0.292e-3 * log(R_therm) + 6.6906e-4);         /* 31 */
T_F = (T_K - 273.0) * 1.8 + 32.0;                        /* 32 */
printf("The T_f of channel %d is: %.2f.\n", 2*n, T_F);   /* 33 */
}                                                          /* 34 */
}                                                             /* 35 */

int make_control_word(int channel)                            /* 37 */
{                                                             /* 38 */
int word, lsb;                                             /* 39 */
/* 40 */
word = 0x10; /* 1 0000  Note that SGL/DIFF is at zero*/    /* 41 */
lsb = channel & 0x01;                                      /* 42 */
word = word | (lsb <<2);  /* 1 1 lsb 0 0 */                /* 43 */
word = word | (channel >>1); /* 1 1 lsb msb middle */      /* 44 */
return(word);                                              /* 45 */
}                                                             /* 46 */
/* 47 */
```