BioBoard/Documentation/Temperature: Difference between revisions

From Noisebridge
Jump to navigation Jump to search
No edit summary
No edit summary
Line 66: Line 66:
Everybody needs to be convinced that your homemade instrument is reading what it should - it must be checked for calibration.  Most of us only have two easily accessible, well known, temperatures in the biological region of interest that we can produce - the melting point of ice (0°C) and the boiling point of water (100°C), at sea level - and these are good places to start.  It can be helpful to use another reference temperature measurement technique which has already been calibrated, such as a commercial digital thermometer, in case or thermocouple (plus a reader for it - I use a Fluke instrument with an adjustable offset in case there is any error at your reference temperatures).  This figure shows the results of a trial where I placed both the thermocouple and the thermistor in an ice+water bath (a double walled coffee mug) and recorded the Arduino output every 10 seconds - both instruments had an efective resolution of .1°C and we are looking at the ''noise'' at a fixed temperature.
Everybody needs to be convinced that your homemade instrument is reading what it should - it must be checked for calibration.  Most of us only have two easily accessible, well known, temperatures in the biological region of interest that we can produce - the melting point of ice (0°C) and the boiling point of water (100°C), at sea level - and these are good places to start.  It can be helpful to use another reference temperature measurement technique which has already been calibrated, such as a commercial digital thermometer, in case or thermocouple (plus a reader for it - I use a Fluke instrument with an adjustable offset in case there is any error at your reference temperatures).  This figure shows the results of a trial where I placed both the thermocouple and the thermistor in an ice+water bath (a double walled coffee mug) and recorded the Arduino output every 10 seconds - both instruments had an efective resolution of .1°C and we are looking at the ''noise'' at a fixed temperature.


It is not uncommon to see a peak-to-peak noise level of 3 times the resolution, and that is about what the experiment shows for both the thermistor and thermocouple.  Note that for this experiment the Arduino output seems to be linear with the calculated temperature, and this what we expect for relatively small changes in temperature - if we are monitoring experiments where the temperature does not change much we can simplify the mathematical relationship between resistance and temperature, avoiding the calculation hassles of the Steinhart-Hart equation.  The offset of ~1.3°C between the "Arduino temperature" and the expected value of 0°C is hard to explain for now (the reference thermocouple does only a little better than this unless the 0°C offset voltage is very carefully tweaked), and if you need improved accuracy you might have to take extra-ordinary measures.  Remember that for thermocouple measurements, the literature indicates that we can expect up to about 1°C error due to instrument on-board cold junction compensation errors
It is not uncommon to see a peak-to-peak noise level of 3 times the resolution, and that is about what the experiment shows for both the thermistor and thermocouple.  Note that for this experiment the Arduino output seems to be linear with the calculated temperature, and this what we expect for relatively small changes in temperature - if we are monitoring experiments where the temperature does not change much we can simplify the mathematical relationship between resistance and temperature, avoiding the calculation hassles of the Steinhart-Hart equation.  The offset of ~1.3°C between the "Arduino temperature" and the expected value of 0°C -(the reference thermocouple does only a little better than this unless the 0°C offset voltage is very carefully tweaked - and remember that the literature indicates that we can expect up to about 1°C error due to instrument on-board cold junction compensation errors) - is likely because this particular thermistor only has a room temperature resistance tolerance of +/-5%.  If measuring and then using the offset is  not what you wish to do, you might have to buy one with a better tolerance and generally take extra-ordinary measures. 


