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 interface with PIC

Status
Not open for further replies.

ARandomOWl

New Member
Hi everyone.

I am looking to interface a KType thermocouple to a PIC (specifically a 16F819) to display temperature on an LCD. (I already used the search function and found some thread, but not the info I was after). The temperature range that I am looking for is -200c to +50c. An accuracy of 1c is desired but not required. At first I planned to use the AD595 with an op-amp to provide a 0v to 5v input for the PIC's ADC, however I have just come across potentially another, better, solution.

**broken link removed** (Page 6) Shows "Offsetting and changing the gain". I would like to utilise this as it seems to void the need for an external op-amp. Now for some questions.

(AD595 datasheet)
(**broken link removed**)

I would like the output voltage from the AD595 to be 0v when the temperature on the KType is -200c. So I would need a voltage of -160uV on pin 8. Is that correct.

If so, how do I go about achieving a -160uV reference?

For a 20mV/c output am I correct in saying that I require the AD595 gain (GNew) to be 387.2? If so, I will proceed to calculate RExt using the formula in AN-274 (I don't yet have physical access to a chip to measure RFDBK but will do soon).

Will I need a dual rail supply for the AD595 in this configuration?

Lastly, is this a "good" way of doing things, or should I use an external op-amp as I previously planned to do?

Thanks in advance for any help or advice offered. Adrian.
 
I measured RFDBK to be 40k. Using the calculation in AN-274 I have found RExt to be 62,718 Ohms. Could someone verify that please?
 
I just got my head around the application note. It seems I need a -2v reference as opposed to the microvolts I thought before. Would a potential divider from -5v be suitable for this application? Say a 1K5 and 1K resistor?
 
I have several comments here.

1. I find it strange that you are going to use a 10$+ thermocouple amp, but are trying desperately to avoid a 40 cent op-amp.

2. I think 10$ is a lot, for thermocouples, I like the AD8293G160. It is a 160 fixed gain amp, very good specs, only costs $1. The down side is you need to do your own cold-point compensation which means you need a temperature measurement IC or thermistor or something also. Unless you only want relative temps, then no compensation necessary.

3. Why do you need additional gain? The AD595 outputs 10mv per C. That's 2V at 200C. If you are thinking you need gain because you want the output to span the entire ADC range, the better solution is to set the PIC ADC reference voltage at your highest expected result.

4. You are going to need to measure negative voltage with your ADC. I just made a post that applies to this. Instead of using the output from the current shunt, use the output from the AD595. You also don't have to set the VHALF at half, if you are going -200 to 50. You can set it at 3/4 for example, so anything below 3/4 of the ADC max is negative and above is positive. Here is the post:

**broken link removed**
 
Sorry I missed your question about the -200 at 0v. That would be a better way to do it but I don't think pin 8 is involved. This is what your datasheet says.

The ice point compensation network of the AD594/AD595
produces a differential signal which is zero at 0°C and corresponds
to the output of an ice referenced thermocouple at the
temperature of the chip. The positive TC output of the circuit is
proportional to Kelvin temperature and appears as a voltage at
+T. It is possible to decrease this signal by loading it with a
resistor from +T to COM, or increase it with a pull-up resistor
from +T to the larger positive TC voltage at +C. Note that
adjustments to +T should be made by measuring the voltage which
tracks it at –T. To avoid destabilizing the feedback amplifier the
measuring instrument should be isolated by a few thousand
ohms in series with the lead connected to –T.
 
1. I am not specifically trying to avoid using an external amplifier. I thought adjusting the amplifier built into the AD595 would be a better solution.

2. Is the AD8293G160 a better solution or do you suggest it because of expense?

3. Thank you for clarifying that. That should have been one of my questions also. I shall look into providing my pic with a suitable reference voltage.

4. I was attempting to avoid this by using a -2v reference on the op-amp's feedback pin. This way when the thermocouple is at -200c, the output from the AD595 should be 0v.

Thanks for the help.
 
In response to your second post: I was referring to the schematic on page 6 of AN-274. Have I got the wrong idea? Is that not the correct way of adjusting the offset?
 
2. No, it is not a better solution, it is just cheaper.
3. The pic ref can be a simple resistor divider as the pic ref inputs are very high impedance.
4. Good idea, my interpretation of the t+, t- business is that as it sits t+ and t- should equal 2.73 volts. You want to decrease the value of a resistor from t+ to ground until t- = 0.73V
 
2. Ok, it's something I will bare in mind.

3. That's something I did not think about.

4. Ah ok, I think I understand what you are getting at. I don't yet have a great understanding of amps so it's not something I thought about. So you mean if I measure T+ to ground and T- to ground, they should both measure 2.73v? Could you explain why or point me in the right direction please. I think what you are talking about is covered on page 4 of AN-274, figure 7.
 
No, you seem to be correct. That is what the App note says. Ignore my 2v advice, I assumed the output was a linear 10mv per C, it is not. So i suppose you would inject -1.454V into pin 8.
 
I came up with 2.73V because the datasheet says t+ is referenced in kelvin and 0C is 273K. You wanted 73K, hence I said get it to 0.73. However, it not linear (something you need to keep in mind when you interpret the ADC result), so you actually need to change the voltage by 1.454 according to their datasheet table. The amp on the left is the gain amp, the amp on the right is the summing amp, for adding the compensation voltage. pin 8 is the inverting input, connected through a resistor, to the summing amp and pin 3 is non-inverting input connected directly. My interpretation at this point is you can pick one. You can pull 3 to ground until you lose 1.454 or you can inject 1.454 into 8.
 
Thanks for explaining that. Everything makes a little more sense now. So should I just connect a pot between pin 3 and ground? I don't need the other 2 resistors shown in figure 7 of AN-274?
 
Honestly, since the ice point compensation is represented as a block, I am having a hard time telling if that is a inverting or non-inverting summing amp. In any case, just do what works, a resistor to ground, or resistor to VDD. The output should be a positive voltage when you start, assuming you are above 0c, whichever makes it go more positive is the right direction. You want the total voltage at the output to be 1.454 + whatever the correct voltage is for the room temperature. I believe figure 7 is just to calibrate the ice point compensation, they provide a method for correcting a positive or negative error with one trim, hence if you were producing something, it would be convenient. You are changing it anyway.
 
Last edited:
Ok thanks, I'll try that out. How can I go about compensating for the non-linearity of the AD595's output? I need the most accuracy between -200c and 0c, positive temperatures don't matter much in this design.

Also, will 2 1K resistors be fine for a potential divider so I can use 2.5v as a reference for the PIC?

Thanks for all the help/guidance and quick replies :)
 
