Curve fit for sensor equation

Go To Last Post
40 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

1. Have a thermistor, data whose dataset is available not anything else from company except B value. Attached is data.

 

2. Trying to make a equation for it and implement for 8 bit MCU, usin IAR IDE.

 

3. First I made this code, steinhart thermistor equation. calculated values of A,B,C from this site:  https://www.thinksrs.com/downloa...  . Put three values at -20C, 25C & 100C and get A,B,C

 

uint8_t get_ntc_temperature_4(float32_t resistance , float32_t *tempearture_c)
{
    uint8_t err = 0U;
    float32_t x;
    float32_t x2;
    float32_t x3;
    
    if( (resistance <= 956040.0f) &&  (resistance >= 6683.0f) )
    {
        x = logf(resistance);
        x2 = x * x;
        x3 = x2 * x;
        x = 0.000641295533f + (0.0002233488434f * x) + (0.0000000926090998f * x3);
        x = 1.0f / x;
        *tempearture_c = x - 273.15f;
   
    }    
    else
    {
        err = 1U;
    }    
       
    return err;

}   

 

4. Then made equation using curve fit tool and below is code:

 

uint8_t get_ntc_temperature_2(float32_t resistance , float32_t *tempearture_c)
{
    uint8_t err = 0U;
    float32_t c0;
    float32_t c1;
    float32_t c2;
    
    if( (resistance <= 956040.0f) &&  (resistance >= 482170.0f) )
    {
        c0 = 14.5029518320319131f;
        c1 = -0.000057344817030149406f;
        c2 = 0.000000000021788855747503695f;
    }    
    else if(resistance >= 250140.0f)
    {
        c0 = 29.3136847463533279f;
        c1 = -0.000119496884518122221f;
        c2 = 0.0000000000876747221220605721f;    
    }    
    else if(resistance >= 130230.0f)
    {
        c0 = 45.3985586636038647f;
        c1 = -0.000249401966454676711f;
        c2 = 0.000000000352768556658954028f;    
    }    
    else if(resistance >= 71230.0f)
    {
        c0 = 62.1448935476119572f;
        c1 = -0.000506560472110208432f;
        c2 = 0.00000000135019658772898851f;    
    } 
    else if(resistance >= 39200.0f)
    {
        c0 = 79.7753263268828902f;
        c1 = -0.00100556530593662709f;
        c2 = 0.00000000491385322365418885f;    
    } 
    else if(resistance >= 21830.0f)
    {
        c0 = 98.8979251125107339f;
        c1 = -0.00198872984475097995f;
        c2 = 0.0000000176669521860767602f;    
    } 
    else if(resistance >= 12750.0f)
    {
        c0 = 118.809289117525665f;
        c1 = -0.00381338043851388829f;
        c2 = 0.0000000598289053823529209f;    
    } 
    else if(resistance >= 7327.0f)
    {
        c0 = 140.313484336487619f;
        c1 = -0.00722784306211046376f;
        c2 = 0.000000196440993753396293f;    
    } 
    else if(resistance >= 6683.0f)
    {
        c0 = 133.215333415477943f;
        c1 = -0.00480709971651089099f;
        c2 = 0.0f;    
    } 
    else
    {
        err = 1U;
    }    
    
    
    if(0U == err)
    {        
        *tempearture_c = c0 + (c1 * resistance) + (c2 * resistance * resistance);

    }    
    
    return err;

}

 

5. Size build on full size optimization on IAR for 8 bit MCU:
a) No function call: 
    5 138 bytes of readonly  code memory
    139 bytes of readonly  data memory
    357 bytes of readwrite data memory

    
    
b) With polynomial equation fit:   
    5 593 bytes of readonly  code memory
    139 bytes of readonly  data memory
    357 bytes of readwrite data memory

 

c) With natural log: 
   5 820 bytes of readonly  code memory
    139 bytes of readonly  data memory
    359 bytes of readwrite data memory 

 

 

6. Noticed that with polynomial fit extra space is 455 bytes  & with natural log its 682 bytes.

 

 

7. Error with polynomial fit is +0.069 to -0.098C.
 Error with natural log is slightly more though.

 

8. Any other better method to implement or curve fit this data? Max end function accuracy I am looking is +-0.099C.

 

PS: In function call, I got coefficients generated in float64_t in curve fit toolbox, put f in the end though. 

 

 

 

 

 

 

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have enough time for float operations and circuit is main powered so no issues in processing time, only thing constaint is size, lesser the better.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Why do you have multiple values of c0/c1/c2?    The c0/c1/c2 are used to form the curve over the entire temperature range 0-100 or whatever your needed range is.

 

