+ Post New Thread
Results 1 to 7 of 7
  1. #1
    Member level 1
    Points: 508, Level: 4

    Join Date
    Nov 2010
    Posts
    32
    Helped
    1 / 1
    Points
    508
    Level
    4

    Problem with LM35 temp sensing

    The following HiTech C code is written to display the temperature on LCD with PIC16F877A.However,0 value is displayed.
    Atleast the voltage should get displayed.Please help with the problem in code.

    Code:
    #include <htc.h>
    #include<math.h>
    #include<stdio.h>
    #include "lcd.h"
    __CONFIG(0x2F4A);
    
    void adc_read()
    {
    	ADCON0=0x00;
    	ADCON1=0b10000000;
    	
    	ADON=1;
    	GODONE=1;
    	while(GODONE);
    	ADON=0;
    }
    
    void main()
    {
    	TRISA=0xFF;	
            lcd_init();
    	lcd_goto(0);
    	lcd_puts("LM35 Test");
    	lcd_goto(0x40);
    	unsigned int val;
    	char buff[4];
    	while(1)
    	{
             lcd_goto(0x40);	
             adc_read();
    	__delay_ms(2000);
    	val=ADRESL;
    	sprintf(buff,"%d",val);
    	lcd_puts(buff);
    	__delay_ms(5000);
    	}
    }
    Thank You.


    Now some random garbage values like,99,28,192,424 etc are getting displayed.
    Last edited by nitsakh; 31st July 2011 at 21:21. Reason: Addition

    •   Alt31st July 2011, 21:20

      advertising

        
       

  2. #2
    Advanced Member level 3
    Points: 6,081, Level: 18
    Achievements:
    7 years registered
    cameo_2007's Avatar
    Join Date
    Mar 2007
    Location
    12°58' N77°38'E
    Posts
    752
    Helped
    71 / 71
    Points
    6,081
    Level
    18

    Re: Problem with LM35 temp sensing

    what is the output of your LM35? Is it stable?


    1 members found this post helpful.

    •   Alt1st August 2011, 05:13

      advertising

        
       

  3. #3
    Member level 1
    Points: 508, Level: 4

    Join Date
    Nov 2010
    Posts
    32
    Helped
    1 / 1
    Points
    508
    Level
    4

    Re: Problem with LM35 temp sensing

    Yes its stable.Its showing 278 mV.
    Is there any problem with code ?
    Are the ADCON0 and ADCON1 registers configured properly ? Whatis the ADC clock ?and how are their values decided ?
    I have an external 8MHz crystal osc. The LM35 input is connected to AN0;
    Last edited by nitsakh; 1st August 2011 at 11:44.


    1 members found this post helpful.

    •   Alt1st August 2011, 10:40

      advertising

        
       

  4. #4
    Newbie level 5
    Points: 430, Level: 4

    Join Date
    Jul 2011
    Location
    Tehran
    Posts
    9
    Helped
    1 / 1
    Points
    430
    Level
    4

    Re: Problem with LM35 temp sensing

    1.set the adc clock as low as it permitts you
    2.place a 100 nf capactior between lm35 output pin and ground
    when an adc wire gets longer than 20 30 cm,it acts as an powerful antenna and gets all microwaves in the air then make the adc value unstable
    if you see an antenna output on oscilloscope you will realize what i say and the role of 100nf cap


    1 members found this post helpful.

  5. #5
    Member level 1
    Points: 826, Level: 6

    Join Date
    Feb 2012
    Posts
    41
    Helped
    0 / 0
    Points
    826
    Level
    6

    Re: Problem with LM35 temp sensing

    Quote Originally Posted by nimra View Post
    1.set the adc clock as low as it permitts you
    2.place a 100 nf capactior between lm35 output pin and ground
    when an adc wire gets longer than 20 30 cm,it acts as an powerful antenna and gets all microwaves in the air then make the adc value unstable
    if you see an antenna output on oscilloscope you will realize what i say and the role of 100nf cap

    Myself Sumanta wants to see the output of LM35. When 5volt is given at its Vs pin with respect to ground, the device is getting heated up too much. Can anyone tell me the cause of this problem and how it can be solved. Waiting for all of your suggestions.


    Sumanta

    Indian Institute of Technology Kharagpur, India



  6. #6
    Newbie level 5
    Points: 430, Level: 4

    Join Date
    Jul 2011
    Location
    Tehran
    Posts
    9
    Helped
    1 / 1
    Points
    430
    Level
    4

    Re: Problem with LM35 temp sensing

    in common datasheets the view side of the components is top view
    but in lm35's datasheet the view side is bottom view so please check supply pins not to be connected incorrect
    if you connect them correctly it won't get warm ever!!!



    •   Alt13th April 2012, 12:30

      advertising

        
       

  7. #7
    Member level 1
    Points: 826, Level: 6

    Join Date
    Feb 2012
    Posts
    41
    Helped
    0 / 0
    Points
    826
    Level
    6

    Re: Problem with LM35 temp sensing

    Quote Originally Posted by nimra View Post
    in common datasheets the view side of the components is top view
    but in lm35's datasheet the view side is bottom view so please check supply pins not to be connected incorrect
    if you connect them correctly it won't get warm ever!!!

    Hi to all,

    I am facing a problem regarding the burning of program from AVR STUDIO4 in ATMEGA32 Micrcontroller through EXTREME BURNER -AVR. But while burning the following messages

    are coming -

    > Autodetecting programmer

    > Found USBasp on USB port

    > Powering ON

    > Powering failed

    > Cannot communicate with target chip

    > Retrying again

    > Power on failed

    > Cannot communicate with target chip

    > Repeating the above three

    > Powering off

    > Power turned off

    > ******Task failed*******

    > *******Please retry again*******

    > Thank you

    I have done the connections in ISP programmer according as shown in figure in the Attachment. Please check if it can be solved.


    Sumanta

    Indian Institute Of Technology Kharagpur, India



--[[ ]]--