A Digital temperature meter using an LM35 temperature sensor Introduction A digital thermometer is a good choice of project for beginners who just stepped in to the world of microcontrollers because it provides an opportunity to learn using sensors to measure the real world signals that are analog in nature. This article describes a similar project based on a PIC166!! microcontroller and an "#$% te mperature sensor. "#$% is an analog sensor that converts the surrounding temperature to a proportional analog voltage. The output from the sensor is connected to one of the A&C channel inputs of the PIC166!! microcontroller to derive the e'uivalent temperature value in digital format. The computed temperature is displayed in a 16() character "C&* in both +C and +scales. Theory The "#$% series of temperatur e sensors are produced by ,ational -emiconductor Corporation and are rated to operate over a %% +C to 1%/+C temperature range. These sensors do not re'uire any e0ternal calibration and the output voltage is proportional to the temperatur e. The scale factor for temperature to voltage conversion is 1/ mper +C. The "#$% series sensors come in di2erent pac3ages. The one I used is in a hermatic T456 transistor pac3age wher e the metal case is connected to the negative pin 7nd8. The meas urement of negative temperatur es below / +C8 r e'uires a negative voltage source. 9owever* this project does not use any negative voltage source* and therefore will demonstrate the use of sensor for measuring temperatures above /+C up to 1//+C8. The output v oltage fr om the sensor is converted to a 1/bit digital number using the internal A&C of the PIC166!!. -ince the voltage to be measured by the A&C ranges from / to 1./that corresponds to ma0imum temperature range* 1//
10
Embed
A Digital Temperature Meter Using an LM35 Temperature Sensor
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
7/24/2019 A Digital Temperature Meter Using an LM35 Temperature Sensor
A Digital temperature meter using an LM35 temperature
sensor
Introduction
A digital thermometer is a good choice of project for beginners who just steppedin to the world of microcontrollers because it provides an opportunity to learn
using sensors to measure the real world signals that are analog in nature. This
article describes a similar project based on a PIC166!! microcontroller and an
"#$% temperature sensor. "#$% is an analog sensor that converts the
surrounding temperature to a proportional analog voltage. The output from the
sensor is connected to one of the A&C channel inputs of the PIC166!!
microcontroller to derive the e'uivalent temperature value in digital format. The
computed temperature is displayed in a 16() character "C&* in both +C and +
scales.
Theory
The "#$% series of temperature sensors are produced by ,ational
-emiconductor Corporation and are rated to operate over a %% +C to 1%/+C
temperature range. These sensors do not re'uire any e0ternal calibration and
the output voltage is proportional to the temperature. The scale factor for
temperature to voltage conversion is 1/ m per +C. The "#$% series sensors
come in di2erent pac3ages. The one I used is in a hermatic T456 transistor
pac3age where the metal case is connected to the negative pin 7nd8.
The measurement of negative temperatures below /+C8 re'uires a negative
voltage source. 9owever* this project does not use any negative voltage source*
and therefore will demonstrate the use of sensor for measuring temperatures
above /+C up to 1//+C8.
The output voltage from the sensor is converted to a 1/bit digital number using
the internal A&C of the PIC166!!. -ince the voltage to be measured by the A&Cranges from / to 1./ that corresponds to ma0imum temperature range* 1//
7/24/2019 A Digital Temperature Meter Using an LM35 Temperature Sensor
+C8* the A&C re'uires a lower reference voltage instead of the supply voltage
dd : %8 for A;& conversion in order to get better accuracy. The lower reference
voltage can be provided using a <ener diode* a resistor networ3* or sometime
just simple diodes. =ou can derive an appro0imate 1.) reference voltage by
connecting two diodes and a resistor in series across the supply voltage* as
shown below. As a demonstration* I am going to use this circuit in this project. Imeasured the output voltage across the two diodes as 1.1>6 . The resistor ? I
used is of $.6@* but you can use 1@ too. The important thing is to measure the
voltage across the two diodes as accurate as possible.
e need do some math for A;& conversion. 4ur ref is 1.1>6 * and the A&C is
1/bit. -o* any input voltage from /1.1>6 will be mapped to a digital number
between /1/)$. The resolution of A&C is 1.1>6;1/)5 : /.//116! ;Count. Therefore* the digital output corresponding to any input voltage in :
in;/.//116!. ,ow* lets see how to get the temperature bac3 from this whole
process of converting sensorBs output to 1/bit digital number.
Assume* the surrounding temperature is )6.5 +C. The sensor output will be )65
m /.)65 8. The output of A&C will be /.)65;/.//116! : ))6. If we reverse this
process* we have ))6 from A&C and we can go bac3 and nd the temperature by
using the sensor scale factor 1/ m;+C8*
temperature : ))6 D /.//116! ;Count8 ; /./1 ;+C8 : )6.5 +C
If you want to avoid Eoating point math in your program* just use*
temperature : ))6 D 116! : )6$>6!
hile displaying this* you need to put a decimal at the fourth place from the left.
-o the calculated temperature is )6.$>6!+C* which is pretty close to the actual
one. The di2erence is caused by 'uantiFation and rounding errors. In this project*
we will display temperature accurate to one decimal place* i.e.* we will divide the
above number by 1/// to get )6$. -o the temperature will be displayed as )6.$
+C.
7/24/2019 A Digital Temperature Meter Using an LM35 Temperature Sensor
The accuracy of the temperature measurement highly depends upon the stability
of the reference voltage. If the reference voltage drifts from the value that we
considered in our calculation* the measured temperature value could be
signicantly o2 from the actual value. Lsing a simple dioderesistor networ3 for
deriving a reference voltage may not be a very good idea* but the purpose of this
project was to demonstrate the techni'ue* not to come up with a commercialdigital thermometer product. =ou can also try a <ener diode or a potentiometer
to derive the reference voltage. Mesides* the 'uantiFation error introduced by the
1/bit A&C* rounding numbers while doing the math* and the accuracy of the
sensor itself within the desired range of temperature also a2ect the
measurement output. ?ead the manufacturerBs datasheet for more details on the
performance of the "#$% series sensor.
pdate
This design has a little Eaw. It uses a voltage drop across two diodes X 1.) 8 asa reference voltage ref8 for A;& conversion. 9owever* the datasheet of
PIC166!! suggests to use ref greater than ).) to ensure 1"-M accuracy in
the A;& conversion. Therefore* I have rewritten this project but this time using a
#CP1%)% device for creating a precise ).% reference voltage. The new design is
more precise and accurate in ta3ing temperature measurements