Shop OBEX P1 Docs P2 Docs Learn Events
Steinhart-Hart for thermistor — Parallax Forums

Steinhart-Hart for thermistor

prof_brainoprof_braino Posts: 4,313
edited 2013-11-24 16:29 in Accessories
I'm working on a spreadsheet http://propforth.googlecode.com/files/Steinhart-Hart20131121-1805.xlsx
for calculating a table off thermistor reading that coorespond to degrees centigrade.

But the spreadsheet chokes on the inverse equation, due to square root of negative numbers.

Any ideas on the right way to do this? Right now I just guestimate each value,, it take a long time.

http://code.google.com/p/propforth/wiki/ThermistorTempSensor

http://code.google.com/p/propforth/wiki/ThermistorRawLogger

Thanks!

Comments

  • Tracy AllenTracy Allen Posts: 6,658
    edited 2013-11-23 19:25
    Can you just use a lookdown in the forward table stored as DATa on the Prop, rather than lookup in the backward table? RCtime measurements are not that great anyway, what with tolerances of the threshold and of the capacitor.
  • prof_brainoprof_braino Posts: 4,313
    edited 2013-11-24 06:52
    Thanks for the reply Tracy. Can you example "lookdown" here?

    I'm trying to create the lookup table of RC values that coorespond to temperatures, so I can put this into the prop. I think I can use Steinhart-Hart to build this table. I don't want to execute Steinhart-Hart on the prop, I want to pre-calculate the values using this spreadsheet.

    The purpose of the spread sheet is to create a lookup table in prop. There are 100 entires in the table, one for each degree contigrade between zero and 100 C. The table contain time counts, if the RC time is close to one of the table entries, the temperature in C should be close to that entry's index.

    I could only get a stable temperature at three points: freezing, ambient, and boiling. I couldn't read the resistance directly (at ambient my meter reads 10.2 k ohms for these 10K thermistors). But I could read the RC time. My experiement is to see how well it works to use RCtime counts instead of direct rresistance readings. I've heard this meethod works realy well for two points (upper and lower threshold). But of course I have to do it the hard way and try to make a full range general purpose thermometer.

    So. I'm fairly confident about the Steinhart-Hart coefficeints; if I put in the RCtime values (instead of resistance values) for freezing, ambient, or boiling, I get out the temperature I expect.

    Now I just have to figure out the other 97 table values. But the inverse equation doesn't work for me. Instead I have to start plugging in values until each temperature comes out. It only takes about half an hour. Once I build the table, I think I can use that thermistor as a thermometer. I havent checked it again the meter yet. Problem is each thermistor is a little different. I'm looking for a better way to fill in the table.

    Thanks
  • Tracy AllenTracy Allen Posts: 6,658
    edited 2013-11-24 10:51
    For a look-down, enter the RC values just as they are in your existing spreadsheet, one for each temperature. Even one at every 5 or 10 degree increment, depending on the precision, speed and memory constraints. At run time, find the position of the RC value in the table using a binary or linear search. That ends up with two RC values and the two temperature values that bracket the unknown, so interpolation can pinpoint the "exact" temperature. Of course, that is a lot of code and a speed hit that you would not have with look-up using the inverse table of temperature vs resistance.

    I've never tried to compute an inverse of Steinhart-Hart, but I'm surprised that any term would end up with a negative value under the square root. The Wiki shows a nasty inverse that involves the exponential of the difference between two cube roots, and one of the terms up top does involve a square root. Is that the formula you are trying to put into Excel? I always wonder about trust in Excel, too.

    I recently had to do a thermistor in Spin, but with a voltage divider into a standard ADC, reading the voltage, then calculate the resistance.
  • prof_brainoprof_braino Posts: 4,313
    edited 2013-11-24 13:13
    OK, I was calling that a look UP table. That is what I think I am doing. My question is about how to build the table of R values. For the time being I have to try arbitrary R values in the Steinhart-Hart spreadsheet, until I got one reasonably close to each degrees C. It only takes a few tens of seconds after i get going, but after 97, I think there should be an eaiser way. The inverse equation would have been first choice, and I too was surprised it didn't work.

    Yes the wiki page is my reference. I got the impression the equation shuld just work, and I was hoping I just have something wrong. I guess its just funky. No biggie, just tendious.
  • Tracy AllenTracy Allen Posts: 6,658
    edited 2013-11-24 16:27
    I see what you mean about the negative values in the formula. I hadn't clicked on the other tabs in your spreadsheet. The link on the wiki is to an app note from a manufacturer, and the example thermistors all have coefficients A, B and C as positive numbers. So it works out. But it really does blow up with your negative C coefficient. Nothing wrong with the coefficient though; it does work beautifully in your spreadsheet. Go figure. I see the same inverse formula in textbooks, for example, Introduction to Measurements and Instrumentation by Arun Ghosh.

    Maybe over a narrow range you can use the simpler beta form,
    RT = R0 * exp(
  • Tracy AllenTracy Allen Posts: 6,658
    edited 2013-11-24 16:29
    I interpret look-UP to mean that you have a table of values of temperature corresponding to evenly spaced values of R or RC. By look-DOWN, I mean that you have a table of values of R or RC corresponding to evenly spaced values of temperature. The latter is exactly what you get for the forward Steinhart-Hart formula. And I think your are trying to derive the former. Look-UP is a relatively simple process, because the table index has a simple linear relation to the measured variable. Look-DOWN on the other hand means that you have to search the table to find the index. Not hard, but it does take more code and more execution time. Maybe I'm not using the right terminology. With thermocouples, there is usually both a lookup (to find the µV corresponding to the reference temperature) and then a lookdown (to find the temperature corresponding to combined µV from the reference and measurement junctions).
Sign In or Register to comment.