Calculating NTC temperature

Thread Starter

nerdegutta

Joined Dec 15, 2009
2,684
To calculate the Celsius I've found this code snippet:

Rich (BB code):
temperature = log(((10240000/adc_raw)-10000));
temperature=1 / (0.001129148 + (0.000234125 * temperature) + (0.0000000876741 * temperature * temperature * temperature));
temperature = temperature - 273;
This assumes that I have a setup like this:

GND|-----|10K|-----|uC|-----|NTC*|-----|+5vdc

*10K @ 25°C
The uC is to the ADC pin on PIC18F25K22

Now it turns out that my DIY thermometer is approximately 1° lower than the commercial I've bought. (It's really cheap, so it could be wrong.)

I've measured the 10K resistor, and it shows 9 960 Ohm, so I changed 10000 in the code snippet to:

Rich (BB code):
temperature = log(((10240000/adc_raw)-9960));
temperature=1 / (0.001129148 + (0.000234125 * temperature) + (0.0000000876741 * temperature * temperature * temperature));
temperature = temperature - 273;
But it's still off.

So I was thinking of putting a 10K pot in series with the 10K, and change the 10K to a 5.6K. Like this:

GND|-----|10K pot|-----|5.6K|-----|uC|-----|NTC*|-----|+5vdc

This way the resistance is adjustable and I can calibrate it with my commercial one.

Is it a good idea or not?

Everything is breadboarded, so I was also wondering if stray capacitance could be an issue, but as long as I'm not doing any RF, I don't think so.
 

WBahn

Joined Mar 31, 2012
30,076
That code snippet you found, was it for a thermistor with YOUR thermistor's temperature coefficients? My guess is that those numbers are for a different part and that most NTC thermistors have sufficiently similar coefficients that it gets you reasonably close. You might look to see if you can find the actual nominal coefficients for your device.
 

WBahn

Joined Mar 31, 2012
30,076
It looks like they are doing the same thing you are doing -- finding some example code and using it. The Wikipedia article they cite specifically states that the values are "typical".

You want to find the actual part number for the thermistor you are using. This may or may not be indicated on the part itself (probably not). But look at the documentation for the board that it came with and see if the bill of materials gives a manufacturer and part number. Or, if they were being unusually complete, they would provide the coefficients in their own documentation.
 

Thread Starter

nerdegutta

Joined Dec 15, 2009
2,684
I have the datasheet, and my NTC is 10K @ 25° C. With R/T No. 4901.

It say's in the ΔT[+-°C] - column 1.2. Does that mead it can 1.2° off the actual temperature?
 

Attachments

WBahn

Joined Mar 31, 2012
30,076
Are you sure you have the 5% part (p16) and not the 10% part (p17)?

Yes, that is what that means, although that is talking about the error range compared to the assumed nominal device. You can almost certainly calibrate your device to be considerably better than that.

You might find this document handy: EPCOS Standardized R/T Characteristics
 

Thread Starter

nerdegutta

Joined Dec 15, 2009
2,684
I have the +/-10%. Checked with the supplier.

So that means I'm well within the +/-10%, and everything should be OK?

Thanks for the doc.:)
 

Markd77

Joined Sep 7, 2009
2,806
If you aren't sure which thermometer is off (and you've got one) use a body temperature thermometer, they are usually accurate to better than 0.5 C
Of course that only gives one point so won't deal with nonlinearity.
 
Last edited:

WBahn

Joined Mar 31, 2012
30,076
Do you have enough confidence in the thermometer you are comparing it to in order to consider it "correct"?

Can you take resistance measurements at three or four fairly widely spaced temperatures?

If so, you can compute your own coefficients very easily.
 

Thread Starter

nerdegutta

Joined Dec 15, 2009
2,684

MrChips

Joined Oct 2, 2009
30,823
If you interface a nonlinear thermistor to an MCU you can easily correct for non-linearity.
I or WBahn can show you how. Also you do not need an ADC to measure the thermistor. A single I/O pin and a capacitor will do it. I will show you the way.

(btw, we never finished our thermometer project.)
 
Last edited:

Thread Starter

nerdegutta

Joined Dec 15, 2009
2,684
If you interface a nonlinear thermistor to an MCU you can easily correct for non-linearity.
I or WBahn can show you how. Also you do not need an ADC to measure the thermistor. A single I/O pin and a capacitor will do it. I will show you the way.
That would be awesome!
(btw, we never finished our thermometer project.)
I know... That's why I'm messing with this now. Trying to learn and understand, and I figured it would be easier to start with LCD instead of multiplexing seven segments. I'm sure that's easy too, but, well here I am. :)

Wolfram alpha can solve them for you, just put the four equations in, separated by commas. It's not as fun as doing it by hand, but easier.
http://www.wolframalpha.com/
Can you show me the four equations?
 

MrChips

Joined Oct 2, 2009
30,823
Before we jump in we have to look at the details and do some analysis.

What is your temperature range of interest? I will assume -20 to +55C for now.
What is your target resolution? I will assume 0.5C is good enough.

Are you building one unit or planning on multiple?
If you are planning to manufacture and market a number of units I would aim for no calibration requirement. Hence I would choose at minimum a 1% component.
If you are just building one unit for the fun of it then you can plan on calibrating the single unit. Do you have an accurate thermometer handy? Analog or digital?

We can use the manufacturer's data sheet to do some initial analysis.
Do you have Matlab? Otherwise we will have to resort to Excel spreadsheet.
 
Top