Monday, January 10th, 2011

Digital thermometer with PIC12c671 Microcontroller

Development of Digital Thermometer:-
In this experiemnt we will learn how to develop a digital thermometer using microcontroller PIC 12c671.
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 PIC12c671 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 PIC16F688 microcontroller to derive the equivalent temperature value in digital format.
components of Digital Thermometer are as listed below.
Temperature sensor LM35
Microcontroller PIC12c671
seven segment LED digits 2NO
serial in parallel out shift register 74hc4094
circuit diagram
Digital thermometer with PIC12c671 MicrocontrollerTheory of Digital thermometer:-The LM35 series of temperature sensors are produced by National Semiconductor Corporation and are rated to operate over a -55 °C to 150°F temperature range. These sensors do not require any external calibration and the  output voltage is proportional to the temperature. The scale factor for temperature to voltage conversion is 10 mV per °C. The PIC12c671 have four analog to digital converter with 8-bit resolution. so we have 256 different pattern for the voltages range from 0v to 5v.so we have 20mv/bit as 5000/256.To have correct temperature we have to multiply the adc reading with a factor of 19.6 or roughly speaking 2.0 to avoid floating point calculation.Code of Digital thermometer:-Code of the digital thermometer is written in HI-TECH C Compiler for PIC10/12/16 MCUs (Lite Mode) V9.80.c language program for digital thermometer is given below.#include
unsigned char decod[10]={0xc0,0xF9,0xA4,0xB0,0×99,0×92,0×83,0xF8,0×80,0×98};
void delays(unsigned int d)
{
unsigned int j;
for(j=0;j<8;j++)
{
if(c<<(7-i)&0×01){GP1 = 1;}
else {GP1 = 0;}
delays(1);
GP2=1;
}
GP4=1;GP4=0;
}
unsigned char ReadADC(void)
{
unsigned char temp;
CHS1=0; //– Select Channel 0
CHS0=0;
ADON=1; //– Turn the ADC on
CLRWDT(); //– Clear the Watch Dog to allow time to convert b4 reset
GODONE=1; //– Start the Conversion
while(GODONE); //– Wait for Conversion to complete

temp=(ADRES)*2; //– Calculate the Range

return(temp);
}
void main (void)
{
unsigned char temperature,digit1,digit2;
CLRWDT();
OPTION=0x3F;
TRIS=0×01;
GPIO=0×00;

GPPU=1; //– Disable pull ups – all pins that would use it don’t need it!
CLRWDT();
ADCON1=0b00000110; //– GPIO.0 is the only Analog Input by Default
ADCON0=0b00000001; //– Fastest sample rate – Turn ADC ON
CLRWDT();
INTCON=0×00;
// T0IE=1;
// GIE=1;
GP4=1;
while(1){
CLRWDT();
temperature=ReadADC();//get the running temperature
if(temperature >=99)temperature = 99;// limit the reading to 99 for two digits
digit1=decod[temperature/10];//divide the temperature into two digits tenth place first and then unit place
digit2=decod[temperature%10];
put(digit2);put(digit1);
delays(20000);
}
}