Professional Documents
Culture Documents
html
Temperature controller using Microchip PIC16F877A
Microcontroller
In continuously monitoring the surrounding temperature of industrial applications Temperature Monitoring
Control System play vital role. A simple prototype of such system has been designed. The system uses the
temperature sensor LM35, PIC16F877A microcontroller and level converter IC MAX232. The controller
reads the temperature sensor data and after calibration the temperature is displayed in the HyperTerminal.
If temperature falls bellow 30C then the system should switch OFF LED.
If temperature is in between 30C to 40C then the LED should BLINK. Blinking rate can
be chosen appropriately.
The sensor data as well as the temperature should be displayed on HyperTerminal of the
computer for every 0.5seconds.
/*
void send_data(unsigned char *p,unsigned char no_of_bytes)
{ unsigned char i;
for(i=0;i
{
while(!TXIF) {} //if transmission buffer is full wait
TXREG=*(p+i); //send character to serial port
}
}
*/
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Calibration
We know PIC16F877A ADC has 10-bit resolution. Thus for 0V we get count zero and for 5V we
get count 1024. Hence for our application each bit represents 5/1024=4.9x10-3 mV/C. But LM35 has a
resolution of 10mV/C. Therefore each bit of ADC represents (4.9x10-3)/10x10-3 =0.49V/C. Thus to get the
exact value of temperature the ADC value has to be multiplied by 0.49. Since multiplication of this
floating-point number consumes enormous memory area and also adds overhead of inefficient calculation
we can approximate it to 0.5=1/2. Hence 2 in the program divide ADC value. This makes program more
efficient, simpler with less program memory area.
Software Improvements
Improvements are possible to the prototype software given here. These improvements are
necessary to convert the prototype into commercial product.
Accuracy
To get more accurate results we have to average the ADC value that has been not done in given
program. A jump in ADC and hence in temperature value may be seen due to this. But this requires more
program memory, RAM and also little more complex logic.