Read Actual Temperature Value : MAX 31865 Integrated Circuit and PT1000/100 Temperature Sensor
Hi , in this article we’ll find a formula to linearize the max 31865 ADC circuitry.But why we do that matter?Isn’t 31865 circuitry already do its own job?
Actually , ADC of the MAX 31865 circutry does it’s job but PT1000 or PT100 sensors can’t do it’s task perfectly.
PT1000/100 sensors is just a platinum resistance thermometer.That’s mean is PT1000/100 has a resistance value depends on the temperature value.If temperature rises then resistance of the PT1000 is also increases.However there is a problem with this matter.
Let look at the temperature table in MAX 31865 .
In the table we can see that there is a difference between ADC value and real temperature.What can we do to read real temperature value by ADC?To do that I implemented some operations.
Before explain the operations there is a second table which includes the continuous values of first table.This table is shown below.
2 is powerful than 1.We can improve the operations easily now.
Let focus between 20 C° and -20C°.In this interval there is no big difference between ADC values and real temperature values.Difference is significantly increases with starting to 30C° and -30C°.
30 C° is a start point for positive temperature values and it goes up to 550C°.Could we find a relation in this interval?Yes , we have a relation in this interval.To find the relation , we can divide the values one by one.For all of the operations I used the Python language.If you desire , you can use another language because operations just includes mathematical operations , array lists and loops.
Let create an array for real temperatures and named as realTemps.
realTemps =[30 , 40 , 50 , ….. , 550 ]
Let create an second array for ADC temperatures named as adcTemps.
adcTemps = [29.88 , 39.78 , 49.66 , …. , 505.56]
Please fill the blanks with values.
Let create an third array for hold the ratios of the real and ADC temperature values named ratioTemps.
ratioTemps = [None]*len(realTemps)
Now , we can find a ratios of the temperatures.
for k in range(0,len(realTemps)):
ratioTemps[k] = adcTemps[k]/realTemps[k]
ratioTemps[] is calculated as:
0.99600
0.99450
0.99320
0.99166
…
…
0.93033
0.92662
0.92291
0.91920
So, what we have now?What we’ll do with this ratios?We’ll find a difference between ratios.
for n in range(0,len(realTemps)-1):
print(ratioTemps[n+1]-ratioTemps[n])
If program runs , you can see the values as below.
- 0.0014999999999999458
-0.0013000000000000789
-0.0015333333333332755
-0.0015238095238094829
…. [There are values in here ]
-0.001576023391812953
-0.0014184210526315688
-0.0037055555555555175
-0.003604444444444521
….[There are values in here]
-0.003705714285714312
-0.00371428571428567
In here think like 4 digit shifted to left.For example 0,003714 is 37,14.
If you realize that values change between 13 and 15 in somewhere than values goes to between 36 and 37.In that point I confused about that matter.Why the values in between 13 and 15 then it goes to 36 and 37?I realize that until 200 C° values increases 10 by 10.However after this point temperature values increases 25 by 25.
25 / 10 = 2.5
37 / 2.5 =14.8
Now , we can see what is going on.Actually ratio is constant-like.
Let create a formula which gives us to real temperature values.
If real value is known then we can find the ADC value.How?
Let say we have a variable namely tryRealTemp and for ADC conversion tryADC.
tryADC = tryRealTemp * (0.996 -(tryRealTemp-30)/10 * 0.00148)
0.996 is the starting point which is 30 C°.Formula is that ; take a real temperature value than multiply it with a ratio to find ADC value.0,996 is the ratio for 29,88 C° / 30 C°.Then find the how real temperature far from 30C°.For example 60 C° is (60–30) /10 = 3 times far from 30C°.In every 10 C°.
we have 0.00148 ratio decline.This formula is to find the ADC values with known real temperature values.However our problem is finding a real temperature value for known ADC value.So , we have to inverse the formula to find real temperature value.
In here , we solve a 2nd order equation.If you solve the equation correctly you find this equation :
tryADC = 1.00044tryRealTemp —0.000148( tryRealTemp)²
0.000148( tryRealTemp)² — 1.00044tryRealTemp-tryADC = 0
Let say t for tryRealTemp and A for tryADC.
0.000148t² — 1.00044t — A =0
In this point let create new variable named as ratioConstant. This ratio is 0,000148 because we assumed 37/2,5=14,8.However we don’t know actual value is 37 or not.We can change it so we define it as variable.Beside 1,00044 is just 0,996+30*0,000148.
Let reformula the equation:
(ratioConstant)*t² — (0,996+30*ratioConstant)*t -A=0
This is the formula which we try to find the root.
Root can be find as shown below:
- Find the delta value : delta = sqr(b² — 4ac)
- Find the root : x1 = (-b + delta) / 2a , x2 =(-b — delta )/2a
a = ratioConstant
b= -0,996+30*ratioConstant
c= tryADC
x2 is the root for our formula .
Let try some example for known temperature values:
If tryADC = 263.97 C °
tryRealTemp = 275.023 C°
If tryADC = 484.53 C°
tryRealTemp =525.016
You can see , we find a formula which gives 0.05 C° accurately temperature values.You can find a new formula for -30C° to -200C°.
I give you for your use:
constant : 0.000212
delta = (1.00533–30 * constant)² — 4 * constant * tryADC
tryRealTemp = -(-(1.00533–30 * constant) + sqr(delta))/(2*constant)
This is the outcome code written in Python.You can convert it any language easily.
tryADC = float(input("enter example ADC"))
tryRealTemp = tryADC
if tryADC >= 30:
constant = 0.0001477
delta = (0.996+30*constant) ** 2 - 4 * constant * tryADC
tryRealTemp = ((0.996+30*constant) - delta ** 0.5) / (2 * constant)
elif tryADCADC <= -30:
constant = 0.000212
delta = (1.00533 - 30 * constant) ** 2 - 4 * constant * tryADC
tryRealTemp = (-(1.00533 - 30 * constant) + delta ** 0.5) / (2 * constant)
tryRealTemp *= -1
print(tryRealTemp)