ChipCenter Questlink
SEARCH CHIPCENTER
Search Type:
Search for:




Knowledge Centers
Product Reviews
Data Sheets
Guides & Experts
News
International
Ask Us
Circuit Cellar Online
App Notes
NetSeminars
Careers
Resources
FAQ
EE Times Network
Electronics Group Sites

  Analog Avenue

    Columns

Archives | Feedback

Implementing a Direct Thermocouple Interface with a High Precision A/D Converter and a Microcontroller
by Mike Mitchell, Texas Instruments, Inc.

Using thermocouples can sometimes be a difficult task. Often, precision amplifiers are needed to amplify the low-level voltage before performing an A/D conversion. In addition, thermocouples are non-linear, so complex math routines are needed to perform linearization on the A/D conversion results to determine the corresponding temperature value. This article gives a brief overview of thermocouples and the need for reference-junction compensation. It then shows how a high-resolution A/D converter such as the ADS1240 can be used to reduce or remove the need for the pre-amplification. It also shows how data tables can be utilized to simplify the task of determining the temperature from the A/D data by removing the need for the complex math linearization routines. Complete schematics are given and a complete code listing is available. The code provides .1 degree C resolution from 0 - 99.9ºC.

Thermocouples

Thermocouples are constructed of two dissimilar metals welded at one end. They produce a voltage at the non-welded end relative to the temperature difference between the two ends of the thermocouple. There are many types of thermocouples (a type K was used in this project) and much has been written on thermocouples and thermocouple usage. A simple search on the Internet can provide much information for anyone wanting to learn the intricate details of thermocouples and thermocouple usage, whereas this article only skims the surface on thermocouples themselves.

The voltage produced by thermocouples depends on the temperature difference between both ends of the thermocouple. So, it is not enough to simply measure the voltage to determine the temperature. That will only tell you the temperature difference between the two ends of the thermocouple. The temperature of the cold junction (the connection of the thermocouple to the measuring device) affects the voltage produced at the thermocouple end. As a result, some type of cold junction compensation is required. Often, circuits are employed to produce a voltage proportional to the cold junction temperature. This voltage is injected into the circuit and is part of the typical thermocouple signal conditioning circuitry.

Another technique of cold junction compensation involves measuring the temperature of the junction with a thermistor or some other type of temperature sensor. This is the technique employed here. In this technique, the temperature of the welded end of the thermocouple can be determined from knowing the cold junction temperature and measuring the thermocouple voltage. For highest accuracy, this technique requires the use of an isothermal block, which is a mechanical block or structure that assures the thermocouple junction and the thermistor are held at the same temperature. I didn't use an isothermal block for this simple application.

The voltage thermocouples produce is standardized by the National Institute of Standards and Technology. Data tables for thermocouple voltages are available from the NIST. Photo 1 shows the completed project and a complete schematic is shown in Figure 1.


click for larger image in .pdf format

Figure 1: This complete schematic shows the thermocouple interface. Header JP2 is only required for in-system debug.

Photo 1: The circuit for this project is small and easy to build. The large chip is the '430, the medium chip is the ADS1240, and the small chip is the reference. The header is only required for in-system debug.

Implementation

The circuit is relatively simple. The thermocouple connects directly to the analog inputs of the ADS1240, with a resistor divider providing some bias to allow for negative thermocouple readings. A thermistor is used for the cold junction compensation and is implemented in a simple resistor divider, also connected directly to the ADS1240. The MSP430 provides the conversion clock and interfaces to the serial port of the ADS1240. The communication link is implemented via general-purpose I/O on the '430 since there is no serial port on the specific MSP430 device I chose. The integrated LCD driver on the MSP430 makes the LCD connections easy. The LCD used here is a static, 3.5 digit LCD from Varitronix, model number VI-302. It is also available from Dig-Key. Note that all the segments were not used. I only connected 3 digits and a decimal point so the temperature could be displayed.

The program flow is shown in Figure 2. The MSP430 and the ADS1240 are both initialized after a reset. The FLL+ and DCO (clock system) of the '430 are configured to give an MCLK of 1.507 MHz. This frequency is used for the CPU and is used externally to clock the ADS1240. This frequency was chosen for the ADS1240 because it is fast enough for the application, but will allow some power savings over the nominal 2.4576 MHz reference in the ADS1240 datasheet. For more information on the FLL+, DCO, or any other MSP430x41x peripheral, refer to the MSP430x4xx Family User's Guide[1]. For more information on the MSP430F41x devices, see the MSP430x41x data sheet[2].