Then, knowing R & these 3 values you can find the corresponding temperature (and you don't generally linearly know R, unless you use a current source...a divider is nonlinear in R (Volts vs R)). 

Are you trying to break the curve into multiple pieces for better fit?

 

In any case, none of this will matter, since it needs actually calibrated at each of those curve sections...you can't just read ohms off some chart and have any hope of a highly accurate temperature.

You could probably get away with some crude chart resistance lookup, if you are willing to be 4 or 5 degrees off (or maybe even more). 

Otherwise, you need to measure the resistances at all of these temperatures for each & every sensor.

 

Do you need to actually display the temperature?  Many times you don't, but perhaps you do.   For instance, an adjusted dial setting (say dial from 0-10) can be maintained, without actually knowing what the numerical temperature is (as is often seen with freezer knobs (that say cold...colder....coldest).

Getting within 0.1 deg is going to take calibration of the more than just the thermistor--it will involve all of the components used in the measuring, so they are inherently part of any cal process.

 

You can now get some amazingly cheap platinum RTD's (thanks China)...maybe they will be your new friend.  Years ago , event the cheapest decent RTD could cost more than an 8-track player.

 

As you can see, the super-cheap PT100 platinum RTD starts off with a highly linear response (far far better than a thermistor) & is easily calibrated for even more precise gain & offset.

 

for comparison, your thermistor

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Wed. Jul 8, 2020 - 07:49 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

@ avrcandies , multiple c0,c1,c2 since it gives acceptable error range in this smaller section only. For example -20 to -8, -8C to +5C and so on. So multiple temperature parts from -20C to 100C.

But this equation I generated is better accurate than steinhart equation, and surprisingly takes only 455 bytes for this function.

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

multiple c0,c1,c2 since it gives acceptable error range in this smaller section only.

A nice and probably valid thought, but you are wasting your time, unless you implement a labor intensive calibration at all of these different temperature curves.  That also means you need precision equipment & a setup & settling time to measure better than what you hope to calibrate to.  Make the easy choice and use an RTD & much easier calibration (or maybe none at all, if you can stand 1 or 2 deg raw error).

 

Sensor manufacturers offer a wide range of sensors that comply with BS1904 class B (DIN 43760): these sensors offer an accuracy of ±0.3 °C at 0 °C. For increased accuracy, BS1904 class A (±0.15 °C) or tenth-DIN sensors (±0.03 °C). Companies like Isotech can provide standards with 0.001 °C accuracy.

 

Note that if you want to cal a lot tighter than the raw RTD, even then you may need to apply a curve fix..but you start off much better.

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

@ avrcandies , cant use any other sensor., Thermistor is inbuilt into this sensor:    https://www.avrfreaks.net/comment/2952886#comment-2952886

This company only sending data tables they dont have any excat mathematical model for dataset.

 

I was thinking can code me made  more optimize for given data?  However accuracy required is +-0.0999

With polynomial equation I got accuracy of  +0.069 to -0.098C ,this is purley mathematical accuracy though

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

How many bits in and how many bits out? 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

avrcandies wrote:
freezer knobs (that say cold...colder....coldest).

If only!

 

Usually they say something unhelpful like "0 ... 9" or "high ... low".

 

And then you're left wondering whether '0' or "low" is the lowest temperature, or the lowest amount of cooling (ie, highest temperature!)

 

angry

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

sometimes you can 

 

sometimes not!

 

 

,this is purley mathematical accuracy though

And without a lot of hard labor that is all that it is.   If you must, be happy with one curve...that is tough enough for undergoing the lab cal.

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Wed. Jul 8, 2020 - 08:32 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Vindhyachal Takniki wrote:
1. Have a thermistor, data whose dataset is available not anything else from company except B value. Attached is data.

You could have posted directly these values.

 

  • R25=100000Ω±5% (25℃)
  • B25/100=3964K±0.5%

 

But there is a problem with the 5%  - look in the table at the value for 25°C


 
TEMP RESISTANCE    
  (Ω)    
(℃) MIN. CENTER. MAX.
25 98000 100000 102000

 

That is ­±2%. What to believe?

 

 

Vindhyachal Takniki wrote:
4. Then made equation using curve fit tool and below is code:

Oh dear-oh-dear; What are you thinking ?

Using a quadratic to curve-fit something essentially logarithmic is never going to work well. An especially strange decision because the Steinhart-Hart model was developed exactly for this thermistor curve fitting purpose.

 

If Steinhart-Hart over the entire temperature range doesn't fit well, then either limit the end-points of the range to increase the accuracy between those points at the expense of accuracy outside them; or split it into two (or more) ranges; you have the data table to do this.

 

Vindhyachal Takniki wrote:

8. Any other better method to implement or curve fit this data? Max end function accuracy I am looking is +-0.099C.

For my precision thermistor work I used a lookup table and set different error criterion allowed depending on the temperature measured. You might get by with a 46 entry LUT with errors thus:

/*
Thermistor - LOOKUP TABLE AREA
characterisation Thermo-metrics material F published curve
based on IPTS-68 Celsius values.  Differences from ITS-90
values are smaller than the thermistor tolerance of ±0.2°C
Generation date 31st March 2000
accuracy criterion set to
    0.1°C     -80 to -40°C
    0.033°C   -40 to +60°C
    0.05°C    +60 to +100°C
    0.1°C    +100 to +150°C
characteristic pegged at 22 and 26°C, instead of 0°C
All non-25°C values biased by half the error criterion
*/

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

@ N.Winterbottom , thanks for ur reply.

1. My idea was to break down complete thermistor graph into multiple sub graphs, and try to fit those data points inside the 2nd order equation. Only single quadratic equation cannot fit complete -20C to 100C graph, so I have to break it down into 10 sub parts to do so.   If I pass on given resistance values (nominal), I got accuracy <0.099.  Though I havent checked on in between resistance values yet.

 

2. Log equation is bit heavy for my 8 bit MCU. Its taking 682 bytes. Implemented log equation also.  While multiple-polynomial equationt aking 455 bytes.

 

3. Will see and implement LUT also

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

N.Winterbottom  Edit:  Implemented mulitple part quadratic, same way we do on LUT, where we find values two points on LUT, and then apply linear interpolation between those. Am i wrong here?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes - Most commonly linear interpolation is used between adjacent X-Y table rows of LUT, mainly because calculation of y=mx+c is trivial.

 

To calculate y=ax2 + bx + c is not impossible; but more difficult for a triplet of X-Y table rows.

 

In a way you are right; what you have done with your polynomial code is pre-calculate the coefficients for each segment.

 

For my lower precision work (battery temperature etc) I just use the log function using the beta value and don't worry about flash.

 

<edit> Added beta value clarification </edit>

 

Last Edited: Fri. Jul 10, 2020 - 11:15 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I would make a LUT "the wrong way around" for each deg

 

231 values (-80 to 150) of the res.(which I assume is a 12-16 bit ADC), that would be about 500 byte if 16bit uint or 1k if you have to use float.

 

And then say is't linear between those two points you measure between.

 

perhaps you need double amount of points but it still beat your first code. (perhaps you can even avoid float) 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You seem to be completely missing the point.  If you want to have very high accuracy, you absolutely cannot get some values from a table and enter them in ANY equation.  The tables contain only rough (uncalibrated) estimates, certainly not anywhere near 0.05 deg

Now that might change if you buy a $$$$ sensor that arrived along with a lab-cal measured  certificate with data for THAT sensor.

 

You MUST measure the actual sensor to get the values to put in your curve finding equation, so you can then predict other temperatures just as accurately as the calibrated temperatures.

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Mathematically it is working in range of +-0.0999.

Hardware i am checking .

 

LUT takes lot of memory though, I tried on -20 to 100C. Storing resistance values itself takes more memory than what what polynomial function taking at the moment. Since i dont have limitation on processing time, leaving LUT for time being, I have limited memory.

Or LUT can be optimized further?    This is 121 values, each values is 4 bytes of resistance so means 484 bytes itself while my polynmial codes takes only 455 with all the processing.  Then will have to implement interploation also which includes division also. 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

avrcandies wrote:
You seem to be completely missing the point.

Not just missing it - persistently refusing to even look at it!

 

"There are none so blind as those that will not see"

 

frown

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

while my polynmial codes takes only 455

I guess that is without about 2k of float lib?

 

But what is your input? (is the format integer or float).

Do you handle all the same sensors as the same, or do you plan on a calibration?
What else does the chip do ? 

Last Edited: Thu. Jul 9, 2020 - 11:39 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well, I did my own fit using the center column from the data supplied and obtained

A = 0.00063384

B = 0.000224404719441095

C = 0.00000008990646509653

 

Error is ±0.065 ºC so it's possible to get better parameters for the Steinhart–Hart equation than you have, you just need to use more points.

 

But of course this is all just an academic exercise; as avrcandies mentioned several times, to actually get this accuracy each thermistor would need to be calibrated individually.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

each thermistor would need to be calibrated individually.

And that can be a tough job...say you want a result accurate within 0.1 C.... so say you cal (really, try to cal) using measurements to 0.05 C.   However, temperature gradients are everywhere, so this can be quite a challenge. You have a stirred oil bath, or maybe some large block of aluminum where the thermistors are both buried next to each other deep within the block...and then you must wait a long time for the temperatures to even out & stabilize.  You'll have a nice day.

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Vindhyachal Takniki wrote:
Or LUT can be optimized further?    This is 121 values

In my post #10 I suggested a short LUT of only 46 entries. This was based on my own thermistor code where I used variable steps in temperature.

 

You could try making a LUT with entries in fixed 2°C or even 3°C steps. This could be just 60 or 40 entries taking 240 or 160 bytes respectively.

 

At the expense of complicating the code but gaining even more space saving; you could store ohms as (ohms/16) into uint16_t integers. You will only have a maximum 8 ohms of error, but even at 100°C (6911 ohm) that is only 0.1%, i.e. far less then the 2% of the thermistor.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

At the expense of complicating the code but gaining even more space saving; you could store ohms as (ohms/16) into uint16_t integers. You will only have a maximum 8 ohms of error, but even at 100°C (6911 ohm) that is only 0.1%, i.e. far less then the 2% of the thermistor.

The hard part by far, is accurately measuring to get the numbers to put into the lookup table. 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Some years back, I found Zunzun.com very useful for deriving equations that described certain relationships. Right now, the site seems to be inaccessible, however.

 

Four legs good, two legs bad, three legs stable.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

My thermistor equation works ok mathematically. Now I want to fit equation for thermopile. PFA its datasheet, excel data points and text file(which is tab separated values for areas of interest around 38301 values).

 

In text file: We are able to measure :

a) Thermopile mV (column 3)

