thermostat with relay outputs

Thread Starter

kavindu.balasuriya

Joined Mar 4, 2011
5
thermostat with relay
Hi All,
I am new to PIC programming. I programme a thermostat using LM35. Now I want to update it with a relay which have a adjustable setpoint. I mean If I need a relay output at 25 C I can adjust it so.
IF I need it at 23C It should be at there.
I have RC2 & RC3 as input (push buttons) and RC5 as output in 16F876A in my hardwere.
This is my code for thermostat.

PLS............... Help me........


/************************************************** ************
THERMOMETER WITH LM35 & LCD DISPLAY
====================================



Date: July 2011
File: LM35.C
************************************************** ************/
//
// Start of MAIN Program. Configure LCD and A/D converter
//
void main()
{
unsigned long Vin,tmp;
char * ch ="00.0";
TRISB = 0; // PORTB are outputs (LCD)
TRISA = 0xFF; // PORTA is input
//
// Configure LCD
//
Lcd_Init(&PORTB); // LCD is connected to PORTB
Lcd_Cmd(LCD_CLEAR);
Lcd_Cmd(LCD_CURSOR_OFF);
Lcd_Out(1,3,"THERMO METER");
Delay_ms(500); // delay
ADCON1 = 0x80; // Use AN0 and Vref=+5V
//
//
// Program loop
//
for(;;) // Endless loop
{

Lcd_Cmd(LCD_CURSOR_OFF);
Vin = Adc_Read(0); //read ADC(0)
tmp = Vin/2 ;
ch[0] = (tmp / 10 + 48) ; //Calculate fractional part
ch[1] = (tmp % 10 + 48) ;
Lcd_Chr(2,11,223);
Lcd_Chr(2,12,'C');
Lcd_out(2,7,ch);
Delay_ms(500); // Wait 1 second
}
}
 

thavinator

Joined Jul 4, 2011
20
You failed to tell us what sort of help you're looking for. Does the code not compile? Does it compile but fail to work as you expect? Be specific and it's far easier to get help. Also, when posting code to the forums, you should wrap it in CODE tags (see the little # button in the editing window), makes it easier to read.

That aside, it looks like your program doesn't do anything with the pushbuttons, so are you looking for help incorporating them into the program? If that's the case, check out on of the many PIC tutorials out there, like this one: http://www.gooligum.com.au/tutorials/baseline/PIC_Base_C_1.pdf (section on switch debouncing starts on page 25)
 

Thread Starter

kavindu.balasuriya

Joined Mar 4, 2011
5
my code is compile. But I need it to be updated adding adjustable output.I mean It show the temparature but not the relay output. Thank you very much for your reply.
 
Top