click for larger image in .pdf format

Figure 2: Program Flow

To set up the ADS1240, a reset command is issued first. The input multiplexer is set for channel 0 and 1 for the plus and minus inputs, respectively. These are for the plus and minus sides of the thermocouple. The data rate is selected for the ADS1240 as the slowest it offers. This results in about 2.3 conversions per second, rather than the 3.75 listed in the datasheet, because the values in the datasheet assume a clock of 2.4576 MHz, whereas this application uses a clock of 1.5 MHz. Next, interrupts are enabled on the MSP430 and the SELFGCAL command is issued to the ADS1240.

The SELFGCAL command works best when the programmable gain amplifier (PGA) of the ADS1240 is set to a gain of 1. The SELFGCAL requires some time to complete. The DRDY\ line of the ADS1240 will go low to signal the completion of the SELFGCAL process. Interrupts are enabled on the MSP430 at this point to allow the MSP430 to go into low power mode 0 (LPM0) while the SELFGCAL is being executed and be interrupted by the ADS1240 when it is completed. After the SELFGCAL command has completed, the programmable gain amplifier (PGA) is set for a gain of 16 and the SELFOCAL command is issued to calibrate the offset. For more information on the ADS1240 refer to its datasheet[3].

After initialization the code begins the mainloop (see listing 1), which is a succession of calls to other routines. The first instruction of the mainloop puts the MSP430 into LPM0. The MSP430 stays in LPM0 until the DRDY\line from the ADS1240 goes low, signaling that data is ready to be read. When the DRDY\line goes low, the MSP430 receives the P1.5 interrupt and awakens to service it. The interrupt service routine then clears the appropriate status register bits so the MSP430 returns from the interrupt in active mode.

Click Here for Listing 1

Listing 1: The mainloop is a succession of calls to other routines with a little power-down mixed in.

Next, a call is made to the routine that reads the ADS1240. This value is for the thermocouple. Upon return from that routine, the MSP430 is again put into LPM0 to wait for the next DRDY\. After the next DRDY\, the ADS1240 is ready to be read again, so a call is made to the routine to read the thermistor value. Upon return from reading the thermistor value, the MSP430 is ready to determine the temperature. Interrupts are disabled and calls are made to routines that convert the thermistor and thermocouple ADC values into their respective temperatures and to determine the absolute temperature based on the thermistor and thermocouple temperatures. After the temperatures are determined, interrupts are re-enabled and a call is made to display the absolute temperature on the LCD. Then the whole process starts over.

Reading the Thermistor and the Thermocouple

The routines to read the thermocouple and thermistor A/D conversion values from the ADS1240 are very similar. Each sends the RDATA command and then clocks the data out of the ADS1240. Then, each sets up the PGA and mux settings of the ADS1240 for the next conversion. The routine to read the thermocouple value sets up the ADS1240 to perform a conversion on the thermistor. The thermistor ADC value is then available at the next DRDY\. Likewise, the routine to read the thermistor value sets up the ADS1240 to perform a conversion on the thermocouple.

