Maths with exponents

I need to "reverse" a formula for a temperature sensor that involves an exponential:

R = 1000 x EXP(3800/T)-(3800/298)

R is in ohms, T is in kelvin

as taken from the chart of calculated resistances for each temperature. Now I'm not brilliant at maths but first i have to invert the formula so that I know T from R and before that deduce the resistance from the voltage provide by a voltage divider consisting of the sensor resistance (variable) and a fixed resistor. Can the arduino libraries do exponents and the inverse of exponents ?

On the other hand what sort of function is that that comes from the voltage divider of one fixed value and one variable value ? could that invert the exponential nicely to make the scale linear ?

R = 1000 x EXP(3800/T)-(3800/298)

Looks wrong - perhaps you mean:

R = 1000 x (EXP(3800/T)-(3800/298))

?

Where does the 3800 value come from? - it seems to have the dimension of temperature (298 is clearly standard temperature in
Kelvin).

The inverse of exponentiation is natural logarithm, written ln(x), and in Arduino language written log(x) [ base 10 logs are
log10(x) ]

No idea where the 3800 comes from. It's a fixed value in a box on the spreadsheet that is called into the formula.

I'm looking at the effects of a resistor in series and can I "linearize" the response making life much simpler, ultimately perfectly liner is not a problem providing i tie the start and end points down as I'm only operating over a 20C range in this case.

I have found that a 2.8K resistor in series with the sensor will practically linearize the scale but the only problem is that the range for the ADC is now 0.2V so I'll have to see if I can set custom references in the program (UNO platform) to expand it a bit although that is still 58 digits over 20C so enough resolution

the only problem is that the range for the ADC is now 0.2V so I'll have to see if I can set custom references

Set analogReference to 1.1V internal?

would give you ~200 steps

The problem there is that I'm working from 4.4 to 4.6V so it is out of range for a 1.1V range with reference to 0V. If I can custom set the Vreff.- and Vreff.+ reference points i can expand my scale and make it more immune to noise (*goes to check libraries)

You can only set Vreff.+ on the UNO but i have another idea, If I swap the sensor and fixed resistor I'll get closer to 0V , the readings may not be what I want but doing 5-Vs I'd get back to where I'd been otherwise. I can also use the external reff then and get a full scale :slight_smile:

Theres more to this game than software, appropriate use of the component blocks can work wonders :grin:

I suspect that 3800 number is some kind of normalization of "colo(u)r temperature"

no idea, i guess it is just some value that is characteristic of the material the temperature sensor is made of (nothing to do with colour)

So what device is this, datasheet please - always provide a datasheet link, its guesswork otherwise.

I just have the attached spreadsheet for the sensor

Copy of THERM-CA-2.XLS (24.5 KB)

To invert the formula, see the picture T(R) attached.....

T(R) = 1/((log(R/1000)/3800)+(1/298)) // results in Kelvins

P.S. - in Arduino log(X) = ln(x)

3800 = B25/100 = "temperature coefficient"

source: Measuring the temperature with NTCs

R(T).gif

T(R).gif

NTC - 10K.pdf (18.9 KB)

Images embedded for our convenience:

R(T).gif

T(R).gif

Technique described here.

R = 1000 x EXP(3800/T)-(3800/298)

R + (3800/298) = 1000 x EXP(3800/T)

(R + (3800/298))/1000 = EXP(3800/T)

log((R + (3800/298))/1000) = 3800/T

38000 * log((R + (3800/298))/1000) = 1/T

1/(38000 * log((R + (3800/298))/1000)) = T

Be sure that log and exp use the same base - 10, or base e (natural log).

Having said that, this formula looks pretty whack.