Wednesday, 22 March 2017

OVERHEAT LED INDICATOR SYSTEM USING LM35 (TEMPERATURE SENSOR)

Overheat LED Indicator System Using LM35 (temperature sensor)


GROUP MEMBERS EMSA:  Quek Yao Jing (01DIS15F1032)

                            Ng Yung Meeng (01DIS15F1027)

                            Nur Munirah binti Zahari (01DIS15F1001)

                            Siti Aishah binti Sahaludin (01DIS15F1011)


Introduction

Our project based on a PIC16F877A microcontroller and an LM35 temperature sensor. LM35 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 ADC channel inputs of the PIC16F877A microcontroller to derive the equivalent temperature value in digital format. The computed temperature will indicate the glow of whether RED or GREEN LED, in measurement of °C.


Synopsis

11)      List of hardware, software and components

           Hardware :

i)                    Lm35
ii)                  PIC16F877A
iii)                1 red LED
iv)                1 green LED


Software :

                 i)            MPLAB ver 8.85
                 ii)            Hi-Tech C compiler ver 9.83


22)      The Circuit diagram of this project


     Figure 1.1 : The Green LED Light on when temperature equal to or lower than 27°C




    
    Figure 1.2 : The RED LED Light on when temperature higher than 27°C


LM35 connection:
PIN 1: VDD
PIN 2: RA0/AN0
PIN 3: VSS/GND


LM35 temperature sensor converts temperature into its proportional analog voltage value. LM35 is three terminal devices. Pin number one and three are for 5-volt voltage supply. Pin two is analog voltage output with respect to temperature value. Relation between measured temperature and analog output voltage is:

                                                                  1°C = 10m volt

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.  PIC16F877A built in ADC (analog to digital converter) is used to measure analog voltage.  PIC16F877A PORTA have seven built in ADC channels. So one can interface up to seven sensors with this microcontroller very easily (In our project, we used RA0 channel). After reading ADC value, using voltage and temperature relationship voltage is converted back into temperature. A conversion factor is used to convert voltage back into temperature. All this conversion has been done through programming. A decision is being made when a specific temperature is achieved in order to determine which LED light should glow whether it’s a green or red LED. 

RC1 = GREEN LED
RC2 = RED LED




3)      Source Code :

#include <pic.h>

__CONFIG(0x3F32); // PIC16F77A Configuration Fuses
void delay(unsigned short i);
unsigned int adc_read(void);

union
{
                unsigned int i;
                unsigned char ch[2];
}adc;
void main ()
{
                ADRESH=0;
                ADRESL=0;
               
                TRISAbits.TRISA0 = 1; //set pin 0 at portA as input
                TRISC = 0b00000000;
                PORTC = 0;

                ADCON0 =0b10000001; //set ADC FOSC/32, channel 0 for input AN0, ADC on
                ADCON1 =0b10001110; //right justified for 10-bits, analog input for pin AN0-AN3
               
                while (1) //loop forever
                {
                                unsigned int ADC_value = 0;
                                unsigned int temp = 0;

                                ADON = 1;
                                ADC_value = adc_read(); //read analog inputs from sensor at channel 0
                                temp = (ADC_value/2);    //convert temp in Volt to Celcius

                                if (temp > 28)
                                {
                                                RC1 = 0;              //green
                                                RC2 = 1;                //red
                                }
                                else   //temperature lower than 28
                                {             
                                                RC1 = 1;                //green
                                                RC2 = 0;                //red
                                }
                                delay(250);
                }
}


unsigned int adc_read (void)
{
                GO = 1;                                               // Start Conversion, 1 cycles
                while(GO);                                          // wait for conversion complete
                NOP();
                adc.ch[0]             = ADRESL;
                adc.ch[1]             = ADRESH;
                return adc.i;
}

//---------------------- SUBROUTINE ---------------------
void delay(unsigned short i)
{
for(;i>0;i--);
}


4)      The video below showing the circuit connection and the               result of the project44







Conclusion

The actual motive toward this task is to test whether the temperature goes beyond 28 degree or less. If it is beyond, then the red LED will glow automatically, otherwise the green LED will stay remains to glow. Next, we also can learn more about ADC (analog-to-digital converter) is a system that converts an analog signal such as a sound picked up by a microphone or light entering a digital camera, into a digital signal. So in this particular situation, the heat detected by LM35 will be convert the analog signal to digital signal. Then the temperature is detected to the condition either it is more than 28 degree or less. If the heat detected more than 28 degrees, the digital signal return is 1(present) to red LED. Otherwise if it is 0(absent), the green LED remains glowing.
























No comments:

Post a Comment