If we need to investigate the calibration over a narrower range we can play tricks like add ice to hot water and watch the temperature on both our Arduino output and our reference thermometer slowly drift up/down together - to see how your DIY measurements compare with the calibrated ones.
If we need to investigate the calibration over a narrower range we can play tricks like add ice to hot water and watch the temperature on both our Arduino output and our reference thermometer slowly drift up/down together - to see how your DIY measurements compare with the calibrated ones.
Line 76: Line 76:
=Links=
=Links=
more than enough for now - list will be trimmed before publication!
more than enough for now - list will be trimmed before publication!
[http://en.wikipedia.org/wiki/Thermistor]    thermistor description - suggested for beginners
[http://en.wikipedia.org/wiki/Thermistor]    thermistor description - suggested for beginners
[http://www.specsensors.com/ntc-engineering.asp]    general thermistor reference
[http://www.specsensors.com/ntc-engineering.asp]    general thermistor reference

Revision as of 13:09, 2 May 2011

Introduction to temperature measurements

We are all familiar with the classic simple analog thermometer - the one with the resevoir of mercury or alcohol at the bottom. Unfortunately it is not very easy to convert the (optical) readings from this into a digital format so that we can datalog the information from our experiments. But with the Arduino we can take an analog electrical signal and turn it into a digital one that we can use. We have a number of choices so we need to choose the best ones for the BioBoard, where we'll be doing measurements on biological systems so the temperature range is generally the same as the one for liquid water. We want inexpensive, readily available, sensors that are easy to implement with the Arduino - and have the appropriate range, precision, and accuracy.

Some of the basic types of electronic temperature sensors include:

  • thermocouple - excellent for very wide temperature ranges, up to 2300°C
  • resistance temperature detector (RTD) - used up to 600°C, for industrial application
  • thermistor - generally limited to <150°C, but inexpensive
  • digital temperature sensor (DTS) - the output is linearly proportional to the temperature

The thermocouple may be seem to be the most versatile - the individual sensors can be quite inexpensive (but to make your own can mean buying enough materials for many probes) and the range large - but the millivolt output requires an amplifier (~$18) to make them compatible with the Arduino, and they have a greater range than we need. RTDs are becoming increasingly common for some applications but require a bridge circuit, and are not as inexpensive or commonly available as we would like. We chose to focus on both the thermistor and the DTS because they cover the temperature range of choice well, they are inexpensive, and they can be implemented on the Arduino easily - you get two choices, just in case you have a preference, or one is more easily available than the other. The photo shows the 2 sensors that we interfaced, but note that the digital one also comes in a smaller surface mount configuration, and thermistors can be as small as a grain of sand.

Building a thermometer

Is this the place where we describe the whole waterproof probe construction - aspects besides the basic sensor?

You can add or remove sections as you find appropriate - the initial structure was meant as a guide, nothing more. -Rikke

Digital thermometer

What you need

How to build it

Things to keep in mind

Thermistor

A thermistor is a type of resistor which has a very well known dependence of the resistance on temperature, and the change is quite steep so that we can resolve small differences in temperature. We are using them in place of traditional thermometers, and so they are sometimes referred to a "resistance thermometers" - they are inexpensive, easy to find, and are very easy to interface to the Arduino. They are specified mainly by their room temperature (25°C) resistance and a common value is 10 kOhms. If many models are available, like from a major electronics supply house, you can also specify the tolerance and you can choose from different shapes and sizes (the size of a match head is good for starters). As well, there are two general types of thermistors - ones that increase in resistance with increasing temperature (PTC) and those that decrease in temperature with increasing temperature (NTC).

What you need

Besides your thermistor, all you need for the circuit is a "standard" resistor with a value that is the same as the room temperature resistance of your thermistor. You'll be using the standard one to build a "resistive divider" so that you can use the 5 VDC output of the Arduino and have good resolution over the full temperature range of the thermistor (usually something like -40°C to +125°C, perfect for biological experiments). For our examples we'll be using a 10Ωk NTC thermistor (Sparkfun and Hacktronics carry these) with a 10kΩ resistor for the bridge.

How to build it

On a breadboard build your simple resistive divider circuit, which looks like this: File:Http://www.flickr.com/photos/zen traveler/5678557159/in/set-72157616067782936/ Since your temperature probe will be exposed to moisture or liquid water, it is best to encase it in a waterproof sheath - a good way to do it might be to place it in a plastic tube and seal both the thermistor end and the wires coming out the far end with silicone aquarium sealant. Leave the tip of the thermistor exposed, so that you will have a good response time.

Things to keep in mind

R1 is the thermistor in the circuit, so your standard resistor (R2) is the one tied to the Arduino ground. When you buy the thermistor and matching resistor, buy ones with tight tolerances so that you don't have to worry about small errors in the temperature introduced by values which are off the stated values; and you might measure the actual values with a good digital multimeter, just to make sure.

Interfacing and measuring

Remember that the Arduino has a digital output with 10 bit (1024) resolution so for the special case where R1 is the same as R2 (that's our situation at room temperature) the voltage will be half of the Arduino's 5 VDC, so we can expect the digital output to be 1024/2 or 512. The code looks like this:

double Thermistor(int RawADC) {
double Temp;
float resistance = (10240000/RawADC) - 10000;    //calculate from voltage divider, for 10k resistor
Temp = log(resistance/10000);
// calculate the temperature, in K, using 4 thermistor model/material specific parameters A, B, C, D
// here we use the values for the Sparkfun/Hacktronics version of the Vishay 10k NTC thermistor (from datasheet)
Temp = 1 / (0.003354016 + 0.0002569850 * Temp + 0.000002620131 * Temp * Temp + 0.00000006383091 * Temp * Temp * Temp);
Temp = Temp - 273.15;            // Convert Kelvin to Celsius
// Temp = (Temp * 9.0)/ 5.0 + 32.0; // Convert Celsius to Fahrenheit
return Temp;
}

and the math part is the Steinhart-Hart equation, which is the relationship between the resistance and the temperature for a thermistor with certain materials properties (see here for a description). On the manufacturer's datasheet for your specific resistor you will find a list of 4 materials constants - usually referred to as A, B, C, and D - that go with it. The most general equation is:

1/T= A + B*ln(R/Rt) + C*ln(R/Rt)2 + D*ln(R/Rt)3

but check which one is appropriate for the material constants on your datasheet (the one above is the right one for Vishay thermistors).

Calibrating a home-built thermometer

Everybody needs to be convinced that your homemade instrument is reading what it should - it must be checked for calibration. Most of us only have two easily accessible, well known, temperatures in the biological region of interest that we can produce - the melting point of ice (0°C) and the boiling point of water (100°C), at sea level - and these are good places to start. It can be helpful to use another reference temperature measurement technique which has already been calibrated, such as a commercial digital thermometer, in case or thermocouple (plus a reader for it - I use a Fluke instrument with an adjustable offset in case there is any error at your reference temperatures). This figure shows the results of a trial where I placed both the thermocouple and the thermistor in an ice+water bath (a double walled coffee mug) and recorded the Arduino output every 10 seconds - both instruments had an efective resolution of .1°C and we are looking at the noise at a fixed temperature.

It is not uncommon to see a peak-to-peak noise level of 3 times the resolution, and that is about what the experiment shows for both the thermistor and thermocouple. Note that for this experiment the Arduino output seems to be linear with the calculated temperature, and this what we expect for relatively small changes in temperature - if we are monitoring experiments where the temperature does not change much we can simplify the mathematical relationship between resistance and temperature, avoiding the calculation hassles of the Steinhart-Hart equation. The offset of ~1.3°C between the "Arduino temperature" and the expected value of 0°C -(the reference thermocouple does only a little better than this unless the 0°C offset voltage is very carefully tweaked - and remember that the literature indicates that we can expect up to about 1°C error due to instrument on-board cold junction compensation errors) - is likely because this particular thermistor only has a room temperature resistance tolerance of +/-5%. If measuring and then using the offset is not what you wish to do, you might have to buy one with a better tolerance and generally take extra-ordinary measures.

If we need to investigate the calibration over a narrower range we can play tricks like add ice to hot water and watch the temperature on both our Arduino output and our reference thermometer slowly drift up/down together - to see how your DIY measurements compare with the calibrated ones.

Making it cooler

The acrylic tube we used for waterproofing the sensors is a little on the large size - you can customize your specific raw sensor so that it is encapsulated differently and suits your application more closely.

Geeking out

If you want to hack just a little more then you might choose to use a thermistor that you find out in the world, using obtainium can be particularly satisfying - such as from a BBQ probe or other similar digital thermometer. These will have a to-be-determined room temperature (25°C) resistance and materials constants, so you will need to measure the resistance at at least 3 different temperatures (some people ignore the "C" constant, so 3 might be enough) and solve the multiple equations to get the constant values. Luckily, websites exist to help you with this process.

Links

more than enough for now - list will be trimmed before publication!

[1] thermistor description - suggested for beginners [2] general thermistor reference [3] description of the Steinhart-Hart equation, for thermistors [4] assorted online calculators for thermistors [5] datasheet for the Maxim DS18B20 digital thermometer