I setup a simple circuit with the AD595 using +/- 12v supply and got a reading of 0.25v output with my ktype. Room temp is around 25c so it works fine. I then connected a 1M (fixed) resistor between T+ and +12v and the reading increased to 1.05v. 2M resistor gave around 0.6v. So your theory seems to work well :)

I will be using a +/- 5v supply in the end so will have to adjust the pot's value accordingly I imagine.
 
If a pull-up increased the voltage, that means it is a non-inverting amp, which probably means you don't need dual supplies, so 0 and +5 may be OK. If there was an easy was to make the output linear, they probably would have built it into the chip. This is transfer function to get the original voltage:

Code:
Type K voltage = (AD595 output/247.3) – 11 mV
My recommendation is to use excel to build a look-up table of the correct result for each of the possible 1024 ADC results. Put it in an array. Then you can conveniently just find the temp with something like:
Code:
 int TCelcius = KTABLE[ADCRESULT];
If you only need precision to 1 degree, then build your table for 256 results and use 8-bit mode ADC or use 10-bit and drop 2 bits like this:
Code:
 int TCelcius_8bit = KTABLE[ADCRESULT  >>  2];
 
Last edited:
But how do I get the K type's temperature from the AD595's output voltage? I know there's a table in the datasheet but how do I get the number in between?
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top