User Tools

Site Tools



Temperature Sensor

There are many uses for devices that sense temperature. Refrigerators, heaters, air conditioners, automobiles, etc.. all make use of devices that sense temperature.

There are several different kinds of temperatures sensors. There are PT100, NTC, and PTC thermistors, and other chip-type sensors such as the DS1620.

We will take a look at the NTC thermistor and interface it with the Cubloc. The NTC thermistor is a temperature-sensitive resistor. Depending on the temperature, the value of resistance will change. By reading the value of this resistance, we can determine the temperature.

A common NTC thermistor resembles a diode. With this thermistor, we can sense temperatures between -30 and 250 degrees Celsius.

You can acquire an R-T (Resistance – Temperature) conversion table from the maker of the thermistor. The following is a diode-type 10Kohm NTC thermistor R-T conversion chart and table.

For connecting the sensor to the Cubloc, please refer to the following circuit diagram. To protect against voltage surges, a zener diode is recommended, especially if the thermistor is attached to a long probe wire.

As you can see in the circuit diagram, we will be using an ADC (Analog-toDigital) converter to read the voltage across the sensor. The A/D converter will convert the voltage into a value between 0 and 1024.

The most important part of this application note is the following table which converts the temperature and voltage to an A/D value between 0 and 1024. (Only some of the temperatures are shown.)

Const Device = cb280
Const Integer TH_TABLE = (992,990,989,987,985,983,981,979,977,975,
Dim a As Integer,b As Integer
    b = Tadin(0)
    If b > 990 Or b < 400 Then
        Debug "Out of Range" 'Check short or open th.
    End If
    For a=0 To 100
        If b > TH_TABLE(a) Then Exit For
    Debug Dec a,cr
    Delay 500

By using the TADIn command for AD conversion, the Cubloc will automatically calculate the average of 10 A/D conversion reads for more precise results. The sample program shown here will be able to sense between 0 and 100 degrees. A minor modification to the code would allow a larger temperature range.

The formula for acquiring the A/D conversion value from the R-T table is as follows:

THR is the resistance value. 1000 is for a 1K Ohm resistor and 5 is for 5 volts. The 10 bit A/D converter of the Cubloc will return a value between 0 and 1024. Therefore, to get the A/D value, you must multiply the result, V, by 204.8. A chart can be made by plotting this formula in a spreadsheet.

cubloc/temperature_sensor/index.txt · Last modified: 2016/04/14 11:07 (external edit)