Introduction to Thermocouple Compensation
When a thermocouple is used with a microprocessor based measuring device, it is possible to provide linearization and reference junction compensation in software. The measuring procedure is to take two readings: the thermocouple voltage e and the reference junction temperature T, using an alternative temperature sensor (not a thermocouple).
The most common method of linearization is to use one or more polynomials. In the example below, the T type thermocouple is linearized using ten polynomials, each covering a small temperature range. A polynomial is a mathematical expression of the form:
y = c_{0} + c_{1}.x + c_{2}.x^{2} + c_{3}.x^{3} .... + c_{n}.x^{n}
where x is the input variable, y is the linearized and scaled result. The c_{n} terms are constants referred to as the polynomial coefficients. The value of n is the order of the polynomial. Each polynomial has its set of coefficients and each thermocouple has its own set of polynomials.
A regression process calculates the polynomial coefficients . The choice of polynomial order is important. The higher the order, the greater the temperature range over which it can apply, but the longer it takes to evaluate because of the extra maths involved. The lower the order, the more polynomials are required, again taking more time to decide which polynomial to use. A typical compromise is for the order to be in the range of 2 to 4.
With some thermocouples, a set of polynomial coefficients is defined by the standard. In most cases the order is too high (up to 15) for precision high speed systems.
A polynomial must only be used over its valid input variable range, otherwise significant errors will occur. The point where polynomials change should be carefully chosen to avoid significant discontinuities.
This whole process can take a great deal of time if all thermocouples are to be supported.
Linearizing a reading: stepby step
Capgo uses a six step process to linearize a thermocouple reading.
Step 1
Measure the thermocouple voltage e (scaled to microvolts) and the reference junction temperature T (scaled to degrees Celsius) using an alternative temperature sensor such as Pt100. The reference junction temperature is typically close to the ambient temperature of the measuring instrument.
Note: It may not be necessary to read the reference temperature for every thermocouple reading, if it is known to change much slower than the thermocouple scan rate.
Step 2
To calculate the reference junction temperature compensation voltage, the appropriate polynomial must be selected. To do so, compare the reference temperature to a number of threshold temperatures. Also check for outofrange inputs. The following pseudo code illustrates the process.
if T > 80.0°C then Error = "Reference junction over range"
else if T > 2.236°C then poly = 0
else if T > 40.0°C then poly = 1
else Error = "Reference junction under range"
end if

The range of temperature for which some thermocouples are defined does not always cover the desired range of the measuring equipment.
Step 3
Calculate the correction voltage using a second order polynomial equation:
e_{c} = c_{0} + c_{1}.T + c_{2}.T^{2}
where the polynomial coefficients are drawn from the following table, based on the value of "poly" from step 2:
Polynomial
" poly" 
c_{0} 
c_{1} 
c_{2} 
Temperature Range
° C 
0 
0.435 
38.605428 
0.042233 
80 to 2.236 
1 
0.051 
38.769854 
0.045276 
2.236 to 40 
Note: There has been no attempt made to optimise the efficiency of the pseudo code  it is for illustrative purposes only. Programmers will see the opportunities!
Step 4
Correct the measured thermocouple voltage by adding the compensation voltage
e = e + e_{c}
Step 5
To convert the voltage e to a temperature, the correct polynomial must be selected. Compare the corrected input voltage to a number of threshold voltages (in microvolts) to identify the appropriate polynomial to use:

if e > 2.087E+4 then Error = "Thermocouple over range" !400°C
else if e > 1.170E+4 then poly = 0 ! 242°C
else if e > 4.827E+3 then poly = 1 ! 109°C
else if e > 4.827E+3 then poly = 2 ! 35°C
else if e > 1.336E+3 then poly = 3 ! 135°C
else if e > 4.233E+3 then poly = 4 ! 183°C
else if e > 5.291E+3 then poly = 5 ! 215°C
else if e > 5.814E+3 then poly = 6 ! 235°C
else if e > 6.053E+3 then poly = 7 ! 250.3°C
else if e > 6.211E+3 then poly = 8 ! 255.6°C
else if e > 6.232E+3 then poly = 9 ! 260.2°C
else Error = "Thermocouple under range"
end if

Note: The lower limit of this linearization is 260.2°C which is about 10°C short of the range over which the T type thermocouple is specified. This is an area of diminishing returns for this method of linearization. It will be noted that at lower temperatures, the polynomial input range becomes increasingly narrow. This is because the simple polynomial becomes less able to represent the thermocouple curve at lower temperatures. It is possible to employ methods to help reduce this effect by applying offsets to the polynomial input.
Step 6
Calculate the temperature using a third order polynomial equation:
T = c_{0} + c_{1}.e + c_{2}.e^{2}+ c_{3}.e^{3}
where the polynomial coefficients are drawn from the following table, based on the value of "poly" from step 5:
Polynomial
"poly" 
c_{0} 
c_{1} 
c_{2} 
c_{3} 
Temperature Range °C 
0 
4.87029E6 
0.02443 
3.677266E7 
5.545721E12 
400 to 242 
1 
1.02808E5 
0.02542 
5.395475E7 
1.298740E11 
242 to 109 
2 
5.19555E3 
0.025962 
7.523751E7 
3.381665E11 
109 to 35 
3 
1.237035 
0.028015 
4.566110E7 
3.054319E10 
35 to 135 
4 
2.29820E5 
0.036497 
4.557068E6 
7.841078E10 
135 to 183 
5 
4.27171E5 
0.079109 
2.057296E5 
2.288945E9 
183 to 215 
6 
1.39897E4 
0.2768 
8.839557E5 
8.105962E9 
215 to 235 
7 
5.91619E4 
1.206391 
3.950282E4 
3.339216E8 
235 to 250.3 
8 
6.93170E13 
2.86373E9 
8.873338E6 
2.494293E9 
250.3 to 255.6 
9 
1.25783E12 
5.21765E9 
1.623264E5 
3.678988E9 
255.6 to 260.2 
The end of linearization
The above T type linearization has an accuracy of about ±0.1°C over the entire temperature range, as illustrated by the following error plot:
It is possible to reduce the number of polynomials by increasing the allowed error bounds at the temperature extremes. Due to impurities in the thermocouple materials, errors are typically ±1°C or ±0.75%, which ever is greater. For the T type thermocouple at 400 °C, this error can be ±3°C. (See ASTM Standard E23087, 1992 for details).
