Tuesday, November 19, 2019

Digital Thermometer (LM35 Sensor) using PIC16F877A Microcontroller



Objective:



LM35 is a precision IC temperature sensor with its output proportional to the temperature (in oC). The sensor circuitry is sealed and therefore it is not subjected to oxidation and other processes. With LM35, temperature can be measured more accurately than with a thermistor. It also possess low self heating and does not cause more than 0.1 oC temperature rise in still air. It is produced by National Semiconductor and can operate over a -55 °C to 150 °C temperature range. Its output is linearly proportional to Centigrade Temperature Scale and it output changes by 10 mV per °C


Pin Diagram:














Pin Description:





Components:

LM35 temperature sensor is used in theis project. It is cheapest in price and easily find it in market. Only 5 volt Power supply is required for LM35 and there is no need of extra circuitry to operate it. PIC16F877A Microcontroller is used to read temperature value. 16x2 LCD is used to display temperature value on LCD. A relay also control by the temperature range like less then 30C Relay is on and more then 30C Relay is off condition. Code ofthis project written in PIC Basic and Mikro C Pro Compiler. 

Implementation:

LM35 temperature sensor converts temperature into its proportional voltage value. Pin two is analog voltage output with respect to temperature value. Relation between measured temperature and analog output voltage is 1oC = 10m Volt .


  • here Vcc is 5Volt
  • ADC is 10bit so , resolution is 1023 
Hence for every 1 degree increase in temperature there will be a increment of 10m volt in output voltage of LM35 sensor. PIC16F877A microcontroller is used to measure analog voltage value by the step size is  = 5V/ 1023. PIC16F877A Microcontroller built in ADC  (analog to digital converter) is used to measure analog voltage. PIC16F877A PORTA have 8 input pin for ADC channels. so, one can interface up to eight sensors with this microcontroller very easily.


Circuit Diagram:










Basic Code:


Define CONF_WORD = 0x3f72

Define CLOCK_FREQUENCY = 12
AllDigital
Define LCD_BITS = 8
Define LCD_DREG = PORTD
Define LCD_DBIT = 0
Define LCD_RSREG = PORTE
Define LCD_RSBIT = 0
Define LCD_RWREG = PORTE
Define LCD_RWBIT = 1
Define LCD_EREG = PORTE
Define LCD_EBIT = 2
Define LCD_READ_BUSY_FLAG = 1
ADCON1 = 0x0e
Define ADC_CLOCK = 3
Define ADC_SAMPLEUS = 50
Lcdinit
Dim an0 As Word
Dim tem As Word
loop:
Adcin 0, an0
tem = an0 * (5000 / 1023)
tem = tem / 10
Lcdcmdout LcdClear
Lcdout "room temparature "
Lcdcmdout LcdLine2Home
Lcdout "tem =", #tem
WaitMs 500
If tem < 30 Then
PORTB.0 = 1
Else
PORTB.0 = 0
Endif
Goto loop





No comments:

Post a Comment