5 December 2009
Author: Giorgos LazaridisExperimenting with a thermistor
Recently i won a bid for a batch of 10K thermistors. The only thing that i knew when i got them in my hand, was that those things are 10K thermistors. As far as i know, the 10K nominal resistance is at room temperature (25°C). But i had to find out if these are PTC or NTC, and also i had to draw their resistance to temperature characteristic line, otherwise they would be useless to me. So i ran some experiments with them...
A thermistor is actually a part that changes its resistance with the temperature change. There are namely 2 types of thermistors, the NTC and the PTC. The 'T' and 'C' stands for "Temperature" and "Coefficient". The "P" stands for "Positive" and "N" for "Negative". So, a NTC will decrease its resistance while the temperature rises, and a PTC will do the opposite.
Also, there are linear and non-linear thermistors. The old thermistors were uusually non-linear. This means that the resistance does not change linear to the temperature. That was a headache for taking measurements and the labs developed very linear sensors that are widely used nowadays. Every sensor should have a temperature to resistance characteristic diagram. But what i got was only a batch of sensors and nothing more.
What i had to find out was the type of the thermistors (PTC or NTC), and the resistance to temperature change characteristic.
For this, i will use a PIC microcontroller. I chose the 16F1937 because... i had it already mounted on a breadboard. Actually, any other PIC with analog to digital conversion capability would do just fine. Then i connected a DS1621 temperature sensor. These sensors have an outstanding measuring accuracy.
Then i used a 10K resistor to create a voltage divider with the thermistor. According to the standard specifications of thermistors, when it is in room temperature (25°C) it should have its nominal resistance, which in my case it is 10K. So, the output of the voltage divider should be 2.5 Volts. The PIC will measure this analog value. It then will get a binary 8-bit number from 0 to 255, representing this voltage.
The idea is to get as much measurements as possible for different temperatures. The more the measurements, the higher the accuracy. But this is not all. To have an overall image of the characteristic of the thermistor, i need to have a wide range of temperatures. The wider the temperature range, the better the accuracy of the characteristic. This is not easy though. I had to find a way to measure from very low temperatures (as low as 0°C) to high temperatures up to 50 °C. I do not really have device to do this, so i had to find different ways.
First of all the external ambient temperature. Today we had temperatures from 17.5°C up to about 22°C. This is a nice way to start. Then i used a thermal gun to increase gradually the temperature up to 50°C. My thermal gun has an electronic adjustment. I hang it over the circuit at about half a meter away and let it run with different setting every time. With this way, i had a batch of nice stable measurement up to 50°C.
The hardest part was the lower temperatures. the only thing available in my house that could work was the refrigerator. And this is exactly what i did. I put the circuit in the refrigerator while in operation. Every one hour i opened the door and quickly note the readings on the display. Then i slightly changed the setting of the refrigerator and repeated this process. It did work!
Every time i got a measurement, i noted the decimal value of the voltage divider that the PIC had measured with the ADC, and the actual temperature that the PIC got from the DS1621. I came up with the following table:
I draw then a Cartesian system. The vertical axis had the temperature (in ° Celsius) and the horizontal had the decimal ADC values from the PIC. To get a first idea of the thermistor that i had, i put all the points corresponding to the above measurements on this system. This is what i got:
Surprisingly, all points seems to belong on one straight line! What this means is that the thermistors i got are linear, at least for the temperatures that i measured. This was a great relief for me and the projects that will follow!
But which is this line really? What is the slope of change? The mathematicians have already given us the tools to get this answer, and this tool is called "The Least Squares" method. Using this method, i can calculate two points from where the best-to-fit line crosses. The least squares method may not be so complicated, but is a long sheet of calculations that i will not explain in this article. Instead, i give you the X,Y pairs of the two points.
To learn more about this method, you can visit this page: The Least Squares Fitting
If you are too tired to calculate it yourself, i have create Least Squares calculator
Also, i have create The Line Equation for you
X1 = 0, Y1 = 62.07
X2 = 50, Y2 = 190.33
And using the above two points, i draw the optimum line:
First of all, i need to have the temperature to resistance characteristic expressed with mathematics, so that i can further use it with my micro controller. The general formula of this line for further calculations is:
Y = a*X + b, where a=2.57 and b=62.07
What is also obvious is that, as the temperature rises, the ADC counter gives bigger numbers, and this means that it measures bigger voltages. The PIC gets this voltage from the Thermistor-resistor junction. The other lead of the thermistor is connected to the +5V, while the other lead of the resistor to the 0V. This is the voltage divider connection. To measure bigger voltages, this means that the resistance of the thermistor is reduced. So, the thermistor that i have is a NTC because its resistance is reduced while the temperature rises.
Finally, although it is not a high accuracy sensor, it gave me some very nice results. The maximum error that i got was 2°C in two measurements. But this error was an addition of the thermistor measuring error PLUS the DS1621 measurement error PLUS the absolute error of measurements during the experiment PLUS the resistance change of the metal film resistor due to temperature changes. A common precision sensor such as these, is usually given with 5% resistor tolerance.
The final test was to integrate the Y = a*X + b [=> X = (Y - b)/a] in the PIC program from which i would calculate the temperature from the ADC value of the NTC sensor. When i did this, i was rather astonished from the results. The temperatures from 16°C to 24°C was measured from the NTC with an unexpected accuracy. The difference from the DS1621 measurements was from 0.5°C to 1°C. Above 24°C this difference was from 0.5°C up to 2.5°C, but that is normal for this cheap thermistor.
Here is an interesting circuit that i used this thermistor to make a thermometer:Low Cost PIC Thermometer
And another circuit, again with this NTC thermistor:PIC Thermometer and Thermostat