Channels ▼

Al Williams

Dr. Dobb's Bloggers

Is It Hot in Here?

November 18, 2013

Winter doesn't come very often to costal Texas, but it's a bit cooler lately and the days are certainly shorter. Last time I talked about sensing the presence of an object using a variety of sensors. Since I'm thinking about temperature this week, it is only fair to talk about common temperature sensors.

Common temperature sensors include semi-mechanical, thermistors, Resistance Temperature Detectors (RTDs), and thermocouples. There are also temperature sensors that take advantage of the change in the band gap of silicon with temperature.

The mechanical sensors are usually a bimetallic coil (that is, a coil made of two dissimilar metals). The metals will have different thermal coefficients and, thus, will expand and contract at different rates. This makes the coil get looser or tighter depending on the temperature. Old-fashioned thermostats use this principle, letting the coil make or break contacts to turn a heating element on and off. As you might guess, this becomes an object detection problem and you can use any of the methods mentioned last time. Of course, it seems silly to detect a bimetallic coil with a SONAR sensor, but microswitches are common in this application.

Two very common methods employ thermistors: resistors made of a metal oxide, and RTDs — resistors made with a platinum film. Thermistors are inexpensive and you can find them NTC (negative temperature coefficient) or PTC (positive temperature coefficient). That's just a fancy way of saying the resistance goes down as it gets warmer (NTC) or the resistance goes up (PTC).

Other than cost, there are a few other differences between thermistors and RTDs. RTDs have exceptional temperature range (the exact range will drive the cost) and are practically linear over most of their range (that is, a plot of the temperature vs. resistance is a straight line). Thermistors are usually more rugged, but they are decidedly non-linear, so converting their resistance value to a temperature is a bit harder.

There are lots of ways you can read a resistance. Most commonly, you make it part of a voltage divider and measure the voltage with an analog to digital (A/D) converter. This requires some excitation voltage and another resistor. You can also pair a resistor with a capacitor to produce a pulse and measure the time width of the pulse. That may take some external circuitry, or you can use a microcontroller I/O pin to do the job.

If you want to use the I/O pin route, you first make the pin an output and drive it low. That will discharge the capacitor. After you allow enough time for a complete discharge, you switch the pin to an input. The resistive device is connected to voltage and the capacitor charges (in a non-linear way). Eventually, the input pin will see a voltage high enough to record a logic one. By timing the amount of time the input pin stays low, you can get a relative idea of the time it takes the capacitor to charge, and thus the value of the resistance.

Thermocouples are very common in certain applications (although they are being overtaken by RTDs). A thermocouple capitalizes on the Seebeck effect — two junctions of dissimilar metal connected together will generate current when there is a temperature difference between them. (By the way, the opposite effect — the Peltier effect — says that if you put current through the junctions you will create a temperature difference and that's how portable refrigerators and some CPU coolers operate.)

Thermocouples generate a very little bit of noisy voltage for most temperatures (typically 1 to 70 microvolts per degree C). In addition, they only measure a difference in temperature, so you need a reference temperature for the "cold" junction. You could stick the cold junction in a bucket of ice, but that's not very practical. Instead, you usually use a special circuit to simulate a known reference temperature. In truth, because measuring thermocouples requires many special techniques, it is common to buy thermocouple amplifiers that do all the hard work (for example, the AD595 from Analog).

There are different types of thermocouples, known by letter designations (like type K or type T). These indicate the two different metals used, which determines the temperature range and output voltages.

Finally, integrated temperature sensors make use of the value of the silicon bandgap voltage. If you ever took a basic circuits class, you probably learned that a diode (or the base-emitter junction of a bipolar transistor) drops "about 0.6 or 0.7 volts." That's true at room temperature. In fact, the real value is a complicated expression involving the temperature, the charge on an electron, and Boltzmann's constant. The upshot, for our purposes, is the voltage changes with temperature (2 millivolts per degree Kelvin) and can be measured. Most often, you'd make this type of measurement with a special-purpose IC like an LM34, which outputs a simple voltage that easily relates to temperature.

Getting a rough idea of temperature is not hard at all. Precision measurements take special care. Keep in mind that putting current through a resistor causes the resistor to heat up! If two different kinds of wires connect together, they make a thermocouple (even if you didn't want one). Even PCB layout can affect the accuracy of temperature measurements. High accuracy resistance readings can be made with a four-wire method, for example. You can limit self-heating by using low currents. In general, if you need a very precise temperature measurement, you are better off buying an integrated sensor with the accuracy you need and getting the expertise of the manufacturer.

Of course, like anything else, you can find oddball ways to measure temperature. For example, Microchip has an example of measuring how long a watch dog timer reset takes using a higher-precision crystal oscillator. Because the watch dog uses a resistor/capacitor oscillator, it is temperature sensitive and by measuring the time it takes to reset, you can estimate the temperature! Of course, that's really a variation on the resistor/capacitor method I mentioned, but with an unintended thermistor.

Have you ever measured temperature in an odd way? Leave a comment with your best (or worst) story while you are braving the winter temperatures.

Related Reading

More Insights

Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.