Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Interfacing LM35 sensor with PIC 16F877A Problem!!!

Status
Not open for further replies.

imaasac

Newbie level 6
Joined
Nov 5, 2010
Messages
12
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,367
Hi guyz!
I am trying to interface lm35 sensor with PIC microcontroller and light the LED when temperature goes beyond 40 deg Celsius. I am using 16F877a pic and using compiler PICC in C language. I have done simulation on Proteus and got no results. I have write this code, can any body tell me where is the problem in this code. Thanks

Code:
#use delay(clock=10000000)
int16 temp, cent;
int16 triptemp, triptempc=40;
void main()
{

   setup_adc_ports(all_ANALOG);
   setup_adc(ADC_clock_internal);
   set_adc_channel(0);
   TripTemp = ((TripTempC/1023)*500);
   while(1)
   {
      
      temp=read_adc();
      cent=((temp/1023)*500);
     
      if(cent>triptemp)
      {  
        output_high(53);
      }
      else
      {
      output_low(53);
      }
      delay_ms(100);
   
   }
}
 

ckshivaram

Advanced Member level 5
Joined
Apr 21, 2008
Messages
5,070
Helped
2,149
Reputation
4,304
Reaction score
2,089
Trophy points
1,393
Location
villingen (Germany) / Bangalore
Activity points
30,086
search in the forum.... you will get it

---------- Post added at 22:04 ---------- Previous post was at 22:01 ----------

you already got the code and already the program for temp measuring and activating buzzer from me and tahmid,......


you expect us to do the project for you..............

already told.. until you learn yourself you will always run for help... dont expect tahmid to answer viva tooo.. he is a busy person
 

imaasac

Newbie level 6
Joined
Nov 5, 2010
Messages
12
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,367
search in the forum.... you will get it

---------- Post added at 22:04 ---------- Previous post was at 22:01 ----------

you already got the code and already the program for temp measuring and activating buzzer from me and tahmid,......

Dear Thank U for your code... but that code is not of use for my project.... first because i dont understand the code and your code is very lengthy and also extra code is given which is waste of memory.

I thought some one can help me here to learn something.
 

Tahmid

Advanced Member level 5
Joined
Jun 17, 2008
Messages
4,758
Helped
1,792
Reputation
3,576
Reaction score
1,651
Trophy points
1,393
Location
Silicon Valley, California, USA (from Dhaka, Bangl
Activity points
30,539
Hi,
I see a few problems. I use mikroC and don't use PICC much, but try with this:
Code:
#use delay(clock=10000000)
int16 temp, cent;
int16 triptemp, TripTempc=40;
void main()
{
   TRISA = 0x01;
   TRISD = 0; //You haven't specified buzzer output
   setup_adc_ports(all_ANALOG);
   setup_adc(ADC_clock_internal);
   set_adc_channel(0);
   triptemp = (TripTempC*500)/1023; //This should be how it is. First dividing by 1023 makes the result always equal 0
   while(1)
   {
      
      temp=read_adc();
      cent=(temp*500)/1023; //Same mistake here
     
      if(cent>triptemp)
      {  
        output_high(PIN_D0); //What's 53?, Try with PIN_D0 (I assume this is where buzzer is connected)
      }
      else
      {
      output_low(PIN_D0); //Same here
      }
      delay_ms(100);
   
   }
}
Hope this helps.
Tahmid.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top