Changes

Thermistor

1,388 bytes added, 19:30, 31 August 2011
Created page with "== Objective == How to read a NTC thermistor via ADC to get the current temperature. == Problem == * NTCs have a negative exponential behavior [1,2,3]. * When trying to read ..."
== Objective ==

How to read a NTC thermistor via ADC to get the current temperature.

== Problem ==

* NTCs have a negative exponential behavior [1,2,3].

* When trying to read with the ADC on an AVR, you somehow need to fit
the voltage into AVcc, for example using the internal reference at
2.56V.

== Solution ==

[2] suggests combining a resistor with the NTC in parallel to create
an approximate linear response for a given temperature range.

I decided to do the math first, and it turns out a voltage divider
works like a charm. Set the ADC reference voltage to 2.56V. Then wire
the divider up this way:

<pre>
5V ----------+
|
NTC 10k@25C
|
+----------o ADC
|
3.6k
|
__|__
___
-
</pre>

The 3.6k value can be calculated from [2] and a bit of
experimentation.

When you read the ADC (say, 8bit ADC), you'll have to post-process the
reading. BUT! It is already linear. That means we can easily compute T
(in degC):

T = (ADC - 40) >> 2;

Of course, you can decide not to shift and instead have .25 degC
resolution.

The resulting temperature reading can be seen in [4] (analysis).

[1] https://secure.wikimedia.org/wikipedia/en/wiki/Thermistor
[2] https://www.avx.com/docs/Catalogs/ntc-general.pdf
[3] http://imgur.com/6efmA.png
[4] http://imgur.com/YlRCY.png