b) NTC temperature(column 2)

c) Need to find object temperature from above two variables.

 

So need to make equation: Z= F(x,y)

We asked the company manufacturer for equation here is what they have replied: "The table is built in 25 degree C. The others are generated via mathematical formula which is confidential."

So need to make equation on own.

 

Page 6 of pdf has a formula, but it doesn't fit the formula given. If we put Vtp, Tobj & Ta , K values are always different for any given data set.

 

 

I made the equation: its third order equation contains 10 coefficients with x & y powers. 

Had to divide entire thermopile range into 13 parts like : -50 to 7C , 7C to 58C and so on upto 700C.  Each of these 13 sets have different 3 order coefficients to fit, within error range of +-0.09999. 

 

This is purely mathematical model required here, anyone has idea on what is there any equation which fits as manufacturer mentions but didnt disclose. 

 

 

 

 

 

 

 

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The table means nothing for you; you are given the thermopile equation #3

 

Using the thermistor voltage, you know the thermistor (ambient) temperature   

Call the result Z..this will require a thermistor calibration of some sort to get an accurate ambient temperature...how to do that is a chore & you can throw some curve at it. 

But you will need to physically measure it to end up with an accurate  ambient temperature

 

Make sure everything in in Kelvins, where needed.

 

Then The object temperature is :

