Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Thermocouple Compensation

Status
Not open for further replies.

Mity Eltu

Member
OK, using 18F4580 and Type T thermocouple (TC) to make a thermometer to be used in laboratory setting. I have the thermocouple interfaced with a difference amplifier using KA4558 and a gain of about 400. The output voltages are working nicely. I will be using a 16-bit a/d givig me a bit/voltage step of about 76uV. The reason for the 400 gain is for my max temp of about 250°C. With type T, the TC output will be 12.013mV. With 400 gain, the voltage to the A/D will be close to 5V.

Now the question. Everything I read tells me I need cold junction (CJ) compensation for the TC. I'm not sure how to accomplish this. Assuming I use a thermistor or other such device, I will be measureing 2 temperatures. One will being coming in as an A/D result from the 16bit chip and the other read directly by the PIC. OK, so now what do I do? Do I convert both ressults to temperature and then subtract the CJ temp? What is the result if I ignore the CJ temp? If I scale then result from the A/D and ignore the CJ temp, can't I still get the right temp using firmware? I mean, if I assume that 65535 from the A/D = 5V = 250°C, then the lookup table would direct me to 250°C when I get that reult, right? So, why do I need the CJ temp?

Does that make any sense?
 
https://www.maximintegrated.com/en/app-notes/index.mvp/id/4026

Without the two physical compensation connections ( an equal temperature) , it will introduce Seeback offset errors depending on changes in temperature difference between the two connections.

4026Fig01b.gif


The most common thermocouple configuration has the two wires of a thermocouple joined at one end. The open end of each wire is connected to an isothermic connector made of copper.
 
Last edited:
OK, using 18F4580 and Type T thermocouple (TC) to make a thermometer to be used in laboratory setting. I have the thermocouple interfaced with a difference amplifier using KA4558 and a gain of about 400.
You're lucky that the output is actually giving a value that you want. The KA4558 has an input offset voltage of +/-2mV typical (6mV max), which could give an output error in the range of +/-800mV.
Do I convert both ressults to temperature and then subtract the CJ temp?
Yes. The value from the thermocouple reflects the difference in temperature between the tip and the "cold/reference" junction. You therefore have to offset the temperature by the cold junction temperature.
What is the result if I ignore the CJ temp?
If the temperature of the cold junction is room temperature, e.g. 25^C, then by ignoring it, the temperature you report will be 25 degrees too low.
 
If the temperature of the cold junction is room temperature, e.g. 25^C, then by ignoring it, the temperature you report will be 25 degrees too low.

But if I ignore the TC voltage and focus only on the A/D result I can shift everything with firmware. I can see, however, that unless the ambient temp is stable I might run into some issues. That is, if I assume ambient is 25°C and create my lookup table based on that then find the ambient is really 18°C, my lookup table has the incorrect values for each A/D result.

Man that stinks. OK. So, I've been looking at some hardware compensation techniques. I'll try to set something up.

You're lucky that the output is actually giving a value that you want. The KA4558 has an input offset voltage of +/-2mV typical (6mV max), which could give an output error in the range of +/-800mV

You've got me worried on this one. Is there an op amp that you would recommend for this application that I can find in a dip?
 
That is, if I assume ambient is 25°C and create my lookup table based on that then find the ambient is really 18°C, my lookup table has the incorrect values for each A/D result.
Yes. If you assume 25^C ambient, but it's actually 18^C ambient, your uncompensated temperature will be 7^C off (at least).
You've got me worried on this one. Is there an op amp that you would recommend for this application that I can find in a dip?
You can either null the offset of the opamp, or use a low-offset-voltage opamp, e.g. LTC2050, or probably any that you see in these search results: https://www.google.com.au/search?q=thermocouple+amplifier&safe=off&source=lnms&tbm=isch
 
Ok. I've been looking around and trying to find a decent dip amplifier is not easy. So, I'm thinking of using a 24 bit a/d to avoid the need. Analog Devices AD7714 is what I'm thinking of using. What do you think of this choice? I will already be using SPI for datalogging on an SD card, so it seems like a good fit, but I've not done anything like this before.

I am thinking of preconditioning the TCvoltage with a thermistor so that the CJ temp is included ion the A/D, but I'm not really sure how to accomplish that yet. I have looked at using the LM35 for CJ compensation, but I',m not real sure how to use that one either (at least not in this fashion). There is a reference voltage input on the AD7714. Would taking the output of al LM35 to the + reference do that trick?

Any advice?
 
Ok. I've been looking around and trying to find a decent dip amplifier is not easy. So, I'm thinking of using a 24 bit a/d to avoid the need. Analog Devices AD7714 is what I'm thinking of using. What do you think of this choice? I will already be using SPI for datalogging on an SD card, so it seems like a good fit, but I've not done anything like this before.

I am thinking of preconditioning the TCvoltage with a thermistor so that the CJ temp is included ion the A/D, but I'm not really sure how to accomplish that yet. I have looked at using the LM35 for CJ compensation, but I',m not real sure how to use that one either (at least not in this fashion). There is a reference voltage input on the AD7714. Would taking the output of al LM35 to the + reference do that trick?

Any advice?
To get reasonable stability you have to use OP07 or 714 op amp. I'm not updated, there could be op amp with lower drift nowadays.
Most CJ compensation is analogue using termistor , it gives linear output related to ambient temp. It assumes that the TC voltage is also linear at around ambient. If you need better accuracy use digital sensor (DS18B20) glued to the CJ terminal block. Use lookup table to convert ambient temp to the type T voltage, and in software add this voltage to the voltage you get from the TC , then use the lookup table to convert it to temp.
 
LT has a really nice chip: https://www.linear.com/product/LTC2983#demoboards

An RTD would be decent to use for that range. Type T is also good. Your selection depends on

Cold junction compensation basically means you have to measure the temperature of the isothermal connection by another means. Diode, for instance. You then need to reverse lookup the voltage for that temperature. You might only have to do this for say 32F to 110F.

Getting a decent isothermal connection i more mechanical than anything else, but it's hard to do it right. Usually a manufacturer slaps a temperature measuring device "nearby" where air currents play havoc.

You either add/subtract this voltage from your measured voltage and then convert tis new voltage to temperature.

Methods are usually polynomial or look-up table.
 
Hi,

Back when i was doing this several years ago i found extensive tables online and even polynomials, maybe 5th degree for generating the tables. They are probably still around somewhere.

If you can get a hold of a commercial meter even for a short time you can check your calculations against the readings taken with the commercial meter. For me it was easy because i already had a meter that could measure using the same thermocouple.
 
Hmmm. Alright. I have already built a room temp thermometer based on the DS18B20 with a resolution of 0.0625°C. What I hear is that I can use that value, which is areledy in °C, scale my TC voltage so that I can read it reliably with an A/D converter, convert this result to °C and then add the results. This relies heavily on making sure the lookup table is bead on accurate for the TC temp conversion.

It makes more sense to my way of thinking to compensate before the amplification. I'll look into the 714 or OP07.

I've been tinkering with a NTC thermistor (15k) but I just don't get it. Question: At room temperature of 21°C, my T-Type TC should have a voltage of 0.000803V when properly compensated (referenced to 0°C). So, if I use a thermistor, does the voltage I am supplying FROM the thermistor (I am assuming I will be using a thermistor resistor divider network here) as a biasing voltage need to bring the TC voltage to that point? Is THAT how this is supposed to work? I'm referencing page 4, figure 14 of the attached pdf.
 

Attachments

  • z021-032.pdf
    282.8 KB · Views: 308
You need two tables uV to temp (what your measuring)
and actual temp (terminals) to uV

The last table only has to be valid for the electronics environment.

Omega.com has the tables. The old way was to put two thermocouples in series with one in an ice bath. That's when the tables are valid.
 
I've been tinkering with a NTC thermistor (15k) but I just don't get it. Question: At room temperature of 21°C, my T-Type TC should have a voltage of 0.000803V when properly compensated (referenced to 0°C). So, if I use a thermistor, does the voltage I am supplying FROM the thermistor (I am assuming I will be using a thermistor resistor divider network here) as a biasing voltage need to bring the TC voltage to that point? Is THAT how this is supposed to work? I'm referencing page 4, figure 14 of the attached pdf.
Yes, you got it, if you connect 803uV to the -TC at 18 centigrade the +TC will give you the correct voltage. The difficult part is to arrange the thermistor to give you the right voltage for 0 to 50 centigrade.
 
Hi,

The voltage you get from the thermocouple if the cold junction was at 0 degrees is the voltage that translates to the correct temperature of the hot junction if you look it up in the table. If the cold junction is not at 0 degrees but at say 25 degrees, then the voltage is lower because there is less difference in temperature across the two thermocouple wires. If the cold junction is at say -25 degrees, then the voltage is higher because there is more difference. But most of the time there will be less difference because we have a more convenient temperature like 25 degrees as the cold junction, and it may vary somewhat so we have to keep track of that in order to get it right.

So lets say the cold junction is at 25 degrees. The thermistor and resistor shows a voltage of 2.5 volts (because we use a power supply of 5v and a resistor in series with the thermistor that is equal to the thermistor resistance at 25 degrees).
1. First, you have to calculate the temperature for the thermistor knowing this 2.5 volts. This could vary, so you have to calculate it or have a table made up so you can look it up. In this case we have 2.5v and that translates to 25 degrees.
2. Next, we look up 25 degrees in the thermocouple table for that type of thermocouple. Lets say we see 0.002 volts (i am making this number up to keep it simple, but if needed we can look up the real value).
3. Next, we measure the voltage of the thermocouple, probably amplified, and say we see 0.5v and that was amplified 100 times. We divide that by 100 and get 0.005 volts for the thermocouple.
4. Now we add the 0.005 and the 0.002, and we get 0.007 volts. This is the voltage of the thermocouple IF we had the cold junction at 0 degrees instead of 25 degrees.
5. Finally, we look up the 0.007 volts in the table for the thermocouple, and we see 80 degrees (i am making this number up too for simplicity but we could use the real table if needed later). That is the temperature of the hot junction, 80 degrees, and we're done.

So there are some steps to perform, and this means looking up values in the table twice...once to find the equivalent voltage of the thermocouple, and once to find out the actual temperature of the hot end of the thermocouple. So we use the table in two different ways.

The step where we find the thermistor temperature is based on the coefficients of the thermistor, so we need the manufacturers data on the thermistor (two numbers, alpha and beta) and also the way it is connected in the circuit (usually with a series resistor to +5v). Otherwise we have to be willing to test it by heating it and cooling it and taking measurements, then figuring out the scale of voltage vs temperature.

Some testing and calibration has to be done also, to make sure we have all the numbers correct. This means changing the temperature and measuring with a known good temperature meter, then applying any calibration corrections to the formula(s).
 
OK. That is clear enough on the conversions. In another thread I asked about these lookup tables. I'm still fuzzy on this. I don't understand what values actaully needt o be in the tables. If the table is composed of integer temperatures in the range of interest (0-250°C in this case), and the A/D result is used to lookup the temperature, why do I even need a table?

Let me see if I can walk myself through this and get some guidance on it - this is just not making any sense to me.

Let's assume that the Type T TC is properly compnesated. The range of temps I am interested in is 0-250°C. The max TC voltage then will be 12.013mV. Let's also assuem a 10-bit A/D instead of the 24 bit version I mentioned earlier. So, if I want the voltage into my 10-bit A/D to be 0-5V, I will amplify the compensated TC voltage by 416. Let's assume my amplifier is doing exactly that. From this I know 0v(a/d input)=0(a/d result)=0°, 1v=205(rounding)=58.52°C(interpolation), 2v=410=111.21°C, 3v=614=160.05°C, etc.

Ok, I see from this that my results from the A/D will not be linear with respect to the temperature (expected since TCs are not linear elements) so that I can't just create a scaling factor and multiply the A/D result to directly get the temp.

So, tables...... I'm sorry, but I don't understand what to do here. What values are in the tables? I know I get an A/D result in the range of 0-1024. If my temp is in the range of 0-250°C, then each bit is approximately 0.244°C. Again, knowing this, it seems logical to simply multiply to get the temp, but it's not a linear function, so I know my temp will be incorrect. I'm stumped.

If I make a table of values, the only table that makes sense to me is one made up of temperatures related to the A/D result. For instance, A/D 10 = 3°C, 20 = 6°C, 50 = 14.95°C, 100 = 29.46, 200 = 57.22, etc. This means to me that my table can have at most 64 values as they will all be single point values (4 bytes each). Each individual A/D result will need to be interpoltaed if it does not fall on one of the specified values. No biggie there. If I need a table for both the thermistor (small range there) and the TC (wide range), I will need to be careful in choosing the values placed in the tables to afford me the best chance at a correct interpolation.

Is THIS how it's done?

Is this really the best solution? This seems very .... brute force. By that I mean it seems to lack sensitivity, precision and accuracy all at the same time.
 
Your table is just related to the uV value by a constant (the bit value), So what? Bit's work in both cases unless your measuring from 250 C to 1000 C and room temp is -10 C to 50 C (Your cold junction). They would still work, but you might end up having two tables.

Tables are ONE way and polynomials are another, I used to have books with the polynomials in it.

Watch out for quantization errors too, The lower the value measured the higher the error.
 
I would like to use the polynomials, but the coefficients are very small. I imagine I would lose wuite alot of the accuracy given the limited Single type variable available with Oshonsoft Basic.

Just for my own edification, is my method listed above for tabe use correct? Honestly, every time I think about it I get confused.
 
OK. That is clear enough on the conversions. In another thread I asked about these lookup tables. I'm still fuzzy on this. I don't understand what values actaully needt o be in the tables. If the table is composed of integer temperatures in the range of interest (0-250°C in this case), and the A/D result is used to lookup the temperature, why do I even need a table?

Let me see if I can walk myself through this and get some guidance on it - this is just not making any sense to me.

Let's assume that the Type T TC is properly compnesated. The range of temps I am interested in is 0-250°C. The max TC voltage then will be 12.013mV. Let's also assuem a 10-bit A/D instead of the 24 bit version I mentioned earlier. So, if I want the voltage into my 10-bit A/D to be 0-5V, I will amplify the compensated TC voltage by 416. Let's assume my amplifier is doing exactly that. From this I know 0v(a/d input)=0(a/d result)=0°, 1v=205(rounding)=58.52°C(interpolation), 2v=410=111.21°C, 3v=614=160.05°C, etc.

Ok, I see from this that my results from the A/D will not be linear with respect to the temperature (expected since TCs are not linear elements) so that I can't just create a scaling factor and multiply the A/D result to directly get the temp.

So, tables...... I'm sorry, but I don't understand what to do here. What values are in the tables? I know I get an A/D result in the range of 0-1024. If my temp is in the range of 0-250°C, then each bit is approximately 0.244°C. Again, knowing this, it seems logical to simply multiply to get the temp, but it's not a linear function, so I know my temp will be incorrect. I'm stumped.

If I make a table of values, the only table that makes sense to me is one made up of temperatures related to the A/D result. For instance, A/D 10 = 3°C, 20 = 6°C, 50 = 14.95°C, 100 = 29.46, 200 = 57.22, etc. This means to me that my table can have at most 64 values as they will all be single point values (4 bytes each). Each individual A/D result will need to be interpoltaed if it does not fall on one of the specified values. No biggie there. If I need a table for both the thermistor (small range there) and the TC (wide range), I will need to be careful in choosing the values placed in the tables to afford me the best chance at a correct interpolation.

Is THIS how it's done?

Is this really the best solution? This seems very .... brute force. By that I mean it seems to lack sensitivity, precision and accuracy all at the same time.

Abbreviated table for type T:
-100, -3.378mv
0, 0.000mv
100, 4.277mv
200, 9.286mv
300, 14.860mv

Example:
Your amplifier has a gain of 100.
You have your cold block at 0 degrees.
Your ADC reference is 5 volts.
Your ADC is a 10 bit unit.
Your ADC returns a value of 88.
5*88/1024=0.429687
0.429687/100=4.297mv
In the table above we see 4.277mv, so your temperature is just above 100 degrees.
Done.

Had you needed cold junction comp, which you will need, you would have to first look up the value for that going the other way around: find the voltage for that temperature...then add that to the final voltage you get above before looking at the table for a second time.

If you use a polynomial then you might calculate the temperature from that, but for finding the voltage of the cold temperature you have to have a way to calculate the inverse function of that polynomial, either analytically beforehand or numerically in real time. You would add the cold calculation to the measurement and then calculate the final temperature.
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top