Friday, January 13, 2017

Simple electronic thermometer using STM32F030 and thermocouple. Part 1.

It has been a while since I blogged about my little thermometer project. Meanwhile I did some progress, but as usually put it aside because more urgent matters. Newertheless, lets try to continue.

I will try to split my progress into a number of smaller blogs, starting from basics and hoping to get some working results.

Thermocouples

As defined in wikipedia:

A thermocouple is an electrical device consisting of two dissimilar conductors forming electrical junctions at differing temperatures. A thermocouple produces a temperature-dependent voltage as a result of the thermoelectric effect, and this voltage can be interpreted to measure temperature. Thermocouples are a widely used type of temperature sensor.

So theoretically my digital thermometer shall perform a simple algorithm:

  1. Measure voltage value provided by thermocouple
  2. Take an empiric curve provided by NIST and do reverse lookup (from Volts to degrees Celsius) to figure out the temperature.

Not that easy!

Cold Junction Compensation

The web contains great number of explanations about the cold junction problem. For example the TI guide provides some insight.

Basically, thermocouple has two ends. One end is used to measure the target temperature it is called the Hot Junction. The other end is normally connected to a thermometer and is called the Cold Junction. The problem is that the Cold Junction forms kind of parasitic thermocouple with leads connected to the thermometer. Since the thermometer itself has non-zero temperature it provides distortion of the Hot Junction measurements.

The empiric curves provided by NIST assume the Cold Junction at temperature zero degrees Celsius. Thus, some action is needed to reverse the distortion provided by the Cold Junction.

Normally the problem solved by putting temperature sensor near the thermocouple connection. I will use a thermistor (see my previous blog) to figure out the temperature of the Cold Junction.

Now my theoretical thermometer's algorithm is more complicated:

  1. Measure voltage value provided by thermocouple. Lets call it $V_{therm}$
  2. Measure temperature at Cold Junction provided by thermistor. Lets call it $T_{CJ}$
  3. Use NIST curves to lookup distortion voltage corresponding to $T_{CJ}$. I will designate this value as $V_{CJ} = V_K(T_{CJ})$. Here $V_K()$ is an approximation of the Celsius to Volts curve for K-Type thermocouple. For other types of thermocouples it is same calculation but curves are different.
  4. Now it is possible to calculate the undistorted voltage at Hot Junction: $V_{HJ} = V_{therm} - V_{CJ}$. The same value we would measure with Cold Junction at zero degrees Celsius.
  5. Use reverse function $V^{-1}_K()$ to figure out temperature at Hot Junction: $T_{HJ} = V^{-1}_K(V_{HJ}) = V^{-1}_K(V_{therm} - V_{CJ}) = V^{-1}_K(V_{therm} - V_K(T_{CJ}))$

Better theoretically, but there are still couple of technical problems... More will come.