Electronics > Projects, Designs, and Technical Stuff
Interfacing a K-type thermocouple using only microcontroller ADC features?
(1/3) > >>
HwAoRrDk:
I have been contemplating an idea I had regarding whether it is feasible to interface with a K-type thermocouple using nothing but the features available in a moderately-equipped microcontroller - namely, an ADC with differential inputs, a programmable gain amplifier, and an internal temperature sensor. I'm wondering whether it's something worth trying, and whether the measurements achievable using such a design would be useful.

The ADC on the microcontroller in question claims the following features:

- 10-bit resolution
- Differential input channels
- Programmable gain amplification of differential inputs, of x5, x10, x20 and x40.
- Internal temperature sensor
- Internal 2.56V reference.

So, I was thinking of an arrangement thus:

The thermocouple's terminals are connected directly to a pair of differential ADC inputs on the micro. It will be configured to apply a x40 gain amplification on the signal, and reference that against the internal 2.56V reference. I think this should give a large enough signal for a K-type. Then, to apply cold junction compensation, the internal temperature sensor is read as the cold junction temperature, and the compensation is done in software. I guess that's probably 'good enough' so long as the junction and MCU are close together on the same PCB, in the same enclosure.

However, I think there are a number of possible sticking points, some of which I'm unsure of the weight of, if they are even concerns at all.

To start with, the datasheet says that "On the amplified channels, 8-bit resolution can be expected". I don't understand why they say 8-bit, as while I get that because the input is differential, one bit must be used to represent the sign, that still leaves 9 bits. And they state the range of output values will be between 0x200 and 0x1FF. A typo perhaps? Or are they suggesting something about the effective accuracy?

The amplifier circuitry is described as a 'switching capacitor' amplifier. What does this mean? The datasheet is fairly brief about the details, only really explaining that it works off a synchronisation clock, and that a stable input value must be present during a certain number of clock cycles in order to ensure an accurate result. Does this work on a similar principle to a Cockcroft-Walton circuit? It sounds to me like such a thing would not be useful for very high bandwidth signals, but I doubt that would be a problem in this use-case.

Also, the amplifier gain claims 5% accuracy. I presume this means that the actual gain figure is not exact, and could be plus-or-minus that amount. So for example, a x40 gain could be anywhere between x38 and x42? Would this be a consistent inaccuracy, or variable, affected by operating conditions, etc?

I understand MCU internal temperature sensors are, out of the box, generally not very accurate at all (typically +/- 10C), so I am assuming calibration will be needed here, for at least the ambient range that the device will be expected to be used in.

I don't know what the accuracy of the internal voltage reference is, and how it varies. Couldn't find that information in the datasheet, if it exists there at all.

Given all the above, I'm wondering what kind of accuracy and precision I can expect from such a solution (assuming it's not a non-starter overall). My attempt at some quick back-of-the-envelope maths shows that, given a K-type thermocouple measuring between 0 and 1000C (so a max input voltage approx. 40 mV), I will get a resolution of about 3C. That sounds fairly reasonable for what I was thinking of doing. I would probably be okay with even 5C resolution! But I'm not sure about how to go about working out what kind of accuracy is to be expected.

Is it worth trying to implement this? Are there any show-stoppers I haven't thought about?

Yes, I have considered taking the easy route and using something like a MAX31855, but those are quite expensive and I thought it would be a good exercise to try and 'make do with what you've got'. :)
jmelson:
100 C difference on a K thermocouple give you 4 mV of potential.  That's NOT a lot to work with.  Unless you are checking ceramic kilns or steel furnaces, your X40 amp is not enough.  Even at full range (1370 C) you only get 55 mV out.  10 bits out of a 2.56 V reference gives 2.5 mV resolution on the ADC.  dividing by the gain give a resolution at the input of 62.5 uV.  A degree C is about 40 uV.  So, you'd have a resolution of 1.56 C (but it gets messier when you add in the polynomial correction.)

Jon



HwAoRrDk:

--- Quote from: jmelson on February 27, 2019, 08:18:44 pm ---10 bits out of a 2.56 V reference gives 2.5 mV resolution on the ADC.  dividing by the gain give a resolution at the input of 62.5 uV.  A degree C is about 40 uV.  So, you'd have a resolution of 1.56 C

--- End quote ---

You missed where I said that the ADC output is a signed 9 bit value when using the differential inputs. So it'll be 4 mV ADC resolution, giving 125 uV at the input, for 3.125 C. So, yeah, my maths was about right. But, like I said, I'd be satisfied with 5 C resolution, if I can get 3, it'll be good.

I'm still puzzled why the datasheet says it is 8 bit in differential mode. I found it even says that in the ADC characteristics table. But all the examples show 9 bit values. :-//


--- Quote from: jmelson on February 27, 2019, 08:18:44 pm ---(but it gets messier when you add in the polynomial correction.)

--- End quote ---

Ah, I knew there was something I'd forgotten. I need to go watch Dave's video on thermocouples again. ^-^ Yes, the response curve is not linear, is it? That is, it's not exactly 40 uV/C all the way across the temperature range, is it? I seem to recall there are pre-defined lookup tables for doing that correction. Published by NIST? Or ANSI? Or was is it the ISO?
Siwastaja:

--- Quote from: HwAoRrDk on February 27, 2019, 08:52:00 pm ---I'm still puzzled why the datasheet says it is 8 bit in differential mode. I found it even says that in the ADC characteristics table. But all the examples show 9 bit values. :-//

--- End quote ---

Would be easier to answer if you revealed your mystery MCU to us.

It may be "software developer speak", from a digital guy, for digital guys. It may just mean ENOB.
aheid:
Several STM32s (like STMF3 series) have differential 12bit ADCs, and coefficients for temp compensation of internal 1.2V reference. Would at least give a bit more margin, no? Not that I have any experience to say if it is still futile...
Navigation
Message Index
Next page
There was an error while thanking
Thanking...

Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod