Hello, my problem is a simple one, the soloution may or may not be.
Basically to convert the resistance of a thermistor directly into a temprature the following equation is used.
T =1/ [A + B*Ln(Rt) + c*(Ln(Rt)^3))]
T is temp in kelvin Rt is thermistor resistance
For my 100k thermister A = 0.001279138 B = 0.000146393 C = 2.55E-7
When i read my ADC values into excel and do all the calculations i get a very accurate temprature reading to within about .2 deg
When i do all the math internal in the micro there is (at room temp anyway) 1 deg of error. nearest i can see it is bacause the log() function is truncating the decimal places it puts out. I need 9 places after the decimal and i only get 5.
Is there any workaround for this or an option in the math header that needs to be set, maybe a better log() function?
Thanks, Tom
OK, so I did a quick test in the simulator. The results agree with Excel calculations perfectly (better than 0.0001 deg.) Apparently, you are doing something wrong. Can you post your code?
i will post code i have to strip it down some and type it manually as i can not transfer any data onto my networked pcs at work.
thank you
i will post code
Meanwhile, here is the code I used for the test:
#include <stdio.h> #include <math.h> #define A 0.001279138f #define B 0.000146393f #define C 2.55E-7f float temp(float r) { float l; l = log(r); return 1.0f / (A + B*l + C*l*l*l); } char volatile buf[16]; void main(void) { sprintf(buf, "%f", temp(100000.0f)); for (;;) ; }