Author Topic: How to mathematically linearize a thermister output  (Read 7092 times)

0 Members and 1 Guest are viewing this topic.

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 18092
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
How to mathematically linearize a thermister output
« on: March 31, 2013, 09:29:41 am »
I'm doing a temperature control project and will use a thermister, idealy I'd have a R/C output but as we all know the scale is a bit exponential. Is there a way to mathematically back track to the original temnperature value ? say by knowing the formula that gets the resistance can i reverse it on the resistance to know the temnperature without having to write in a complete table of resistances ? or maybe that is the best thing ?
 

Offline firewalker

  • Super Contributor
  • ***
  • Posts: 2452
  • Country: gr
Re: How to mathematically linearize a thermister output
« Reply #1 on: March 31, 2013, 09:34:52 am »
There is Steinhart-Hart equation.

http://en.wikipedia.org/wiki/Steinhart%E2%80%93Hart_equation

I have used it several times and it is fairly accurate.

Alexander.
« Last Edit: March 31, 2013, 09:37:09 am by firewalker »
Become a realist, stay a dreamer.

 

Online IanB

  • Super Contributor
  • ***
  • Posts: 12477
  • Country: us
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 18092
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: How to mathematically linearize a thermister output
« Reply #3 on: March 31, 2013, 09:39:09 am »
but does that formula apply to any thermistor ?

Ian: Nope don't really want to use one of those unless you can get them cheap embedded in 3/8" BSPT bosses with a deutsh socket on the back.
 

Offline firewalker

  • Super Contributor
  • ***
  • Posts: 2452
  • Country: gr
Re: How to mathematically linearize a thermister output
« Reply #4 on: March 31, 2013, 09:41:49 am »
Every thermistor I have used seems to follow that "rule". I am using this datasheet for the values.

http://dl.dropbox.com/u/31742622/ntc.pdf

Alexander.
« Last Edit: March 31, 2013, 09:54:39 am by firewalker »
Become a realist, stay a dreamer.

 

Offline mrflibble

  • Super Contributor
  • ***
  • Posts: 2051
  • Country: nl
Re: How to mathematically linearize a thermister output
« Reply #5 on: March 31, 2013, 09:42:31 am »
There is Steinhart-Hart equation.

Thanks! Bookmarked for future reference.
 

Offline Rerouter

  • Super Contributor
  • ***
  • Posts: 4704
  • Country: au
  • Question Everything... Except This Statement
Re: How to mathematically linearize a thermister output
« Reply #6 on: March 31, 2013, 09:46:34 am »
so to this same end, is there some way to mathematically work out a correction curve from say 100 points? (preferably not expressed as an integral)
 

Online IanB

  • Super Contributor
  • ***
  • Posts: 12477
  • Country: us
Re: How to mathematically linearize a thermister output
« Reply #7 on: March 31, 2013, 09:53:34 am »
I think with 100 points you could use a lookup table.

If you want a simpler mathematical formula you have to find a pattern that fits the data. Knowing something about the physics can often help.
 

alm

  • Guest
Re: How to mathematically linearize a thermister output
« Reply #8 on: March 31, 2013, 10:08:38 am »
Fitting a polynomial of either R or log(R) as in the Steinhart-Hart equation would probably be my first guess. Polynomials are relatively cheap, since they only involve multiplication, which many uCs can do in a reasonable number of cycles.

The issues with lookup tables is that you still need interpolation for values in between, unless your ADC only outputs 100 codes.
 

Offline Rerouter

  • Super Contributor
  • ***
  • Posts: 4704
  • Country: au
  • Question Everything... Except This Statement
Re: How to mathematically linearize a thermister output
« Reply #9 on: March 31, 2013, 10:20:37 am »
well in my case it is more to devise a sound model for automotive cross coil gauges, as i occasionally have to alter the calibration, but if i knew how the relationship as a whole shifts i could more easily calculate the values when something odd is requested,
 