K = S*k*e  , which is a calibration constant, which depends on a lot of physical parameters. Your best bet is to start with this equation.

If you know ambient very accurately (which you must) & don't get a good object temperature over all temperatures, then you can tweak K slightly as a function of Z.  But do that after you first test things out, keeping K fixed.

Rather then trying to take the 4th root (or square root twice), you can scan or successive approx object temperatures, say 30,31,32, 33...and raise them to the 4th (easier), homing in on the temperature that closest matches the inner quantity.

 

To summarize:

  • Calibrate thermistor, get measured (calibrated) ambient Z, over all ambient temperatures  ...just this task is hard! Start simple (like within 1 or 2 deg)!!
  • Using calibrated Z, find K to get Tobj from a known object, like a 400 deg hotplate 
  • You need to plot Tobj(meas) vs Tobj(actual)..Only if Tobj, differs too much at other temperatures, calibrate K(Z)
  • Alternatively, you may find only a very slight tweak is needed and may perform an easier correction Tobj(Z) 

 

I found a paper, with some other info...and I noticed they do some calc, using a similar equation to the one I gave, they compute Tobj, using an iterative method, maybe like  Newtons-Rhapson root finding.

https://www.melexis.com/-/media/...

 

Rather than using the two-step method, you could try a 2-dimensional nonlinear interpolation...not really recommended (No, I will not answer any questions!)

