MAX31856: Explaining the Thermocouple Digital Converter

Posted by

Introduction to the MAX31856 Thermocouple Converter

The MAX31856 is a highly integrated thermocouple converter that provides a complete thermocouple digitization solution. It includes precision reference junction compensation, thermocouple linearization, and digital output in a small package.

Key features of the MAX31856 thermocouple converter include:

  • Supports 8 common thermocouple types (K, J, N, R, S, T, E, B)
  • 19-bit resolution ADC
  • 0.0078°C thermocouple temperature resolution
  • 0.0625°C reference junction temperature resolution
  • Operating supply voltage range of 3.0V to 3.6V
  • SPI-compatible interface up to 5 MHz
  • Detects open thermocouple conditions
  • Overtemperature and undertemperature fault detection

How a Thermocouple Works

A thermocouple is a temperature sensor that consists of two dissimilar metal wires joined together at one end, called the hot junction or measurement junction. When the junction experiences a temperature gradient relative to the other end of the wires (the cold junction or reference junction), a voltage is generated that is approximately proportional to the temperature difference between the junctions. This effect is called the Seebeck effect.

The relationship between the temperature gradient and generated voltage is nonlinear and depends on the thermocouple type, which is defined by the composition of the two metal wires.

Common thermocouple types and their temperature ranges include:

Type Temperature Range
K -200°C to +1350°C
J -210°C to +1200°C
N -200°C to +1300°C
T -200°C to +400°C
E -200°C to +1000°C
R -50°C to +1750°C
S -50°C to +1750°C
B +250°C to +1800°C

To accurately measure the temperature at the hot junction, the cold junction temperature must be known. Traditionally, the cold junction was kept in an ice bath at a stable 0°C. For convenience, modern thermocouple converters like the MAX31856 measure the cold junction temperature and perform compensation calculations digitally.

MAX31856 Functional Diagram

The MAX31856 integrates all the essential components for digitizing a thermocouple:

The main functional blocks are:

  1. Thermocouple Bias and ADC: Amplifies and digitizes the thermocouple voltage. The ADC has 19-bit resolution.

  2. Reference Junction Sensor: Measures the temperature of the cold junction where the thermocouple connects to the MAX31856. Uses a diode temperature sensor.

  3. Digital Control Logic: Oversees operation of the MAX31856, including linearization, cold junction compensation, fault detection, and the digital interface.

  4. Voltage Reference: Provides a stable reference voltage for the ADC.

  5. SPI Interface: Allows an external microcontroller to communicate with and configure the MAX31856 using an SPI-compatible protocol.

Connecting a Thermocouple to the MAX31856

The MAX31856 has a straightforward hookup for a thermocouple:

The thermocouple wires connect directly to the T+ and T- pins. Note that thermocouple polarities are color coded by type:

Type Positive Lead Negative Lead
K Yellow Red
J White Red
N Orange Red
T Blue Red
E Purple Red
R Black Red
S Black Red
B Gray Red

Be sure to observe proper polarity when connecting the thermocouple. Reversing the leads will result in inaccurate readings.

A 0.1 μF ceramic bypass capacitor should be placed close to the T+ and T- terminals to reduce noise. The BIAS pin can be left unconnected.

Configuring and Reading the MAX31856

The MAX31856 has several registers that control its operation and provide the digitized thermocouple temperature output. All register access is through the SPI interface.

SPI Interface

The MAX31856 uses an SPI-compatible 4-wire interface:

  • CS (Chip Select): Active-low input that enables the SPI interface when asserted.
  • SDI (Serial Data In): Input for data sent from the SPI master to the MAX31856 slave.
  • SDO (Serial Data Out): Output for data sent from the MAX31856 slave to the SPI master.
  • SCLK (Serial Clock): Clock input that synchronizes data transfer. Data is latched on the rising edge of SCLK when CS is low.

The SPI interface supports clock speeds up to 5 MHz and uses SPI MODE 1 (CPOL = 0, CPHA = 1). Data is transferred MSB first.

Register Access

