Thermostat (temperature regulator)
Thermostat is used to read temperature and keep the the temperature near to a desired temperature of a room or any builds.
The thermostat keep temperature by heating or cooling systems, so if temperature is under desired the cooling start and when temperature is below desired the heathing system start.
Description:
The lm35 read temperature converted the analog signal and viewed in lcd with the low and high range of tmperature, if you want o change the range simply click on push-button of selection and increase or decrease it.
We have three parameters actual temperature, range desired with min and max values.
The thermostat keep temperature by heating or cooling systems, so if temperature is under desired the cooling start and when temperature is below desired the heathing system start.
Description:
The lm35 read temperature converted the analog signal and viewed in lcd with the low and high range of tmperature, if you want o change the range simply click on push-button of selection and increase or decrease it.
We have three parameters actual temperature, range desired with min and max values.
- If the temperature is in range the green led is on and the system do nothing.
- if temperature is under range the hathing system start with a electrical relay on and red led is on.
- if temperature is below cooling system start and shutt-off heathing and the yellow les id on.
Programme:
// --------------------------------AKIL Ayoub---------------------------------//
// ------------------------FS Ben Msik Master M.S.I---------------------------//
//--------------------------------2013/2014-----------------------------------//
// modules LCD connections
sbit LCD_RS at RB7_bit;
sbit LCD_EN at RB6_bit;
sbit LCD_D4 at RB5_bit;
sbit LCD_D5 at RB4_bit;
sbit LCD_D6 at RB3_bit;
sbit LCD_D7 at RB2_bit;
sbit LCD_RS_Direction at TRISB7_bit;
sbit LCD_EN_Direction at TRISB6_bit;
sbit LCD_D4_Direction at TRISB5_bit;
sbit LCD_D5_Direction at TRISB4_bit;
sbit LCD_D6_Direction at TRISB3_bit;
sbit LCD_D7_Direction at TRISB2_bit;
// Fin modules LCD connections
int t;
char a;
char lcd[]="000";
unsigned short tempMin=10;
unsigned short tempMax=30;
unsigned short ky=1;
char txt[3];
char tft[3];
char tct[3];
char tbt[3];
char tkt[3];
char tdt[3];
char tet[3];
void interrupt()
{
INTCON.INTF=0;
if(ky<4)ky++;
else ky=1;
}
void main()
{
ADCON1 = 0x04;
Lcd_Init();
Lcd_Cmd(_LCD_CURSOR_OFF);
OPTION_REG.INTEDG = 1;
INTCON.GIE = 1;
INTCON.INTE = 1;
TRISC =0b00001100;
TRISB.F0=1;
do
{
t = ADC_Read(0);
t = t * 0.4887; // 4.887 est la resolution du convertisseur ADC
switch(ky)
{
case 1: // Mode 1
if(portC.F2==1){tempMax++;Delay_ms(500);}
if(portC.F3==1){tempMax--;Delay_ms(500);}
Lcd_out(1,1,"tempMin =");
Lcd_out(2,1,"tempMax ?");
ByteToStr(tempMin,txt);
Lcd_Out(1,10,txt);
ByteToStr(tempMax,tft);
Lcd_Out(2,10,tft);
break;
case 2: // Mode 2
if(portC.F2==1){tempMin++;Delay_ms(200);}
if(portC.F3==1){tempMin--;Delay_ms(200);}
Lcd_out(1,1,"tempMin ?");
Lcd_out(2,1,"tempMax =");
ByteToStr(tempMin,tct);
Lcd_Out(1,10,tct);
ByteToStr(tempMax,tbt);
Lcd_Out(2,10,tbt);
break;
case 3: //mode 3
Lcd_out(1,1,"Temp =");
IntToStr(t,tkt);
Lcd_Out(1,8,tkt);
Lcd_out(2,1,"SB =");
ByteToStr(tempMin,tdt);
Lcd_Out(2,5,tdt);
Lcd_out(2,9,"SH =");
ByteToStr(tempMax,tet);
Lcd_Out(2,13,tet);
break;
}
if(t<tempMin){
portC.F5=1;
portC.F6=0;
portC.F7=0;
portC.F4=1;
}
else if(t>tempMin && t<tempMax)
{
portC.F5=0;
portC.F6=1;
portC.F7=0;
portC.F4=0;
}
else if(t>tempMax){
portC.F5=0;
portC.F6=0;
portC.F7=1;
portC.F4=0;
}
else;
}while(1);
}
// --------------------------------AKIL Ayoub---------------------------------//
// ------------------------FS Ben Msik Master M.S.I---------------------------//
//--------------------------------2013/2014-----------------------------------//
// modules LCD connections
sbit LCD_RS at RB7_bit;
sbit LCD_EN at RB6_bit;
sbit LCD_D4 at RB5_bit;
sbit LCD_D5 at RB4_bit;
sbit LCD_D6 at RB3_bit;
sbit LCD_D7 at RB2_bit;
sbit LCD_RS_Direction at TRISB7_bit;
sbit LCD_EN_Direction at TRISB6_bit;
sbit LCD_D4_Direction at TRISB5_bit;
sbit LCD_D5_Direction at TRISB4_bit;
sbit LCD_D6_Direction at TRISB3_bit;
sbit LCD_D7_Direction at TRISB2_bit;
// Fin modules LCD connections
int t;
char a;
char lcd[]="000";
unsigned short tempMin=10;
unsigned short tempMax=30;
unsigned short ky=1;
char txt[3];
char tft[3];
char tct[3];
char tbt[3];
char tkt[3];
char tdt[3];
char tet[3];
void interrupt()
{
INTCON.INTF=0;
if(ky<4)ky++;
else ky=1;
}
void main()
{
ADCON1 = 0x04;
Lcd_Init();
Lcd_Cmd(_LCD_CURSOR_OFF);
OPTION_REG.INTEDG = 1;
INTCON.GIE = 1;
INTCON.INTE = 1;
TRISC =0b00001100;
TRISB.F0=1;
do
{
t = ADC_Read(0);
t = t * 0.4887; // 4.887 est la resolution du convertisseur ADC
switch(ky)
{
case 1: // Mode 1
if(portC.F2==1){tempMax++;Delay_ms(500);}
if(portC.F3==1){tempMax--;Delay_ms(500);}
Lcd_out(1,1,"tempMin =");
Lcd_out(2,1,"tempMax ?");
ByteToStr(tempMin,txt);
Lcd_Out(1,10,txt);
ByteToStr(tempMax,tft);
Lcd_Out(2,10,tft);
break;
case 2: // Mode 2
if(portC.F2==1){tempMin++;Delay_ms(200);}
if(portC.F3==1){tempMin--;Delay_ms(200);}
Lcd_out(1,1,"tempMin ?");
Lcd_out(2,1,"tempMax =");
ByteToStr(tempMin,tct);
Lcd_Out(1,10,tct);
ByteToStr(tempMax,tbt);
Lcd_Out(2,10,tbt);
break;
case 3: //mode 3
Lcd_out(1,1,"Temp =");
IntToStr(t,tkt);
Lcd_Out(1,8,tkt);
Lcd_out(2,1,"SB =");
ByteToStr(tempMin,tdt);
Lcd_Out(2,5,tdt);
Lcd_out(2,9,"SH =");
ByteToStr(tempMax,tet);
Lcd_Out(2,13,tet);
break;
}
if(t<tempMin){
portC.F5=1;
portC.F6=0;
portC.F7=0;
portC.F4=1;
}
else if(t>tempMin && t<tempMax)
{
portC.F5=0;
portC.F6=1;
portC.F7=0;
portC.F4=0;
}
else if(t>tempMax){
portC.F5=0;
portC.F6=0;
portC.F7=1;
portC.F4=0;
}
else;
}while(1);
}
You want to download it click on the link below