PT100 resistance to temperature - Page 1
Forum section: electronics / general

author: peter-h
author_rank: Super Contributor
timestamp: December 13, 2020, 11:53:55 am
content: I am looking for a formula for T in terms of R but all over the internet is the same old Callendar–Van Dusen equationRt = R0 * (1 + A* t + B*t2 + C*(t-100)* t3)(A is more typically 3.85 nowadays)For t > 0 (i.e. R > 100 ohms) there is a formulabut I can't find one for t < 0. I believe it has been done with a polynomial (curve fitting) but I can't find it.I came across thisT = -247.29 + 2.3992 R + .00063962 R2 + 1.0241E-6 R3but no idea whether it is accurate. I suppose one could plot it and check against one of the standard tables which are online.This articlehttps://en.wikipedia.org/wiki/Callendar%E2%80%93Van_Dusen_equationrefers to a 20th order polynomial but that standard is not freely available.Thishttps://techoverflow.net/2016/01/02/accurate-calculation-of-pt100pt1000-temperature-from-resistance/contains some references but again I can't find them.There is a complete formula here which claims to go below zerohttp://www.code10.info/index.php%3Foption%3Dcom_content%26view%3Darticle%26id%3D82:measuring-temperature-platinum-resistance-thermometers%26catid%3D60:temperature%26Itemid%3D83expressed as code but AFAICT this is just the quadratic fomula which holds true for T > 0 and they have therefore got it wrong.Basically I am after the formula behind this but can't see any way to reach itMuch appreciate any help.

author: Nominal Animal
author_rank: Super Contributor
timestamp: December 14, 2020, 03:48:38 am
content: The more precise polynomials are described in the ITS-90 equipment calibration standard (PDF, section 3.3 starting on page 7).It defines the sensor resistance $R$ at temperature \$T_{90}\$ as a ratio to the sensor resistance at the triple point of water, 273.16 K = 0.01°C: \$W_r(T_{90}) = R(T_{90}) / R(273.16 K)\$. It describes the actual measured ratio as \$W(T_{90})\$.For clarity, let's change to a different set of variables and definitions. We'll still use \$T\$ to describe temperatures (with \$T_0 = 273.16 K\$ the temperature of triple point of water), and \$R\$ to describe the sensor resistance (with \$R_0 = R(T_0)\$ being the sensor resistance at the triple point of water). This change will be useful, because the ITS-90 polynomials are relative (fractions compared to a fixed value), and unitless.Let \$t = T / T_0\$ be our unitless temperature, the fraction of the current temperature \$T\$ to the temperature at triple point of water \$T_0\$.Let \$r = R / R_0\$ be our unitless resistance, i.e. the fraction of the resistance compared to the resistance at triple point of water.ITS-90 equation 9a describes how resistance varies as a function of temperature, for temperatures below the triple point of water (specifically, \$13.8033 K \le T \le T_0\$, i.e. \$t \le 1\$). We can state it as$$\begin{aligned}L(t) &= A_0 + \sum_{n=1}^{12} A_n \left( 1 + \frac{2}{3} \log(t) \right)^n \\r(t) &= e^{L(t)} \\\end{aligned}$$where \$\log\$ represents natural logarithm of base \$e\$. The coefficients \$A_0\$ through \$A_{12}\$ are listed in the PDF table IV.Equation 10a describes how resistance varies as a function of temperature above the triple point of water (specifically, \$T_0 \le T \le 1234.93 K\$, i.e. \$t \ge 1\$):$$\begin{aligned}r(t) &= C_0 + \sum_{n=1}^{9} C_n \left( \frac{273.16 t - 754.15}{481}\right)^n \\~ &= C_0 + \sum_{n=1}^{9} C_n \left( 0.5679 t - 1.5678794 \right)^n \\\end{aligned}$$with the coefficients \$C_0\$ through \$C_9\$ in the PDF table IV also.The inverse ones are what we really are interested in.Equation 9b describes the temperature as a function of the resistance ratio for \$13.8033 K \le T \le T_0\$, i.e. when \$r \le 1\$:$$\begin{aligned}t(r) &= B_0 + \sum_{n=1}^{15} B_n \left( \frac{r^{1/6} - 0.65}{0.35} \right)^n \\~ &= B_0 + \sum_{n=1}^{15} B_n \left( 2.857142857 r^{1/6} - 1.857142857 \right)^n \\\end{aligned}$$which differs from its inverse by at most \$0.0001 K\$; and 10b for \$T_0 \le t \le 1234.93 K\$, i.e. when \$r \ge 1\$:$$\begin{aligned}273.16 t(r) - 273.15 &= D_0 + \sum_{n=1}^{9} D_n \left( \frac{r - 2.64}{1.64} \right)^n \\t(r) &= 0.999963391419 + 0.003660858105 \left[ D_0 + \sum_{n=1}^{9} D_n \left( 0.609756097561 r - 1.609756097561 \right)^n \right] \\\end{aligned}$$which differs from its inverse by at most \$0.00013 K\$. Coefficients \$B_0\$ through \$B_{15}\$ and \$D_0\$ through \$D_9\$ are in table IV in the PDF.The polynomials themselves aren't terribly interesting, because they are just an error minimizing polynomial fit to the calibration values, i.e. expected sensor resistances at specific known temperatures (like the triple point of water, which can be experimentally established more precisely than any "random" temperature, being based on some physical phenomena):$$\begin{array}{c|c|c}K & °C & r \\\hline13.8033 & -259.3467 & 0.00119007 \\24.5561 & -248.5939 & 0.00844974 \\54.3584 & -218.7916 & 0.09171804 \\83.8058 & -189.3442 & 0.21585975 \\234.3156 & -38.8344 & 0.84414211 \\273.16 & 0.01 & 1.00000000 \\302.9146 & 29.7646 & 1.11813889 \\429.7485 & 156.5985 & 1.60980185 \\505.078 & 231.928 & 1.89279768 \\692.677 & 419.527 & 2.56891730 \\933.473 & 660.323 & 3.37600860 \\1234.93 & 961.78 & 4.28642053 \\\end{array}$$Note that simple least squares fitting is unlikely to produce good results, because you want to minimize the maximum error (in temperature). That does not mean it is hard at all; you can certainly construct your own polynomials based on the above using free software like Octave and Maxima/wxMaxima (both available for all operating systems).I personally would probably use Python with SciPy or NumPy (former includes the latter), and do an iterative brute-force search in the coefficient space (probably gradient descent on maximum error), to optimize the coefficients. Especially if dealing with known ADC input range instead of \$r\$.

author: peter-h
author_rank: Super Contributor
timestamp: December 14, 2020, 07:48:21 pm
content: Thank you for that comprehensive reply. However, only a good mathematician would be able to take that furtherI did eventually find this great sitehttp://www.mosaic-industries.com/embedded-systems/microcontroller-projects/temperature-measurement/platinum-rtd-sensors/resistance-calibration-tablewhich presents a ready to use solution which is highly accurate and very quick to compute.

author: Nominal Animal
author_rank: Super Contributor
timestamp: December 16, 2020, 12:04:02 am
content: No, you don't need to be a mathematician; me, I'm a computational physicist, and definitely not a mathematician!A bit of Python andnumpy.polynomial.polynomial.Polynomial.fit()can do the heavy lifting. It supports a customizable weight function for the fit, so one can adjust how the least squares error is weighted. Or you can use even LibreOffice Calc or Excel, or Matlab or Octave, or any number of tools. One just needs to check the resulting polynomial as a curve, to ensure it is monotonically increasing (everywhere increasing, no flat regions or dips).For example, the following Python functionCode:def PT100(R):v = 31.64259588293078f = Rv += f * 2.327765488883832f *= Rv += f * 0.000825034783247256f *= Rv += f * 5.503555111531539e-07f *= Rv -= f * 8.846016370591097e-10f *= Rv += f * 2.79478040084237e-12return vreturns the temperature of a PT100 sensor in Kelvins, when given its resistance in Ohms, with less than 0.003 K of error between 234 K (-39°C) and 1235 K (962°C). I wrote the Python version, because it is trivial to port to any other programming language, and should be easy to understand. (Noting thatx += yis equivalent tox = x + y, as is usual in many programming languages.)The coefficients are an unweighted 5th degree least squares fit to the ITS-90 calibration points, omitting the four points below 100 K.I might at some point write some Python code for optimizing calculation of temperature with 32-bit fixed-point math for MAX31865 converters; that ought to come in handy. (I do have a few PT100 RTDs and MAX31865 converters, but no better temperature references than freezing and boiling water.)

author: peter-h
author_rank: Super Contributor
timestamp: December 16, 2020, 11:50:47 am
content: That's a cunningly simple way to do itI did wonder why one has the complexities when this is just a monotonic curve. How hard can it be?

author: snarkysparky
author_rank: Frequent Contributor
timestamp: December 16, 2020, 03:49:43 pm
content: octave way. I made several polynomials to cover the region i was interested in.Input is in A/D counts with a 12 bit converter and Vref = 3.3V And a 30K pullup for the thermistor.Code:B = 3950;R25 = 30*1000;Tc = [0:1:30]; % define region deg C for fitTcAbs = Tc + 273.15;R = R25*exp(B*(1./TcAbs - 1/(25 + 273.15)));Count = ((R ./(R + 30000))*3.3)*4096/3.3;[rw cl] = size(Tc);R1 = [(Count').^3 (Count').^2 (Count') ones(cl,1)];K = pinv(R1)*Tc'