The MAX31856 has a total of six 8-bit registers used for configuration and data output. A register is read or written by sending a one-byte command composed of:

  • A register address (5 bits)
  • A R/W bit indicating read (1) or write (0)
  • Two “don’t care” bits (set to 0)

This command byte is followed by one or two data bytes, depending on the specific register.

For multi-byte registers, data is sent MSB first. Any unimplemented bits are read as 0.

The MAX31856 register set includes:

Register Address R/W Description
CR0 00h R/W Configuration 0
CR1 01h R/W Configuration 1
MASK 02h R/W Fault Mask
CJHF 03h R Cold Junction High Fault Threshold
CJLF 04h R Cold Junction Low Fault Threshold
LTHFTH 05h R/W Linearized Temperature High Fault Threshold MSB
LTHFTL 06h R/W Linearized Temperature High Fault Threshold LSB
LTLFTH 07h R/W Linearized Temperature Low Fault Threshold MSB
LTLFTL 08h R/W Linearized Temperature Low Fault Threshold LSB
CJTO 09h R Cold Junction Temperature Offset
CJTH 0Ah R Cold Junction Temperature MSB
CJTL 0Bh R Cold Junction Temperature LSB
LTCBH 0Ch R Linearized TC Temperature MSB
LTCBM 0Dh R Linearized TC Temperature Middle Byte
LTCBL 0Eh R Linearized TC Temperature LSB
SR 0Fh R/W Status

Some key configuration settings in the CR0 and CR1 registers include:

  • Thermocouple Type: The CR1 register bits 7-5 set the type of thermocouple connected (K, J, T, etc.)
  • Conversion Mode: The CR0 register bits 7-6 set the conversion mode to Normally Off (00), Automatic (01), or Manual (10).
  • Averaging: The CR1 register bits 4-2 set the number of samples averaged per conversion from 1 to 128.
  • ADC Resolution: CR1 register bit 1 sets the ADC resolution to 12 bits (0) or 16 bits (1).

After configuration, the thermocouple and cold junction temperatures can be read from the LTCB and CJT registers respectively. The LTCB register provides a signed 19-bit temperature value and the CJT register provides a signed 12-bit temperature value.

Temperatures are represented in degrees Celsius. To convert the LTCB temperature to Celsius, the 19-bit value is multiplied by the resolution of 0.0078°C per bit. To convert the CJT temperature to Celsius, the 12-bit value is multiplied by the resolution of 0.0625°C per bit.

The MAX31856 also provides fault detection for open circuit and over/under temperature conditions. Fault thresholds are set in the LTHFT, LTLFT, and CJF registers. Any detected faults are flagged in the Status register and optionally trigger the FAULT output pin.

Example Arduino Sketch for the MAX31856

Here is a simple Arduino sketch that demonstrates configuring the MAX31856 and reading the thermocouple temperature using the SPI interface:

#include <SPI.h>

// MAX31856 SPI Pins
#define CS 10
#define SDI 11 
#define SDO 12
#define SCLK 13

// Thermocouple type (K)
#define TYPE K

void setup() {
  // Initialize SPI
  pinMode(CS, OUTPUT);
  digitalWrite(CS, HIGH);  
  SPI.begin();
  SPI.beginTransaction(SPISettings(5000000, MSBFIRST, SPI_MODE1)); 

  // Configure MAX31856
  writeReg(0x00, 0x80);   // CR0: Auto-conversion, Fault detection
  writeReg(0x01, TYPE<<4 | 0x03);  // CR1: Type K, 16 avg samples, 19-bit
}

void loop() {
  float tc_temp = readThermocouple();

  if (tc_temp == 0 && (readReg(0x0F)>>2 & 0x01)) {
    // Handle open circuit fault
    Serial.println("Open thermocouple!");
  }
  else {
    // Print temperature
    Serial.print("Thermocouple: ");
    Serial.print(tc_temp);
    Serial.println(" C");
  }

  delay(500);
}

float readThermocouple() {
  int32_t temp32;

  temp32 = readReg24(0x0C);

  if(temp32 & 0x00800000)
    temp32 |= 0xFF000000;  // Negative value

  return temp32/4096.0*0.0078125; 
}