http://s2is.org/Issues/v9/n2/papers/paper13.pdf

 

This should keep you busy for a while!

 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Sun. Jul 19, 2020 - 08:45 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


This formula doesn't exactly fit in dataset given.

 

For example:

1. If I take set no 1 from text file

Tobj = -50+273.15K

NTC = 0+ 273.15K

Vtp = -2.90303987541749/1000 volts

values of K comes out to be K : 9.40360645303949000000E-13

 

2. If I take set no 61 from text file

Tobj = -49+273.15K

NTC = 9+ 273.15K

Vtp = -3.5222018314122336/1000 volts

values of K comes out to be K : 9.23698403345936000000E-13

 

 

2. If I take set no 8053 from text file

Tobj = 107+273.15K

NTC = 45+ 273.15K

Vtp = 8.260617415613451/1000 volts

values of K comes out to be K : 7.76451812140848000000E-13

 

 

Similarly I tried plotting graph of K calculated from all 38301 values given: this is what I get for first 32000 values graph(excel limitation)

 

As seen value of K keeps on falling for given dataset.

I have attached excel also on which I had calculated K values.

 

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Those falling to zero are actually diviide by zero error, where Tobj & Tamb equals each other.

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Vindhyachal Takniki wrote:
Each of these 13 sets have different 3 order coefficients to fit, within error range of +-0.09999. 

For the Infra-red measurement you are perhaps a bit misguided. You are NOT going to achieve anything like 0.1°C  level of accuracy outside of reference level lab equipment.

 

I have a Fluke VT-04 Thermal Imager it's only 2% accurate. Also a gun type spot thermometer, accuracy is 1% in common with the majority in it's class.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

NTC = 45+ 273.15K

How did you calibrate your NTC?...how did you know its exact temperature?

 

The formula presented is an exact rearrangement of the formula given in the datasheet.

 

How accurate are your Vtp readings?  What if they are 1 mv off?    saying you read -0.00290303987541749 V from a voltmeter you built sounds suspicious.

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Mon. Jul 20, 2020 - 04:49 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

these values/dataset are given by manufacturer. 

As in post #24, we asked manufacturer what is mathematical equation for this they replied:   "The table is built in 25 degree C. The others are generated via mathematical formula which is confidential."

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

Yes, you will see the K values form a sloped line:

 

K= Vthermopile/( Tobj^4 -Tamb^4)

 

Here are some K values I found, using the table values...In a perfect world, the K values would be the same everywhere.

 

In the real world, the Thermistor & thermopile temperatures drift apart (unless the device is heavily insulated) as the package temperature heats up the difference between them goes up.

This Vthermopile  can be corrected (linearized) by forming an offset from the thermopile voltage, that cancels the K line slope and offset:

Voffset= x+y(Tthermistor -298.15)      ...you have to determine x & Y  

 

So you use (Vthermopile-Voffset)  instead of Vthermopile in any calc    ....that should then help to get a steady K value.  Note that Voffset varies as Thermistor does, so Vos is not a fixed number.

 

The object temperature is derivable using Equation 2:

TO = (TS4 + VTP /A)1/4

This formula is valid for a sensor in a well-insulated package, typically a metal can, with inert gas or even vacuum inside, which causes the predominant heat transfer to happen through IR radiation. In the smallest versions of the IR sensors, such as the TMP006 that is in a wafer-level chip-scale package (WCSP), the sensor and the absorber membrane are directly exposed to ambient environment. This makes the sensor more sensitive to conduction and convection, which are the other two heat transfer mechanisms, versus radiative heat transfer. The resulting effect is the sensor's thermopile voltage drift as a function of the sensor die temperature. A total of three coefficients are used to compensate for this voltage drift, as per Equation 3:

VOS = b0 + b1(TS â€“ TREF) + b2(TS â€“ TREF)2

In Equation 3 above, VOS is the offset voltage when TO and TS are equal (for example, the object and the sensor have the same temperature), and TREF is room temperature (+25°C or +298°K). This offset is calculated and subtracted from the thermopile voltage at every measurement point, and the resulting voltage for the object temperature calculation is given by Equation 4:

f{VO} = (VTP â€“ VOS) + c2(VTP â€“ VOS)2

