On Mon, 22 May 2000 13:46:59 -0400, you wrote:
{Quote hidden}>Damon wrote:
>> I've got an A/D circuit on my 16F874.
>> I have a couple of OP Amps hooked to some resistors a few Pots and a
>> thermistor so that I get a 5X gain on the voltage. (schematic available
>> if needed)
>> I have it giving me 2.5V at room temp. But for the LIFE of me I can't
>> figure out how to convert the 0-1023 value into a usable temperature.
>> I have an Excel spreadsheet that will tell me the readout if I type in
>> the voltage example: 0v=0, 5V=1023, 2.5V=512, 2.813782991V=576
>>
>> From my chart that last Voltage should correspond to a reading of 68F
>> (20C)
>> Maybe it's late and it's really simple but I can't figure it out.. any
>> help out there?
>>
>>
> Well, using a thermistor, it's not exactly straightforward. The
>reason
>is the highly non-linear resistance to temperature characteristic of the
>thermistor. I have been working on something similar (in my copious
>spare time). This equation is from memory, i'll look it up tonight when
>I get home:
>
> T(Kelvin) = 1/(A + B*ln(R) + C*(ln(R)^3))
>
>This equation is the Steinhart-Hart equation. R is the resistance
>of the thermistor. A, B, and C are material constants that you can figure
>out by measuring the resistance at three different temperatures. The
>constants are all less than 1 for my particular thermistor.
>
>Now you can see the difficulty with this equation in a PIC. While the
>fractional values can be taken care of by scaling everything,
>calculating the natural log function is a bit more difficult. On top
>of that, the temperature (in Kelvin) is actually the inverse.
Use a lookup table - you can compensate for the thermistor
nonlinearity, and the nonlinearity of using a simple resistive divider
in one go. You can generate the table using the equation from the
thermistor databook data with a simple Basic/[insert your favorite
language] program, or probably Excel.
If you need a wide temperature range, use 2 switchable pullups to
improve linearity at the hot end, otherwise select the pullup/pulldown
to get a reasonable voltage swing over the range you're interested in.