Thread: Arduino issues
View Single Post
Old 03-03-13, 05:34 PM   #8
jeff5may
Supreme EcoRenovator
 
Join Date: Jan 2010
Location: elizabethtown, ky, USA
Posts: 2,428
Thanks: 431
Thanked 619 Times in 517 Posts
Send a message via Yahoo to jeff5may
Default

If it were me, I would use what works and build upon it.
Since the original routine reads the thermistor value as it should, I would use it.
It returns the floating point variable READING.
I would take the first code and add a single line that converts the reading to temperature.
Something like this:

float logcubed = log(reading);
logcubed = logcubed * logcubed * logcubed;
float kelvin = 1.0 / (-7.5e-4 + 6.23e-4 * log(reading) - 1.73e-6 * (logcubed));
float celsius = kelvin - 273.15;

the A, B, and C values were stolen from Alan Wendtt from his arduino.cc posting. Your values may or may not vary, IDK.

I learned long ago that the compilers/assemblers/translaters (whatever you call themtoday) tend to work better with these ugly one-line equations without hiccups or weird errors than using many lines to do the same thing.

Once you have the code in that first program spitting out temperatures, use it as a function to do your averaging. As long as you keep the operations separate it will be easy to tell where your program is going wrong.
jeff5may is offline   Reply With Quote