One of the unique uses of the ARD-LTC2499 24-bit Analog to Digital Convert Shield is to measure thermocouples directly. Conventional solutions for digitizing thermocouples use a MAX31855 or MCP9600 to convert the voltage to a usable temperature, but these solutions need one part for each thermocouple sensor, and the part is tied specifically to the type of thermocouple being used. By using the LTC2499 to measure the thermoelectric voltage directly, we can measure up to 8 thermocouples per board, and because all of the conversion is done with math on the host processor, you can have any mix of thermocouple types that you want. It’s remarkably easy to do, and I’ll show you how just how easy it is to get started.
Before we get into exactly how to make this work, let’s take a look at how thermocouples actually work and how we use that to measure temperature.
Thermocouple Physics and Cold Junctions
Thermocouples, in the simplest sense, are two dissimilar metal wires that are joined at one end and used to measure temperature by detecting minute voltage differences between the wires. That’s a vast simplification, however. Thermocouples function due to the Seebeck effect, which says that a small potential will develop between two ends of a metal wire at different temperatures because energetic electrons will diffuse from the hot end to the cold end. So for example, if we take a nickel wire and put one end at 100C and the other end at 0C, electrons diffuse creating a slight voltage.
We can’t just measure this potential directly. We’d have to account for Seebeck effects in our meter leads, since one would be going from 100C to ambient, and the other will go from 0C to ambient. That’s not going to work well. Fortunately, each type of metal has its own relationship between the temperature difference and voltage created, known as a the Seebeck coefficient. Let’s say our example nickel wire develops 10uV for every degree Kelvin of difference between the ends. However, iron might only develop 2uV per degree Kelvin. (These numbers are all imaginary and for example only.) If we run a pair of wires – one iron, one nickel – and connect them at the point we want to measure, we can use this property to work out what the temperature is at the hot end.
How? That’s the beauty of the cold junction. As long as our meter connects to both wires at exactly the same temperature, we can work out what the potential is across each from the voltage we see. Let’s assume for a moment that our meter and meter connections are at 0C. So in our example, the nickel wire would be putting out 10uV/C, so for our 100C difference that’s 1000uV between the hot end and our meter. Our iron wire would develop 2uV/C, or 200uV, over that same distance. Using math (we know the potential will be 8uV/C, since one wire will be generating a reverse polarity to the other), we could work out that there’s 100C difference between our meter and the connection at the hot end.
Now of course in the real world, nothing is ever nice and linear. There are always non-ideal effects, and the actual math to for doing all this is a bit ugly. Fortunately there’s some lookup tables – known as the NIST ITS-90 standards – that give a way to convert standard thermocouple metal combinations into temperature. The bad news is that the tables all assume that the meter connection point – known as the cold junction – is at 0C. If you use the same wires from the cold junction to the meter, everything else cancels out, but it’s still annoying and usually infeasible to make your connections at exactly 0C.
Fortunately, that’s where cold junction compensation comes into play. If we know the temperature of the cold junction, we can use more math to calculate exactly how much voltage would be created between there and 0C. We can just add that in, and suddenly all of our calibration tables work again, because we’ve virtually compensated for the cold junction being at a non-zero temperature.
Note: While they’re called the hot and cold junctions, there’s nothing that specifically says they have to be in that relationship. The hot junction – the thermocouple itself – can actually be colder than the cold junction and work just fine thanks to all the math.
A Thermocouple Library
The NIST polynomials are 9th order and very computationally intensive in an effort to have one equation that tries to model the thermocouple over its entire range. For small 8-bit microcontrollers, that’s extremely taxing to implement. About a decade ago, Michael and I discovered a solution by Mosiac Industries that used much lower polynomials (4th order) divided up over discrete segments of the thermocouple’s measurement range. They’ve published a very complete reference about this solution and quite frankly, it’s brilliant. We’ve used their work and turned it into an easy-to-consume Arduino library called Thermocouple. Given a thermocouple type (at least from the usual suspects – B, E, J, K, N, R, S, and T), a thermocouple voltage, and a cold junction temperature, it can calculate the thermocouple temperature.
Putting It All Together
The LTC2499 at the heart of the ARD-LTC2499 provides a high precision, high accuracy way to measure small differential voltages. Its 24 bits spread over +/-2.048V of range provides a resolution of 244 nanovolts. Realistically, accounting for a couple least significant bits of error, that’s still sub-microvolt accuracy, which is far more than enough to measure thermocouple voltages. The part conveniently also includes an onboard temperature sensor. While not as good as having a temperature sensor at the cold junction (the terminal blocks), it’s accurate enough in most situations as there’s not likely to be much of a temperature difference between the block and the ADC chip.
Since the ARD-LTC2499 has 16 single ended or 8 differential inputs, you can use this method to measure up to 8 thermocouples using a single board. Also, since you’re measuring the voltage directly and converting in software, you can use any mix and match of thermocouple types, as long as you use the correct type objects to convert the resulting values.
Getting the Software
- Thermocouple Library – This is what handles all the math to convert from thermocouple voltage and cold junction temperature to the temperature measurement you want.
- Ard2499 Library – This is the driver for the ARD-LTC2499 board.
Within the next couple weeks, we intend to get both of these libraries so that they can be installed from the Arduino library manager. In the meantime, if you download the ZIP file (click the green “Code” button and select “Download ZIP”), you can then directly import them into the Arduino environment (Sketch->Include Library->Add .ZIP Library…). Once both libraries are installed, you should be able to go to File->Examples->ISE ARD-LTC2499 ADC Library->ard2499_thermocouple and open the example.
Setting Up the Hardware
For this, I’m just using a Sparkfun RedBoard Qwiic – pretty much our standard Arduino these days – and an Iowa Scaled Engineering ARD-LTC2499 shield on top. I’ve left all of the address jumpers on the shield in the Z position (factory default). (Since the LTC2499 has up to 27 addresses, you could theoretically have up to 216 thermocouples being measured by a single Arduino using 27 ARD-LTC2499 shields and 8 thermocouples per shield.)
Then I took a standard Type K thermocouple from eBay. It’s one of a batch that I bought to measure the inside of my toaster oven when reflow soldering PCBs. I cut the measuring end off with about a foot of wire, stripped the ends, and plugged the negative side into analog input 0 and the positive side into analog input 1 on the ARD-LTC2499.
The example sketch from above measures the thermocouple voltage between channel 0 and 1 differentially (since at these very low potentials you really want differential measurements to get rid of any stray noise) and also measures the LTC2499’s internal temperature. It then uses a TypeK object from the Thermocouple library to convert those to a temperature. If you open the Arduino serial console and set it to 9600 baud, you’ll see the output result.
How Well Does It Work?
Since my Fluke T3000 – a thermocouple temperature measurement unit – was sitting on the bench next to me while I was building this, I decided to do a little comparison with my newly built thermocouple measurement unit. I took the two thermocouples – one from each measurement solution – and wrapped them together with some wire to hold them together.
My first test case was my Yeti insulated coffee mug filled with ice water. I put a whole bunch of ice in it and water, and let it sit for 10 minutes with some occasional stirring to make it all a nice, even temperature right around freezing. The Fluke read 1.2C and the Arduino sketch was reading right around 1C. I’ve inset the Arduino serial monitor console into the picture so you can see both. Definitely within the margins of error.
The hot testing was a bit more difficult. I used my Metcal temperature controlled iron with a nice broad tip coated with a blob of solder to transfer the heat. Still, getting good transfer to the thermocouple was finicky and depended on how well the thermocouple joint was making contact with the iron. Regardless, with that test the Fluke read 367C, whereas the Arduino solution read 362C. I had to do them separately just to get reliable contact, and given I was seeing +/- 10C on both depending on contact quality, I’m going to also consider this one to be a pass.