CONTROL SYSTEM TEMPERATURE

ANALOGUE TO DIGITAL CONVERTER (ADC).

Analogue to digital converter is any device that can be used to change a physical parameter into an electrical parameter which is understood by the micro-controller. the ADC`s are referred to as actuators, mostly sensors.
They help to detect the changes in the environment then convert and send it to the MCU for necessary action.
For a full understanding of ADC, we shall be carrying out an experiment on temperature control system. Our aim is to regulate the temperature of a room. If the room temperature goes below 20`C a heating device should come on e.g a bulb and when it goes above 25`C a cooling device should come on e.g cooling fan. The actuator we are going to be usuing is LM35. It is temperature sensor that has a reading range value from (0`-1028`), a little mathematical has to be done so as to put our specified optimum and minimum temperature of the room.
Required components:
1. PIC16F877A.
2. LM35.
3. COLLING FAN.
4. LAMP.
5. CRYSTAL OSCILLATOR.
6. 10k & 220R RESISTOR.
Schematic:

Program:


int temp;
char display[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
void sevenseg(char n){
char i;
char ch[3];
char rem=n;
ch[0]=rem%10;
rem/=10;
ch[1]=rem%10;
rem/=10;
ch[2]=rem%10;
rem/=10;
for(i=0;i<100;i++){
portb=display[ch[2]];
portc=0xef;
delay_ms(15);
portc=0xff;
portb=display[ch[1]];
portc=0xdf;
delay_ms(15);
portc=0xff;
portb=display[ch[0]];
portc=0xbf;
delay_ms(15);
portc=0xff;
}
}
void main() {
trisb=0x00;
portb=0x00;
trisd=0x00;
portd=0x00;
trisc=0x00;
portc=0x00;
trisa=0xff;
adcon1=0x00;
while(1){
temp=adc_read(0);
temp=temp*100/204.5;
sevenseg(temp);
if(temp<20){
rd7_bit=1;
rd0_bit=0;
}
else if(temp>25){
rd7_bit=0;
rd0_bit=1;
}
}
}

 

Leave a Reply

Your email address will not be published. Required fields are marked *