Temperature Monitoring System using LM35 and PIC18f4580

Digital Fiber, Photoelectric, Laser Range, Optical, Temperature, Rotary Encoder, Ultrasonic, Gas, Gyro, Accelerometer, FlexiBend, Flexiforce, Compass......

Temperature Monitoring System using LM35 and PIC18f4580

Postby syamilshahrel » Fri May 30, 2014 9:35 am

Hi, i'm doing a project for my university study, and its about temperature monitoring. The background of my project is that i want to display the condition of the temperature. Example= if temperature is 10-30 C, the LCD wil display 'COLD WATER'. I think i've done what i can, yet when i run it in the proteus, no display on the LCD. Can anyone help me? i need help ASAP guys, thanx :D below is the code

CODE: SELECT_ALL_CODE
#pragma list P=P1884580
#pragma config OSC=HS
#pragma config WDT=OFF
#pragma config PWRT=ON
#pragma config DEBUG=ON,LVP=OFF

#include <P18F4580.h>
#define ldata PORTD
#define rs PORTCbits.RC0
#define rw PORTCbits.RC1
#define en PORTCbits.RC2


unsigned char L_byte, H_byte, Bin_temp;

unsigned char data0[]="Temp = 0~10";
unsigned char data1[]="Temp = 11~20";
unsigned char data2[]="Temp = 21~30";
unsigned char data3[]="Temp = 31~40";
unsigned char data4[]="Temp = 41~50";
unsigned char data5[]="Temp = 51~60";
unsigned char data6[]="Temp = 61~70";
unsigned char data7[]="Temp = 71~80";
unsigned char data8[]="Temp = 81~90";
unsigned char data9[]="Temp = 91~100";
unsigned char condition1[]="COLD WATER";
unsigned char condition2[]="COOL WATER";
unsigned char condition3[]="WARM WATER";
unsigned char condition4[]="HOT WATER";
unsigned char a;
unsigned char b;
unsigned char c;
unsigned char d;
unsigned char e;
unsigned char f;
unsigned char g;
unsigned char h;
unsigned char k;
unsigned char l;
unsigned char m;
unsigned char n;
unsigned char p;
unsigned char q;


void lcdcmd(unsigned char value);
void lcddata(unsigned char value);
void ADCset(void);
void Display (void);
void ADCset(void);
void MSDelay(unsigned int itime);
void delay(unsigned int itime);


void main ()
{
   ADCset();
   TRISD=0;
   TRISC=0;
   en=0;
   MSDelay(250);
   lcdcmd(0x38);
   MSDelay(250);
   lcdcmd(0x0E);
   MSDelay(15);
   lcdcmd(0x01);
   MSDelay(15);
   lcdcmd(0x06);
   MSDelay(15);
   lcdcmd(0x80);
   MSDelay(15);
   TEMP ();
   Display ();
   
   
}   
   


void TEMP(void)
{
   
   TRISD=0;
   TRISAbits.TRISA0=1;
   TRISAbits.TRISA2=1;
   ADCON0 = 0X81;
   ADCON1 = 0XC5;
   
   while(1)
     {
      MSDelay(1);
      ADCON0bits.GO = 1;
      while(ADCON0bits.DONE == 1)
      L_byte = ADRESL;
      H_byte = ADRESH;
      L_byte >>= 2;
      H_byte &= 0X3F;
      L_byte <<=6;
      H_byte &= 0xC0;
      Bin_temp = L_byte|H_byte;
      PORTD= Bin_temp;
     }
}
   

   
void lcdcmd(unsigned char value)
{
   ldata = value;
   rs=0;
   rw=0;
   en=1;
   MSDelay(1);
   en=0;
}
void lcddata(unsigned char value)
{
   ldata = value;
   rs=1;
   rw=0;
   en=1;
   MSDelay(1);
   en=0;
}

void ADCset(void)
{
   ADCON0=0X01;
   ADCON1=0X07;
   ADCON2=0XAA;
}



