Proton BASIC Compiler - Steinhart-Hart Linearization Worksheet


  • PicŪ Basic


  • Steinhart-Hart Linearization Worksheet

    I needed to better understand and to be able to better visualize how a standard 10k NTC (Negative Temperature Coefficient) thermistor would respond to changes in temperature. I knew the basic details, but wanted more visualization. I have made this Excel worksheet a bit flexible, so that you can change the details somewhat to better understand your particular Thermistor. The sheet is locked, to prevent you from accidentally deleting formulas, and allowing you to only change the YELLOW text boxes, etc, but can be unlocked with the password: "proton".

    I have found Thermistors to be very helpful, inexpensive and surprisingly accurate (+/- ~ 0.5°F) though in the future, I will add a method I've come across that increases the accuracy down to 0.2°F.

    Les and others have provided ample code samples, and, should anyone need assistance, I have several variants of my own for both 16F PICŪ (where you cannot use the Log command) and the 18F PICŪ (where you can). Once you get your head around the concept, the code is very simple. You are simply using Stienhart & Hart's (two oceanographer's from the late 60s) algorithm to make the relationship between temperature and resistance a linear relationship. With this simple formula, you get temperature based on 4 inputs: Resistance & 3 coefficients from the thermistor data sheet. We'll call these coefficients a, b & c. That's it.

    The linearization formula is this:
    Temperature (in Kelvin) = 1 / [ a + (b * lnR) + (c * (lnRģ)) ]

    where ln R = the natural log of the resistance.
    The natural logarithm is the logarithm to the base "e", where e is an irrational constant approximately equal to 2.718
    Think of this as e^x = R, or, in other words, e raised to what power = Resistance

    Finally to get from Kelvin to Celsius, you simply add 273.15. (°C = K + 273.15). Should you also want to go to Fahrenheit, you simply take these results and do the following: (°F = 9/5 °C + 32)

    The colder it is, the more resistive the NTC Thermistor will be...

    The standard circuit is a simple resistor divider circuit with the balance resistor on top and the NTC Thermistor on bottom. When choosing the balance resistor, keep in mind that you want the resistor to be large enough to limit the current through the thermistor to prevent "self-heating"

    For a 10-k NTC thermistor, I typically use 16.9kΩ. If my reference voltage is 5.0v, that limits the current to the thermistor to a max of 500ĩA.

    The Thermistor data sheet should have the linearization constants (a, b & c...and sometimes d, etc...but mine had just a, b & c) Enter those values (if known). Next enter your Reference voltage (typically Vdd which is 5.0v or 3.3), unless you're using some other reference source on purpose such as 4.095, etc).

    Here is an example using the constants, etc based on my particular thermistor's data sheet:

    Code:
    'Carl's Notes from Thermistor Data Sheet
    'Therm-O-Disc: ECONOMY APPLIANCE PROBE SERIES 
    'NTC Thermistor Probes (10JH/11JH)
    'R-T Formula: 1/T = a + b(ln R) + c(ln R)^3
    'Values for 10K at 25°C:
    'a = 1.125498166 x 10-3
    'b = 2.346771694 x 10-4
    'c = 8.579674698 x 10-8
    
    'Operating Temperature Range
    '-40° to 80°C
    '(-20° to 105°C with optional UL1015 lead wires)
    'Thermal Time Constant
    '10 seconds typical (liquid)
    '25°C/50°C
    'Dissipation Constant
    '4mW/°C
    The Excel file can be found here: http://click-server.com/forumfiles/misc/48946-Steinhart-Hart Worksheet.xls

    This is simply a short article intended to pass on to fellow Proton/Amicus users, a handy worksheet I created for my own purposes. Feel free to use & modify as you wish, though I don't claim it is perfect, it was for my own needs and purposes.

    You will see that it creates a table for Adval, Input voltage, thermistor resistance and the resulting temperatures in 3 different units, all based on 5 simple inputs (the 3 constants mentioned above, plus the Balance Resistor value, along with the Max Reference Voltage)

    For those of you who have seen this before, it has been updated and slightly improved.

    Best Regards,
    Carl (Citius)
  • Recent Activity

    david-48000

    Valid time in NMEA sentance

    Thread Starter: SimonJA

    Is there any way to know that a GPS nmea sentence has the correct time? I use a module to keep a pic rtc accurate but have noticed that when...

    david Yesterday, 20:40 Go to last post
    david-48000

    GPS speed logger for RC planes.

    Thread Starter: david

    Hi All, This is a simple project to allow the logging of RC plane speeds to help determine battery, motor and prop variables. The code is crude and...

    david Yesterday, 21:01 Go to last post
    Les-15

    Baud rate problem

    Thread Starter: charliecoultas

    I am trying to run one of the USARTs on a 24HJ128GP502 at 115,200 bits/second. I thought I had defined the clock frequency wrong but Delayms gives...

    Les Today, 17:06 Go to last post