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.

Converting adc readings to degrees?

Status
Not open for further replies.

ClydeCrashKop

Well-Known Member
Most Helpful Member
Hi ETO
I am using an automotive coolant temperature sensor on a 16F1827.
The sensor is wired to +5 volts and AN0 with a 4K7 ohm pull down resistor.
At 32 Degrees F the sensor is 6000 ohms.
At 77 Degrees F the sensor is 1700 ohms.
At 212 Degrees F the sensor is 176 ohms.
I would like to display degrees Fahrenheit on the LCD but the ADC readings seem to change exponentially.
What kind of formula do I need to convert the output?
I am using Hi-Tech C so there are plenty of functions to work with.
Or could I hook it up differently to get a more linear output?
These are my readings and a graph.

Code:
TEMP    READING
30    462
35    480
40    502
45    544
50    580
55    595
60    615
65    650
70    695
75    726
80    740
85    767
90    786
95    810
100    828
105    844
110    855
115    873
120    892
125    910
130    922
135    931
140    936
145    940
150    943
155    952
160    960
165    968
170    974
175    978
180    983
185    987
190    999
195    991
200    995
205    997
210    998

Temp scale horizontal.jpg
 
What kind of temperature sensor are you using? How it is "hooked up" now? Usually temperature sensors are linear.
 
4.7K is not the right pull-down value.

Give me a table of resistance vs temperature (at least every 10 degF) and I will suggest a resistor network to put around the sender to better linearize it.

Or, throw it away and use an LM34
 
Last edited:
What type of sensor are you using? Since you talk about resistance, I'm thinking thermistor or RTD. Thermistor usually follow a non-linear (log) curve.
 
I think it is probably a thermistor. It came out of a sending unit for an analog temperature gage on a Nissan, circa 1980. It is in a little glass bead, 3/16" diameter. It does look like a non-linear (log) curve on the graph. I just chose the 4.7K resistor because it gave me a wide spread between freezing and boiling.
What is the best way to hook up a two wire variable resistor to an ADC?
How would you make a log curve linear mathematically?
 
It is wired +5v---- thermistor----AN0----4.7K----ground.
Would this be better? +5v----4.7K----thermistor----AN0----4.7K----ground.
I have run into this problem before. The time between pulses on a tachometer is also a log curve. It would be nice if we could sort it out.
I like that LM34 Precision Fahrenheit Temperature Sensor.
This sounds kinky.

oil bath.jpg
 
I think it is probably a thermistor. It came out of a sending unit for an analog temperature gage on a Nissan, circa 1980. It is in a little glass bead, 3/16" diameter. It does look like a non-linear (log) curve on the graph. I just chose the 4.7K resistor because it gave me a wide spread between freezing and boiling.
What is the best way to hook up a two wire variable resistor to an ADC?
How would you make a log curve linear mathematically?

I was about to tell you, but I need more than the three points of resistance vs temperature you posted...
 

Shows the thermal response of the TO92 package for a step change in temperature. (dunking the sensor in the oil bath). Stirred oil conducts heat well, so they are measuring how long it takes the internal die to heat up through the plastic walls...

Post # 8000
 
Give me a table of resistance vs temperature (at least every 10 degF) and I will suggest a resistor network to put around the sender to better linearize it.

I will need to find an uninterrupted hour to do that.
 
I was searching around the Mathematics and Physics section.
I found some interesting info and this post.
A good example of logarithms is the stock market. It has typically grown 10% per annum. Plot this on a linear scale and you get an exponential graph. Plot on a logarithmic scale and it's a straight line. When it varies from the logarithmic line you should worry.
Mike.
That sounds like what I need.
 
Thanks Mike.
Those links will take some studying.
It does look like my graph.

Termister calculator.jpg
 
These are the ohm readings of the thermistor.
If I just get a window, I won't need more than 100 degrees and down to 50 or 60 is good.

Code:
F  Ohms
30 6000
35 5200
40 4500
45 4000
50 3600
55 3200
60 2850
65 2500
70 2200
75 2000
80 1850
85 1650
90 1500
95 1350
100 1200
105 1080
110 944
115 870
120 794
125 720
130 650
135 590
140 538
145 520
150 500
155 460
160 400
165 360
170 340
175 330
180 320
185 300
190 274
195 250
200 232
205 220
210 176

temp resistance.jpg
 
If all you need is from 50 to 100 degF, it may be easier to split the readings in two. One linear equation for anything between 50 and 70, and one linear equation for anything between 70 and 100.
 
Put the following two resistors around the thermistor, and the output will be quite linear between 50 and 150 deg F.

lin.jpg


Linp.jpg
 
Last edited:
That’s a good idea languer.
Thanks a lot Mike. I appreciate it.
It sounds like you have done that often.
 
So far, ADC readings / 3.8 - 30 looks pretty good.

Close graph.jpg
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top