View Full Version : Thermisistor woes...

RinksCustoms

01-21-2008, 07:02 AM

While pining the Prop's Obex, I· noticed the lack of an object for a thermisistor such as RadioShack #271-110. I have three setup on a protoboard. Clock values can be easily displayed with three thermisistors by staggering samples from two counters this simple program is running on. I'd like to make this a simple object. So far (a few days into it), is very accurate, but only for about·a 25-30 degree range. In opperation, the higher the temp the lower the resistance. I have the code able to track the temperature·up & down correctly. My woes are with the fact that the·code only produces a linear result within a 20-25 degree range. If there's a way to expand the range·from about -20-230F (-29-110C) with an accuraccy of 1-2%, that would be acceptable for this $2USD sensor.

I'm guessing the "simple scaling" method of clock ticks / farenheit as a divisor is not a good method. And the thought of using some kind of lookup/lookdown table & scale method to get the better accuracy.

Any suggestions for a better scaling method or an efficient lookup/down table?

I can type out the table on the back of the package which translates temperatures from -50C to 110C to the corresponding resistance values if it'd help

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

E3 = Thought

http://folding.stanford.edu/ (http://folding.stanford.edu/)·- Donating some CPU/GPU downtime just might lead to a cure for cancer! My team stats. (http://vspx27.stanford.edu/cgi-bin/main.py?qtype=teampage&teamnum=78528)

Tracy Allen

01-22-2008, 02:36 AM

Thermistors usually follow close to the Steinhart-Hart equation, which in its simplified form is,

degC = B / (ln(R)-A) - C

The parameters A, B and C are characteristic of the thermistor. For precision thermistors those parameters will be given in the data sheet along with a table of R vs T values. Typical values might be A=-6.913, B=5078, C=42.24. I don't know anything about the Rat Shack thermistor, but if the data is not supplied, I guess it would be up to you to run a calibration to determine the points for your table or to solve for the parameters A, B and C.

A graph is attached, where the blue curve goes with the right-hand scale and is kOhms vs Celsius temperature. The red curve with the left scale is the voltage in a divider with a 10kOhm resistor and a 4.096 volt excitation.

As you know, your program as it stands is making a linear approximation, and for that reason it has the limited range. The count that comes from phsx is proportional to 1/R. But the curve you want is proportional to 1/ln(R). I think the easiest approach would be a sparse table with interpolation. Sparse, in the sense of enough values to achieve your desired accuracy (also within the limits of the RCtime measurement method).. Another approach would be to first calculate R, and then use the log table in hub ROM to calculate the logarithm in the Steinhart-Hart formula.

It might also be possible to linearize the thermistor to a degree by adding resistors in series and parallel with the it. I'm not quite sure how to go about doing that, but it is a standard technique when using thermistors for temperature compensation.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

Tracy Allen

www.emesystems.com (http://www.emesystems.com)

Perry

01-22-2008, 09:29 AM

Tracy is correct but left out one important point. the Steinhart-Hart Equation calculation is for Kelvin degrees

then convert to Centigrade and finally to Fahrenheit

here is a good description of the process www.eidusa.com/Electronics_Kits_EUSB_To_4_THR.htm (http://www.eidusa.com/Electronics_Kits_EUSB_To_4_THR.htm)

does the Radio Shack documentation give the parameters for A,B, and C.

You will also need to use the logarithms from the prop eeprom and do some creative work with integer arithmetic . . . or use the float library

Perry

Tracy Allen

01-22-2008, 10:23 AM

Quite right, Perry, thanks for pointing that out. It should be,

Kelvin = B / (ln(R)-A) - C

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

Tracy Allen

www.emesystems.com (http://www.emesystems.com)

RinksCustoms

01-22-2008, 11:30 AM

non-prop related:http://www.myke.com/thermo.htm (for those who can understand ASM) He does some "black magic" with a multiplied 16bit calibration constant, he also notes that:

..especially if they are not located in North America and cannot buy components from "Radio Shack". The thermistor that was used is a 10K (at 25 Celcius) 1% tolerance, NTC ("Negative Temperature Coefficient") Thermistor with a -3.85%/C specification. This means that the thermistor's value decreases by 3.85% for each degree Celcius its temperature goes up

I do like the idea of the ellagant equation Mr. Allen and will try your approach which makes more sense for a non-linear device.

Thanks to the othersfor pointing out possible pitfalls and solutions for a thermisistor.

After reading Tracy's solution, and the webpage exerpt i've included, i will rewrite my code, and thanks for any new enlightenments.

Post edit : Dug up this data sheet, probably as close to what Mr. Allen would like to see, I can't make a whole lotta sense out of it though·: http://support.radioshack.com/support_supplies/doc33/33553.pdf

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

E3 = Thought

http://folding.stanford.edu/ (http://folding.stanford.edu/)·- Donating some CPU/GPU downtime just might lead to a cure for cancer! My team stats. (http://vspx27.stanford.edu/cgi-bin/main.py?qtype=teampage&teamnum=78528)

Post Edited (RinksCustoms) : 1/22/2008 4:41:23 AM GMT

OzStamp

01-22-2008, 01:53 PM

Hi Rinks

For probably less than 2 bucks you can get a Smartec temperature sensor ..

It is a 3 wire device like a T0-92 transistor..

It has a duty cycle output ( 5VDC level) but can go straight into Propeller (with series resistor)

Use counter hardware to measure the temp (duty cycle on is temperature)

See smartec.nl..for info re how to convert the duty cycle to actual temperature.

I have not yet figured out the exact formula but that is trivial I think..

So easy.. high accucary... check it you as well mr Tracy allen

Could be a good sensor for your type of work Tracy happy New year to still as well.

cheers Ron Nollet Mel OZ

Post Edited (OzStamp) : 1/22/2008 11:42:54 PM GMT

Tracy Allen

01-23-2008, 06:11 AM

Hi Ron,

I took a look at http://www.smartec.nl/temperature_sensor.htm, and see that they list the Analog Devices TMP04 as a second source. I did at one time use that for a BASIC Stamp project. The signal is a high-low waveform, and the formula is

degC = 253 - (400 * T1 / T2)

where T1 and T2 are the durations high and low respectively. That is indeed a good bet for the Propeller! +/- 1.5 degrees from -25 to +100 Celsius, and operates from -40 to +150 Celsius. And less complicated than the one-wire sensor or the math of the thermistor.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

Tracy Allen

www.emesystems.com (http://www.emesystems.com)

OzStamp

01-23-2008, 07:47 AM

Hi Tracy

The conversion for the smartec sensor is Duty Cycle =((0.0047 * temperature) + 0.32) * 100

DC >>>> Duty Cycle ..

Converted >> ((DC/100)-0.32)/0.0047 = temperature.

According to the literature Zero celsius is DC 32 % ..

With 32 bits it can all probably be scaled up to make it easier..

Ron

www.nollet.com.au home of the PropBus.