void writeReg(uint8_t addr, uint8_t data) {
  digitalWrite(CS, LOW);
  SPI.transfer(addr);
  SPI.transfer(data);
  digitalWrite(CS, HIGH);
}

uint8_t readReg(uint8_t addr) {
  uint8_t data;

  digitalWrite(CS, LOW);
  SPI.transfer(addr | 0x20);
  data = SPI.transfer(0x00);
  digitalWrite(CS, HIGH);

  return data;
}

uint32_t readReg24(uint8_t addr) {
  uint32_t data = 0;

  digitalWrite(CS, LOW);  
  SPI.transfer(addr | 0x20);
  data = SPI.transfer(0x00);
  data <<= 8;
  data |= SPI.transfer(0x00); 
  data <<= 8;
  data |= SPI.transfer(0x00);
  digitalWrite(CS, HIGH);

  return data;
}

This sketch configures the MAX31856 for a Type K thermocouple with automatic conversion mode, 16 samples averaged per reading, and 19-bit ADC resolution.

In the main loop, it reads the thermocouple temperature from the LTCB registers and prints it to the serial monitor. It also checks the Status register for a fault condition and reports if the thermocouple is open.

The key steps are:

  1. Initialize the SPI interface
  2. Write configuration values to the CR0 and CR1 registers
  3. Read the thermocouple temperature from the LTCB register
  4. Convert the raw 19-bit signed value to degrees Celsius
  5. Read the Status register and check for faults
  6. Print the temperature or fault status

With this sketch loaded on an Arduino connected to a MAX31856 and thermocouple, you can easily read the digitized thermocouple temperature.

FAQ

What is the MAX31856?

The MAX31856 is a precision thermocouple-to-digital converter that integrates all the circuitry needed to convert a thermocouple signal to a digital output. It supports multiple thermocouple types, performs cold junction compensation and linearization, and provides a simple SPI interface.

What thermocouple types does the MAX31856 support?

The MAX31856 supports 8 common thermocouple types:

  • Type K
  • Type J
  • Type N
  • Type R
  • Type S
  • Type T
  • Type E
  • Type B

The specific type is software configurable.

How do I connect a thermocouple to the MAX31856?

The two thermocouple wires (positive and negative leads) connect directly to the T+ and T- terminals on the MAX31856. Be sure to observe the correct polarity – the wire colors indicate polarity and vary by thermocouple type.

It’s recommended to place a 0.1 μF ceramic surface mount bypass capacitor close to the T+ and T- terminals to minimize noise.

What is cold junction compensation?

Cold junction compensation is a technique used to correct for the “cold” junction where the thermocouple wires connect to the measurement terminals.

A thermocouple generates a voltage proportional to the temperature difference between the “hot” junction (the measurement point) and “cold” junction (the connection point). To get an accurate absolute temperature reading, the temperature at the cold junction must be known.

The MAX31856 has a built-in temperature sensor at the cold junction that it uses to measure the cold junction temperature directly. It then uses this value to digitally compensate the thermocouple temperature reading.

What is the output resolution of the MAX31856?

The MAX31856 has a 19-bit ADC for digitizing the thermocouple voltage. This provides a resolution of 0.0078°C per bit.

The cold junction temperature is measured with a 12-bit ADC, providing a resolution of 0.0625°C per bit.

Conclusion

The MAX31856 is a highly integrated and easy-to-use thermocouple-to-digital converter that simplifies adding precision temperature measurement to any project. With support for 8 standard thermocouple types, integrated signal conditioning, and a digital SPI interface, it’s an ideal choice for embedded applications.

By understanding the key principles of thermocouples and how the MAX31856 digitizes thermocouple signals, you can quickly integrate thermocouple sensors into your designs. The provided example Arduino sketch outlines the basic steps for configuring and reading the MAX31856.

For more detailed information on the MAX31856, refer to the official datasheet.

Leave a Reply

Your email address will not be published. Required fields are marked *