As previously mentioned, the thermistor circuit is a 10k-ohm resistor and 10k-ohm thermistor forming a resistor divider. The top of the divider is connected to the reference and the bottom to ground. This provides a voltage input to the ADC that varies with temperature. I used a negative temperature coefficient (NTC) thermistor, so the thermistor resistance (and voltage) decreases as temperature increases (see Figure 1). Perhaps a more common way of measuring a thermistor is with a slope A/D conversion. A slope conversion was not employed in this application because a high-performance, precision ADC was already in use, and performing the slope A/D conversion would have unnecessarily complicated the application and the code. A complete application report and code examples are available to show how to perform a slope A/D conversion with the MSP430 (See the MSP430 Web site http://www.ti.com/sc/msp430 and application note MSP430 Based Digital Thermometer[4]).

Determining Temperature

The routine to determine the thermistor temperature from its ADC value is shown in listing 2.

Click Here for Listing 2

Listing 2: The routine to determine the thermistor temperature uses a table lookup for nearest whole degree with interpolation to tenths of a degree.

First, a table lookup is performed to determine the temperature to the nearest degree. Then, an interpolation is done to determine the temperature to the nearest tenth of a degree. To do this, first the nearest whole degree temperature is multiplied by 10 and saved to RAM.

Then, the tenths are determined from the following equation:
((higher-ADCvalue)x10)/(higher-lower) where:
ADCvalue = ADC conversion value of thermistor voltage
higher = the next higher value in the table
lower = the next lower value in the table

Once the tenths are interpolated, they are added to the nearest whole temperature that was multiplied by ten previously. Now the thermistor temperature is stored in the form of XX.X in binary format.

The table of thermistor values shown in the complete code listing is specific to this application. It uses measured values for the 10K resistor and for the ADC reference and only uses 16 of the 24 ADC bits. The general formula for computing the table is:

where:

N = desired resolution of the A/D conversion (The ADS1240 is a 24-bit A/D converter, but for this application only the upper 16-bits were used, so in this case, N would be 16).

voltage = resulting voltage from the voltage divider
Vref = reference for the ADS1240

For this application the equation for the voltage divider is:

where:

Rt = thermistor resistance and
V = the voltage source for the divider - Vref in this application.

Combining the two equations results in:

which reduces to:

Determining the thermocouple relative temperature is done with a lookup table and tenths interpolation just like the thermistor temperature (see listing 3).

Click Here for Listing 3

Listing 3: The routine to determine the thermocouple temperature is very similar to the thermistor routine - using a table look-up for nearest whole degree with interpolation to nearest tenths of a degree.

If the temperature of the thermocouple tip is below the cold junction temperature, the voltage from the thermocouple will be negative and the ADC value will be negative. At the completion of the routine the thermocouple temperature is stored in RAM in 2s compliment binary format in the form of XXX.X

As with the thermistor, the table of values used for the thermocouple temperature lookup is specific to this application and incorporates measured values. The general formula for computing the table is:

where:

N = desired resolution of A/D conversion (The ADS1240 is a 24-bit A/D converter, but for this application only the upper 16-bits were used, so in this case, N would be 16.)
PGA = Gain from the programmable gain amplifier
Vref = Reference for the ADC
Vtc = Thermocouple voltage

The temperature of the thermocouple tip is computed by adding the thermistor temperature to the relative thermocouple temperature. After adding, the result is checked to see if it is negative. If so, it falls outside of the range of this application (0-99.9ºC). But the range checking is performed in the display routine, so if the absolute temperature is negative, then it is simply stored in RAM as a negative value. On the other hand, if the temperature is positive, it is converted to BCD format and stored in RAM in BCD format.

Displaying the Results

The DISPLCD routine checks the absolute temperature to make sure it falls within the specified range. If not, either an L or an H is displayed on the LCD to indicate the out-of-range temperature. If it is within range the bits are manipulated appropriately for display on the LCD. The code in this application report is written specifically for the Varitronix VI-302 LCD. The display routine will need to be modified for the LCD of your choice.

Conclusion

While traditional thermocouple circuits can be complex to design and implement, this article shows how high-resolution A/D converters and microcontrollers can simplify the task.

References

  1. MSP430x4xx Family User's Guide, Texas Instruments Inc. , SLAU056A, July 2001
  2. MSP430x41x data sheet, Texas Instrument Inc., SLAS340A, July 2001
  3. ADS1240 data sheet, Texas Instruments, Inc., SBAS173A, June 2001
  4. MSP430 Based Digital Thermometer, Texas Instruments, Inc., SLAA038, May 1999.

Author's Bio:

Mike Mitchell received a BSEE from Texas A&M University in 1992. He works for Texas Instruments, Inc. as an MSP430 Applications Engineer where he writes application reports and code examples and enjoys helping customers and spreading the word about the MSP430. You may reach him at Phone: (214) 480-3478; Fax (214) 480-3160 Email: MLM@ti.com.

Analog Main | Product of the Week | Columns | Editorial | Tech Notes
Click here to get your listing up.

Copyright © 2003 ChipCenter-QuestLink
About ChipCenter-Questlink  Contact Us  Privacy Statement   Advertising Information  FAQ