Microcontroller › PIC › Help on Controlling Air Condition using LM35 interfacing to PIC microcontroller
- This topic has 3 replies, 2 voices, and was last updated 10 years, 4 months ago by AJISH ALFRED.
-
AuthorPosts
-
October 19, 2013 at 8:31 pm #2693Akanbi IbrahimParticipant
Hi everybody,i am working on a project which i have to switch ON and OFF Air Condition whenever the temperature of the room is above or below certain temperature respectively.I have done my breadboard design and the temperature is displaying properly but the automatic switch ON and OFF is not working as expected instead it will not allow the temperature to go below or beyond my minimum and maxmum temperature respectively.below is my code in MikroC
sbit LCD_RS at RC4_bit;sbit LCD_EN at RC5_bit;sbit LCD_D4 at RC0_bit;sbit LCD_D5 at RC1_bit;sbit LCD_D6 at RC2_bit;sbit LCD_D7 at RC3_bit;sbit LCD_RS_Direction at TRISC4_bit;sbit LCD_EN_Direction at TRISC5_bit;sbit LCD_D4_Direction at TRISC0_bit;sbit LCD_D5_Direction at TRISC1_bit;sbit LCD_D6_Direction at TRISC2_bit;sbit LCD_D7_Direction at TRISC3_bit;// End LCD module connections// Define Messageschar message0[] = “AC Monitoring”;char message1[] = “Room Temperature”;// String array to store temperature value to displaychar *tempC = “000.0”;char *tempF = “000.0”;// Variables to store temperature valuesunsigned int tempinF, tempinC,orgtemp;unsigned long temp_value,maxtemp;void Display_Temperature() {// convert Temp to charactersif (tempinC/10000)// 48 is the decimal character code value for displaying 0 on LCDtempC[0] = tempinC/10000 + 48;else tempC[0] = ‘ ‘;tempC[1] = (tempinC/1000)%10 + 48; // Extract tens digittempC[2] = (tempinC/100)%10 + 48; // Extract ones digit// convert temp_fraction to characterstempC[4] = (tempinC/10)%10 + 48; // Extract tens digit// print temperature on LCDLcd_Out(2, 1, tempC);if (tempinF/10000)tempF[0] = tempinF/10000 + 48;else tempF[0] = ‘ ‘;tempF[1] = (tempinF/1000)%10 + 48; // Extract tens digittempF[2] = (tempinF/100)%10 + 48;tempF[4] = (tempinF/10)%10 + 48;// print temperature on LCDLcd_Out(2, 10, tempF);}void main(){TRISE=1;TRISB=0;PORTE=1;TRISD=0;PORTD=0;// ANSEL = 0b00000100; // RA2/AN2 is analog inputADCON0 = 0b01001000; // Connect AN2 to S/H, select Vref=1.19V// CMCON0 = 0x07 ; // Disbale comparatorsTRISC = 0b00000000; // PORTC All OutputsTRISA = 0b00001110; // PORTA All Outputs, Except RA3 and RA2Lcd_Init(); // Initialize LCDLcd_Cmd(_LCD_CLEAR); // CLEAR displayLcd_Cmd(_LCD_CURSOR_OFF); // Cursor offLcd_Out(1,1,message0);Delay_ms(1000);Lcd_Out(1,1,message1); // Write message1 in 1st row// Print degree characterLcd_Chr(2,6,223);Lcd_Chr(2,15,223);// Different LCD displays have different char code for degree symbol// if you see greek alpha letter try typing 178 instead of 223Lcd_Chr(2,7,’C’);Lcd_Chr(2,16,’F’);while(1){temp_value = ADC_Read(2);temp_value = temp_value*4882;tempinC = temp_value/1000;tempinC = tempinC*10;tempinF = 9*tempinC/5 + 3200;}}//~ End of main FunctionOctober 21, 2013 at 5:02 am #10538AJISH ALFREDParticipantHi Akanbi,
Air conditioners already have automatic temperature control. It will try to keep the temperature of a room constant, and I guess that is why your project is not working. Please find a way to confirm it first.
November 6, 2013 at 12:47 pm #10577Akanbi IbrahimParticipantThanks Mr Aljish,but i tried to test this with a LED to see if the temperature is beyond the normal limit i set the LED will ON instead its prevents the temperature that is displaying on the LCD to reach the limit i set.
November 7, 2013 at 5:04 am #10578AJISH ALFREDParticipantHi Akanbi,
Check whether your circuit is proper. Make sure that you’ve connected the ADC reference pin of the microcontroller to 5V
-
AuthorPosts
- You must be logged in to reply to this topic.