Offline mikeselectricstuff

  • Super Contributor
  • ***
  • Posts: 14089
  • Country: gb
    • Mike's Electric Stuff
Re: How to mathematically linearize a thermister output
« Reply #10 on: March 31, 2013, 10:52:32 am »
For the level of accuracy of a typical thermistor, a lookup table with linear interpolation will  typically take less space than the maths code to calculate it. The same table can also be used to compensate for the measurement method where you don't get a linear resistance value (e.g. when using a simple potential divider).
Youtube channel:Taking wierd stuff apart. Very apart.
Mike's Electric Stuff: High voltage, vintage electronics etc.
Day Job: Mostly LEDs
 

Offline Neilm

  • Super Contributor
  • ***
  • Posts: 1559
  • Country: gb
Re: How to mathematically linearize a thermister output
« Reply #11 on: March 31, 2013, 11:05:54 am »
I have seen a circuit that would roughly linearise a thermistor output. I don't remember it very well. As I recall, you had an op-amp - fed a reference voltage into one pin and had the thermistor in parrallel with a resistor in the feedback path. It made it approximately linear for a certain temperature range.
Two things are infinite: the universe and human stupidity; and I'm not sure about the the universe. - Albert Einstein
Tesla referral code https://ts.la/neil53539
 

Offline nessatse

  • Regular Contributor
  • *
  • Posts: 99
  • Country: za
Re: How to mathematically linearize a thermister output
« Reply #12 on: March 31, 2013, 11:34:29 am »

It all depends on the temperature range and accuracy you require.

The mere act of using a thermistor in a voltage divider configuration will linearise the output to a certain extent (for a specific temperature range).  The choice of series resistor is quite important though   If you use a common 10k thermistor for example, in series with a 4k7 as the 'top' of the voltage divider, you will get a fairly linear output over the 20C-80C range, within 2%.  No lookup tables or complex maths required, just a simple scaling factor to convert the voltage to temperature.


 
 

Offline mrflibble

  • Super Contributor
  • ***
  • Posts: 2051
  • Country: nl
Re: How to mathematically linearize a thermister output
« Reply #13 on: March 31, 2013, 11:43:54 am »
For the level of accuracy of a typical thermistor, a lookup table with linear interpolation will  typically take less space than the maths code to calculate it.

Pretty much this. I usually write a small matlab script that calculates the datapoints and truncates it to n-bits precision. Then I do an error plot of the LUT + interpolation solution versus ideal value. If that all looks reasonable then you spit out the table with some printf's so you get some ready to include C/verilog/whatever code, and you're good to go.
 

Offline mikeselectricstuff

  • Super Contributor
  • ***
  • Posts: 14089
  • Country: gb
    • Mike's Electric Stuff
Re: How to mathematically linearize a thermister output
« Reply #14 on: March 31, 2013, 12:02:09 pm »

It all depends on the temperature range and accuracy you require.

The mere act of using a thermistor in a voltage divider configuration will linearise the output to a certain extent (for a specific temperature range).  The choice of series resistor is quite important though   If you use a common 10k thermistor for example, in series with a 4k7 as the 'top' of the voltage divider, you will get a fairly linear output over the 20C-80C range, within 2%.  No lookup tables or complex maths required, just a simple scaling factor to convert the voltage to temperature.
 
It's also easy to use multiple, selectable resistors to select different ranges by connecting to different MCU pins and tristating the unused one(s).
Youtube channel:Taking wierd stuff apart. Very apart.
Mike's Electric Stuff: High voltage, vintage electronics etc.
Day Job: Mostly LEDs
 

Offline firewalker

  • Super Contributor
  • ***
  • Posts: 2452
  • Country: gr
Re: How to mathematically linearize a thermister output
« Reply #15 on: March 31, 2013, 12:23:20 pm »
A Sunplus (I remember Sunplus batteries, the same company?) application note.

http://mcu.sunplusmcu.com/soft/75_en_Application_note/AN_SPMC75_0101_en_V1.3.pdf

Alexander.
Become a realist, stay a dreamer.

 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf