Thermistor help

Discussion in 'General Electronics Chat' started by chimera, Dec 26, 2011.

  1. chimera

    Thread Starter Member

    Oct 21, 2010
    122
    2
    Hello. Im trying to figure how to linearize a thermistor (10 KΩ). I want to learn to do this so that I can send the data to a uC.

    I have already worked with LM35 but I am not pleased with its result. Its not to sensitive or accurate. It was easy to linearize the LM35 becaz of its straight forward voltage to temp graph (a basic linear equation).

    However, I would like to know how to work with a thermistor. Eventually, I want to find a good approximation over a predicted range of temperature..say 25°C to 55°C.

    Any ideas where to begin :confused: Thanks
     
  2. MrChips

    Moderator

    Oct 2, 2009
    12,410
    3,353
    You need to tell us a bit more than this.

    1. What is the part number of the thermistor?
    2. How do you plan on digitizing the thermistor?
    3. What MCU are you planning on using?
    4. How many bits of digitized data are you planning on having?
     
    chimera likes this.
  3. steveb

    Senior Member

    Jul 3, 2008
    2,433
    469
    You can't fully linearize it at the hardware level. However, you can make it more linear by placing a resistor in series with it and then placing a resistor in parallel with that and then placing a resistor in series with that. Then choose the three resistor values that best fit to a line, under the assumption that you will drive it with a current source. A current source drive tends to make it more linear than a voltage divider arrangement. Once you determine the circuit structure formulas, you can fit to a line using standard linear regression techniques and the thermistor data.

    The final linearization must be done at the code level, but that is easier if you first linearize it with resistors. In addition to linearizing, you will want to calibrate each thermistor individually for gain and offset after the general linearization (both hardware and software linearization) that you apply to to all devices.
     
    chimera likes this.
  4. pilko

    Active Member

    Dec 8, 2008
    213
    20
    If you check the resistance from the chart for a temp half way between the two limits, ie 40*, then put a resistor in // of the same value. The graph will be fairly linear within that range.
    Better to use a DS18B20 digital temp sensor.

    pilko
     
    chimera likes this.
  5. crutschow

    Expert

    Mar 14, 2008
    12,969
    3,219
    The thermistor is likely to be no more accurate then the LM35. If you need more sensitivity from the LM35 just add an op amp non-inverting amplifier. You can add some offset to that if you want to center the output over the desired temperature range to match the uC input voltage range.
     
    chimera likes this.
  6. joeyd999

    AAC Fanatic!

    Jun 6, 2011
    2,677
    2,696
    You are incorrect. The LM35 has best case accuracy of 0.25C at room temperature and 0.75C across the operating temperature range.

    Precision thermistors that have an accuracy of 0.1C from 0-70C are available at Digikey, for example:

    PS502J2

    The nice thing about these is you don't need a voltage reference for accurate conversion. Just operate them ratiometrically with Vref as Vdd. Then, using a table (generated as described below) and piecewise-linear approximation, compute the actual temperature.

    The only thing to watch out for is self-heating. They will generate a 1C error for every mW dissipated (in still air), but even this can be corrected and/or minimized.

    Also wrong. Series a fixed resistor with the thermistor (as a voltage divider). Pick a value for the resistor close to the midpoint of your desired temp range, as per pilko's suggestion. Then, plot Vout vs. temp (using the mfgrs temperature table) in a spreadsheet. Then, adjust your fixed value till the slope is steepest within the range of interest.

    For best results. when you've determined the proper value, use a 0.1% fixed resistor.
     
    chimera likes this.
  7. crutschow

    Expert

    Mar 14, 2008
    12,969
    3,219
    True. But I should have elaborated on my statement. After you use typical 1% bias resistors for the thermistor circuit you will not get such high accuracy unless you calibrate the circuit, which means the accuracy is no better than your calibration. Unless you have access to a calibration lab that is unlikely to be better than the LM35 intrinsic accuracy.
     
    chimera likes this.
  8. joeyd999

    AAC Fanatic!

    Jun 6, 2011
    2,677
    2,696
    With the part I mentioned, and a 0.1% resistor, error is less than 0.2C (ignoring self heating), and this is *without* requiring a precision reference for the A/D conversion.

    Edit: Also, no calibration required.

    BTW...we are splitting hairs! OP never indicated what accuracy is required.
     
    Last edited: Dec 27, 2011
    chimera likes this.
  9. strantor

    AAC Fanatic!

    Oct 3, 2010
    4,302
    1,988
    chimera likes this.
  10. steveb

    Senior Member

    Jul 3, 2008
    2,433
    469
    In reference to my post above, I can give an example of placing a 10 K resistor in parallel with the 10K thermistor and then placing a 5 K resistor in series with that parallel combination. The total value is still 10 K at 25 deg C, but the response is more linear, at the expense of being less sensitive.

    I've included two plots. I use two typical negative temperature coefficient thermistor curves for the comparison.

    The first plot shows how both of these curves are more linear if the additional resistors are used. It is also clear that sensitivity is sacrificed for linearity. Note that it is implied that a current source will be driven through the network to maintain the better linearity. The use of a voltage divider will make it more nonlinear.

    The second plot allows the linearity to be seen more clearly. Here the 10 K resistance is subtracted from both resistance curves, and then the modified resistance in multiplied by 10 times to make it clear that the improved linearity is really there.

    It is possible to get better linearity with more complicated resistor networks and with optimized resistance values, however, this takes time to figure out, and I leave that to the OP, if this seems interesting to him. This type of curve is much easier to linearize in code than the raw resistance curve. I'm not saying this is necessarily the best option because tradeoffs are involved, but it is an option under the right circumstances.
     
  11. joeyd999

    AAC Fanatic!

    Jun 6, 2011
    2,677
    2,696
    So, to be clear, you are recommending the following:

    1. Two precision resistors (for linearization);
    2. A precision current source (to drive the network);
    3. A precision voltage source (as a reference for the A/D converter);
    4. A voltage vs. temperature curve equation (for temperature estimation based upon input voltage vs. Vref);
    5. Code to preform the above equation.

    I suggested the following:

    1. One precision resistor;
    2. A look-up table (easily derived from the mfg. data sheet);
    3. Code to preform piece-wise approximation (interpolation between datapoints).

    I think what's important here is the OP asked originally, "Im trying to figure how to linearize a thermistor (10 KΩ). I want to learn to do this so that I can send the data to a uC".

    The answer is, he doesn't have to. The CPU can do the linearization. IMHO, the front-end should only be responsible for maximizing the dynamic range (i.e. sensitivity) of the incoming signal. And with as little contributed error as possible. A single resistor does this!
     
    chimera likes this.
  12. steveb

    Senior Member

    Jul 3, 2008
    2,433
    469
    To be clear, I'm not recommending my suggestion, but am just providing information that seems relevant to the question.

    I think your ideas and comments are very good, and as I said in my above post about my suggestion, "I'm not saying this is necessarily the best option because tradeoffs are involved, but it is an option under the right circumstances." I really don't know the details of the OPs application, so it's better to provide more information and let him decide.
     
    chimera likes this.
  13. pilko

    Active Member

    Dec 8, 2008
    213
    20
    @joey99,
    You stated that steveb and I were "incorrect/wrong" in our methods to improve liniarization.---In fact we were NOT wrong. Different recommendations from yours do not make them wrong.

    pilko
     
    chimera likes this.
  14. joeyd999

    AAC Fanatic!

    Jun 6, 2011
    2,677
    2,696
    Steveb was incorrect in saying that "The thermistor is likely to be no more accurate then the LM35." I gave an example where a particular thermistor's basic accuracy is 250% better at room temperature, and 750% better across the operating temperature range.

    I further elaborated that, with only a single precision resistor, and no voltage or current sources, the overall accuracy can be held to less than 0.2C, or 350% better than the *best* accuracy achievable by the LM35 (without manual adjustment in either case). Additionally, the use of an LM35 solution requires an accurate Vref for digitization.

    WRT your comment, I was considering the OP's original question, which was:

    This is a two part question: 1. Linearization, 2. Digitize to a CPU. I was addressing the whole question, not just the linearization part.

    Simply paralleling some resistors does not get the temperature data into a CPU. I was trying to illustrate that the OP could get high accuracy with a simple voltage divider and no additional precision references.

    You provided a solution to the first part of the question, without further explanation of how to get the resulting temperature dependent resistance value accurately into the CPU. Perhaps the use of the word "wrong" was too strong. But at best, it was incomplete.

    You are correct: there are many ways to skin a cat...but few good ones.

    EDIT: SteveB *did not* make the above referenced comment re thermistor vs. LM35 accuracy. I sincerely apologize for the misattribution!
     
    Last edited: Dec 28, 2011
    chimera likes this.
  15. pilko

    Active Member

    Dec 8, 2008
    213
    20
    @ joeyd999,

    "You are correct: there are many ways to skin a cat...but few good ones".

    I guess you are inferring then that the only good ways are your ways.

    pilko
     
    chimera likes this.
  16. steveb

    Senior Member

    Jul 3, 2008
    2,433
    469
    Excuse me sir !

    I never said that.

    Personally, I haven't done a direct experimental comparison to make a statement either way on that question.
     
    chimera likes this.
  17. joeyd999

    AAC Fanatic!

    Jun 6, 2011
    2,677
    2,696
    My most humblest apologies, Steveb. I got the posts mixed up. Crutschow made that comment. I will edit my comment to reflect my mistake!
     
    chimera and steveb like this.
  18. joeyd999

    AAC Fanatic!

    Jun 6, 2011
    2,677
    2,696
    No! I occasionally do things wrong. As a matter of fact, I made some smoke yesterday that brought one of our assembly lines to a halt :p

    But I always try to learn to do things better.

    My posts on this thread were for the benefit of the OP. I was trying to illustrate what I consider to be one of the best ways to get accurate temperature info into a CPU. I'll admit, it's not the *cheapest* way: a precision thermistor can cost up to $8 in single quantities. But they are nice because they are easy to use and accurate. And linearization can be done in code, and there need be no dependency on other accurate components. And its hard to do wrong.

    In this case, given the OP's question, yes, I think this is the best solution. You are free to disagree!
     
    chimera likes this.
  19. pilko

    Active Member

    Dec 8, 2008
    213
    20
    A cheap, simple and accurate way is also the Dallas DS18B20 (10 bit capability), that I already mentioned.

    pilko
     
    chimera likes this.
  20. MrChips

    Moderator

    Oct 2, 2009
    12,410
    3,353
    Have you noticed how the conversation can get heated and go on for a very long time with no signs of the OP? I never got a response on my questions at post #2.

    I have to side with joeyd. We can maximize the sensitivity of the thermistor and then deal with the linearization on the MCU.

    You don't even need an ADC to digitize the thermistor. A common solution is to use a capacitor and measure frequency or period, depending on whether the thermistor exhibits positive or negative temperature coefficient. You can easily get 12 to 16-bit resolution using this technique. No additional components required!
     
    chimera likes this.
Loading...