The coefficient c2 accounts for the deviation from the ideal Stefan-Boltzmann model due to the limited spectral range of real sensors and provides a second order compensation. The formula for the object temperature calculation then becomes as in Equation 5:

TO = (TS4 + f{VO}/A)1/4

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Tue. Jul 21, 2020 - 06:23 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

In this  https://www.fierceelectronics.com/components/demystifying-thermopile-ir-temp-sensors  , I had read what the role of separate Tref? 

This mentions:

1. Vtp = A(To^4 - Ts^4)

where To : object tempearure

Ts: sensor die tempearture as per link 

 

but we are using Ta= thermistor tempearture here

 

I think I am making mistake of direly converting into object temperature using Vtp & Tthermistor

 

2. In thermocouple where cold junction compensation is done, this is how it is:

a) Get CJ tempearture

b) Convert CJ temperature into mV by lookup-table or equation

c) Add mV(from 2) , to measured thermocouple milivolt

d) Now convert this combined millivilts to celsius by reverse loop up table

 

 

I am missing something here.

 

 

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

trying to fit as you have suggested for this Voffset= x+y(Tthermistor -298.15)      ...you have to determine x & Y  

 

 

I am using this type of sensor, so they are insulated ?

Thermopile and Infrared Temperature Sensors | TE Connectivity

Last Edited: Tue. Jul 21, 2020 - 12:30 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have connected fixed resistance in place of NTC connection, I measure stable reading, similarly fixed 0.5mV given at thermopile ADC connection, I read it correctly.

So that means I read correct NTC and thermopile mV when sensor is correct

 

But when I connect this sensor, I am not able to get some formula right where i can get right object temperature. Means something wrong with my formula. 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I found this thread really interesting, although I dont know anything about thermisters.  It sounds like a theorist arguing with an experimentalist.  From the outside, though, being a theorist by training and an experimentalist in retirement, I have to agree that doing your own calibration at known temperatures is the only way to get the accuracy you want that you can believe.  And it won't be easy.  Calibration is always way more subtle that expected.  Just my two 0.00001 cents worth.  Now I shall butt out forever.  

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Vindhyachal Takniki wrote:

1. Vtp = A(To^4 - Ts^4)

...

I think I am making mistake of direly converting into object temperature using Vtp & Tthermistor

Not really - that's exactly what that equation says; BUT this deceptively simple equation only arises due to major assumptions about how perfect the sensor, filters and optics actually are. To get a decent level of accuracy as in my #28 examples, you MUST do some corrections on a per-sensor (batch) or even per-instrument basis.

 

Provide some more detail about your test lab setup. We cant guess what tests you are doing or how you're performing them.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

I am pleased to deliver the solution you are looking for:

https://cdn.shopify.com/s/files/1/0672/9409/files/analog-digital-thermopile-application-note.pdf?v=1591982661

 

It gives very specific step-by-step procedures...read the entire document before proceeding, I think it will be worth your whil.e

The steps hows how to calculate all the parameters.  The document also covers some other method, like a 2 dimensional table interpolation.

 

 

 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Wed. Jul 22, 2020 - 02:27 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


Hi @avrcandies,

I had this file. The issue is here , as in page 9  , it assumes NTC is stable 25C at object temperature 100C.  But in our sensor NTC temperature also varies with change in object temperature. 

But if we keep fixed 100K instead of NTC, then I always measure perfect reading. That means our adc measurement channel is ok, thermistor is actually varying. 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


 

I am trying to get values by formula given in pdf

Page 10 have this:

 

How come this comes?

TCF = 1+[5*-0.0045/K] = 0.9775 it should be ?

Delta is differene, should be same either in celsius or kelvin.  or I am doing mistake in basic math?

 

Edit: I am using this sensor with this spces:

 

Last Edited: Wed. Jul 22, 2020 - 11:22 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Vindhyachal Takniki wrote:

 

7. Error with polynomial fit is +0.069 to -0.098C.
 Error with natural log is slightly more though.

 

8. Any other better method to implement or curve fit this data? Max end function accuracy I am looking is +-0.099C.

 

PS: In function call, I got coefficients generated in float64_t in curve fit toolbox, put f in the end though. 

 

 

 

 

 

 

 

IHMO, you are expecting WAY too much accuracy from a thermistor. Can you use something like the LM35?

 

You would be able to ditch the linearization code too...

 

 

Gentlemen may prefer Blondes, but Real Men prefer Redheads!

Last Edited: Thu. Jul 23, 2020 - 05:13 AM