void Display (void)
{

   if(Bin_temp<2)
   {
      
      for(a=0;a<11;a++)
      {
         lcddata (data0[a]);
         MSDelay(15);
      }
   
      lcdcmd(0xC0);
      MSDelay(15);
   
      for(m=0;m<10;m++)
      {
         lcddata(condition1[m);
         MSDelay(15);
      }
       }
   else if(2<Bin_temp<4)
   {
      
      for(b=0;b<12;b++)
      {
         lcddata (data1[b]);
         MSDelay(15);
      }
   
      lcdcmd(0xC0);
      MSDelay(15);
   
      for(m=0;m<10;m++)
      {
         lcddata(condition1[m]);
         MSDelay(15);
      }
   }


   else if(4<Bin_temp<6)
   {
      
      for(c=0;c<12;c++)
      {
         lcddata (data2[d]);
         MSDelay(15);
      }
   
      lcdcmd(0xC0);
      MSDelay(15);
   
      for(n=0;n<10;n++)
      {
         lcddata(condition2[n]);
         MSDelay(15);
      }
   }

   else if (6<Bin_temp<8)
   {
      
      for(d=0;d<12;d++)
      {
         lcddata (data3[e]);
         MSDelay(15);
      }
   
      lcdcmd(0xC0);
      MSDelay(15);
   
      for(n=0;n<10;n++)
      {
         lcddata(condition2[n]);
         MSDelay(15);
      }
   }
   else if(8<Bin_temp<A)
   {
      
      for(e=0;e<12;e++)
      {
         lcddata (data4[f]);
         MSDelay(15);
      }
   
      lcdcmd(0xC0);
      MSDelay(15);
   
      for(n=0;n<10;n++)
      {
         lcddata(condition2[n]);
         MSDelay(15);
      }
   }

   else if(A<Bin_temp<C)
   {
      
      for(f=0;f<12;f++)
      {
         lcddata (data5[g]);
         MSDelay(15);
      }
   
      lcdcmd(0xC0);
      MSDelay(15);
   
      for(p=0;p<10;p++)
      {
         lcddata(condition3[p]);
         MSDelay(15);
      }
   }

   else if(C<Bin_temp<E)
   {
      
      for(g=0;g<12;g++)
      {
         lcddata (data6[h]);
         MSDelay(15);
      }
   
      lcdcmd(0xC0);
      MSDelay(15);
   
      for(p=0;p<10;p++)
      {
         lcddata(condition3[p]);
         MSDelay(15);
      }
   }

   else if(E<Bin_temp<10)
   {
      
      for(h=0;h<12;h++)
      {
         lcddata (data7[k]);
         MSDelay(15);
      }
   
      lcdcmd(0xC0);
      MSDelay(15);
   
      for(p=0;p<10;p++)
      {
         lcddata(condition3[p]);
         MSDelay(15);
      }
   }

   else if(10<Bin_temp<12)
   {
      
      for(k=0;k<12;k++)
      {
         lcddata (data8[l]);
         MSDelay(15);
      }
   
      lcdcmd(0xC0);
      MSDelay(15);l
   
      for(q=0;q<9;q++)
      {
         lcddata(condition4[q]);
         MSDelay(15);
      }
   }

   else(12<Bin_temp<14)
   {
      
      for(l=0;l<13;l++)
      {
         lcddata (data9[m]);
         MSDelay(15);
      }
   
      lcdcmd(0xC0);
      MSDelay(15);
   
      for(q=0;q<9;q++)
      {
         lcddata(condition4[q]);
         MSDelay(15);
      }
   }



}


void MSDelay(unsigned int itime)
{
   unsigned int i,j;
   for(i=0;i<itime;i++);
      for(j=0;j<135;j++);
}

void delay(unsigned int itime)
{
   unsigned int i,j;
   for(i=0;i<itime;i++);
      for(j=0;j<135;j++);
}

syamilshahrel
Fledgling
 
Posts: 1
Joined: Fri May 30, 2014 9:18 am

Re: Temperature Monitoring System using LM35 and PIC18f4580

Postby ober » Mon Jun 02, 2014 9:21 am

You will have to identify which parts of your code is introducing problem. It is not possible for forumers to go through your long code.

Try to narrow down the possible section.
Ober Choo
Cytron Technologies Sdn Bhd
www.cytron.com.my
User avatar
ober
Moderator
 
Posts: 1486
Joined: Wed Apr 15, 2009 1:03 pm


Return to Sensor

Who is online

Users browsing this forum: No registered users and 31 guests

cron