Thursday, December 12, 2013

Interfacing LM35 with AT89s52

   Today, we are going to interface LM35 temperature sensor with AT89s52 microcontroller. As most of all already know that AT89s52 is a microcontroller from 8051 microcontroller family and it has no any feature of internally built analog to digital converter and since LM35 being an anlog sensor, we will require a suitable means of converting the analog signal obtained from LM35 to a discrete time signal. So, by now you must have already known that interfacing LM35 requires knowledge of interfacing analog to digital converter with AT89s52. If you donot have knowledge on interfacing analog to digital converter with AT89s52, you are recommended to read this post Interfacing ADC with AT89s52 first.


Pin layout of LM35.
fig a:- bottom view of  LM35
    Now, we will be moving towards the pin description of LM35 along with some tips of using it.The pin layout on LM35 is shown below in fig a. It has three pins which are supply (+5 V ) , output and ground. The output of this temperature sensor is analog in nature and need to be converted to digital form and this is done with the aid of analog to digital converter. In this case we will be using ADC0804 as an converter.The schematic for interfacing LM35 with AT89s52 is shown in figure b. As shown in figure the output of LM35 is connected to Vin(+) of ADC0804 Vin(-) is connected to GND and the data pins from ADC0804 i,e D0-D7 are connected to PORT of AT89s52. The reference voltage for conversion of analog output from LM35 to digital form is 2.56V. Thus, the voltage at Vref/2 of ADC should be adjusted to 1.28V which can be done using variable register as shown in figure b.

interfacing LM35 with at89s52
fig b:- interfacing LM35 
Now after assembling the components as shown in figure b in the circuit board, it is required to program the microcontroller to convert the analog signal to digital form and display it in the LCD. The procedure used to program to convert the analog signal to digital signal is the same which was used in previous post Interfacing ADC with AT89s52. After programming for conversion you need to write a code to convert the obtained digital value into decimal representation form which can be displayed in LCD.The source code in C along with proteus simulation file can be downloaded by clicking here.

You may also like:
Interfacing DS1820 (Digital temperature sensor) with 8051
Temperature based device control system using LM35

No comments: