Quadratic equation to calculate a temperature from resistance

1k Views Asked by At

I'm trying to implement an electronic temperature sensor that gives a resistance value. The sensor is a Honeywell TD4.

In the datasheet, they give a table of values :

  • -40ºC => 1584Ω ±12Ω
  • -30ºC => 1649Ω ±11Ω
  • -20ºC => 1715Ω ±10Ω
  • -10ºC => 1784Ω ±9Ω
  • 0ºC => 1854Ω ±8Ω
  • +10ºC => 1926Ω ±6Ω
  • +20ºC => 2000Ω ±5Ω
  • +30ºC => 2076Ω ±6Ω
  • +40ºC => 2153Ω ±6Ω
  • +50ºC => 2233Ω ±7Ω
  • ... (up to 150ºC)

They give a quadratic equation for computing resistance given the temperature:

$$R_T = R_0 + (3.84×10^{-3}×R_0×T) + (4.94×10^{-6}×R_0×T^2)$$

  • where $R_T$ is the resistance at temperature R,
  • $R_0$, resistance at 0ºC and
  • T the temperature in ºC.

we now want to get this equation the other way around, i.e. having the temperature given the resistance: $$T = f(R_T)$$

As we wanted to reduce the equation to get only one $T$, we calculated the discriminant, so we get :

$$∆ = b^2-4ac = (3.84×10^{-3}×R_0)^2 -4×4.94×10^{-6}×R_0×R_0$$ $$∆ = (3.84×0.001×1854)×(3.84×0.001×1854)-(4×4.94×0.000001×1854×1854)$$ $$∆ = -17.236077350399988$$

It is negative, thus there is no real roots, only the complex ones...

But our problem is that we want to come with a formula up we can implement in a microcontroller to get the value with the best precision... But my mathematics skills from highschool are far behind (if I knew at that time that I would actually have to solve such an equation in the real world ;-)). I may be wrong in the way to extract $T$ from $R_T$'s formula. But then what could be the good way ?

While I don't have a solution, I'm implementing in the microcontroller a linear formula for each segment of the given table...

2

There are 2 best solutions below

3
On BEST ANSWER

It is not necessary to solve for the discriminant because the LHS is not zero. I recommend that you take the following approach.

EDIT to illustrate completion of the square

  1. Factor $R_0$ out of the RHS and move to the LHS as $R_T/R_0$. $$R_T/R_0 = 1 + (3.84×10^{-3}×T) + (4.94×10^{-6}×T^2)$$
  2. Complete the square on the RHS. $$R_T/R_0 = 1 - \frac{(3.84×10^{-3})^2}{4(4.94×10^{-6})}+ \frac{(3.84×10^{-3})^2}{4(4.94×10^{-6})}+ (3.84×10^{-3}×T) + (4.94×10^{-6}×T^2)$$
  3. Move the extra constant to the LHS. $$R_T/R_0 - 1 + \frac{(3.84×10^{-3})^2}{4(4.94×10^{-6})}= \frac{(3.84×10^{-3})^2}{4(4.94×10^{-6})}+ (3.84×10^{-3}×T) + (4.94×10^{-6}×T^2)$$ $$R_T/R_0 - 1 + \frac{(3.84×10^{-3})^2}{4(4.94×10^{-6})}= \left(\frac{3.84×10^{-3}}{2(4.94×10^{-6})^\frac{1}{2}} + (4.94×10^{-6})^\frac{1}{2}×T\right)^2$$
  4. Take the square root of each side (be careful about which branch you choose (i.e. +/-)). (This should get rid of the $T^2$ term.) $$\frac{3.84×10^{-3}}{2(4.94×10^{-6})^\frac{1}{2}} + (4.94×10^{-6})^\frac{1}{2}×T = \sqrt{R_T/R_0 - 1 + \frac{(3.84×10^{-3})^2}{4(4.94×10^{-6})}} $$
  5. Solve for $T$. $$ (4.94×10^{-6})^\frac{1}{2}×T = \sqrt{R_T/R_0 - 1 + \frac{(3.84×10^{-3})^2}{4(4.94×10^{-6})}} - \frac{3.84×10^{-3}}{2(4.94×10^{-6})^\frac{1}{2}} $$ $$T = \frac{1}{(4.94×10^{-6})^\frac{1}{2}}\left(\sqrt{R_T/R_0 - 1 + \frac{(3.84×10^{-3})^2}{4(4.94×10^{-6})}} - \frac{3.84×10^{-3}}{2(4.94×10^{-6})^\frac{1}{2}}\right) $$

Also note that $R_T/R_0 must be > 0.25376518218$ which appears to hold from your posted data.

7
On

One approach is to fit the data in the other sense. For the data you give, Excel gives $T=2\cdot 10^{-5}R^2+.232R-345.9$. The data looks quite linear over this span-would a straight line over the whole range be accurate enough for you?

Added: that fit seems to be polluted with roundoff error due to the high resistance values. If you use kohm instead it works very well. The fit (over the range -40 to +150) is $T=-16.941*R^2+201.93*R-316.55$, which is within 1 degree over the whole range.