CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

LM35 temp sensor reading (10°C off)
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Kenny



Joined: 07 Sep 2003
Posts: 173
Location: Australia

View user's profile Send private message

PostPosted: Mon Mar 02, 2009 10:13 pm     Reply with quote

The LM34 can go down to about 5F (-15C) without using a negative supply.
The sensitivity is 18mV/degree C (10mV/degree F by 9/5).
Mamat



Joined: 20 Jan 2011
Posts: 9

View user's profile Send private message Yahoo Messenger ICQ Number

Re: LM35 temp sensor reading (10°C off)
PostPosted: Wed Feb 16, 2011 10:11 am     Reply with quote

STIX wrote:
Hi:

I connected a LM35 temperature sensor to my PIC16F877A MCU to take temperature readings. The following is my code:

Code:

#include <16F877A.h>
#device *=16
#device ADC=10
#include <math.h>
#include <stdio.h>
#include <stdlib.h>

#fuses HS,NOWDT,NOPUT,NOPROTECT,NODEBUG,BROWNOUT,NOLVP,NOCPD,NOWRT

#USE DELAY(clock = 4000000)
#use RS232(baud = 9600, xmit = PIN_C6, rcv = PIN_C7)

void main ()
{
   int16 value, value1;
   setup_adc (ADC_CLOCK_DIV_8);
   setup_adc_ports (AN0);
   set_adc_channel (0);
   while (1)
   {
      delay_ms (500);
      value = read_adc ();
      value1 = 5 * value * 100/1024;
      printf ("Temp:%5.1fC\n\r", (float)value1);
   }
}


How the code if I have two lm34 to use 2 analog input ?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Feb 16, 2011 1:40 pm     Reply with quote

These threads have examples of how to read two A/D channels on the PIC:
http://www.ccsinfo.com/forum/viewtopic.php?t=25969
http://www.ccsinfo.com/forum/viewtopic.php?t=42007
temtronic



Joined: 01 Jul 2010
Posts: 9245
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Feb 16, 2011 2:01 pm     Reply with quote

Also add 'errors' to the options in USE RS232(....) !
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group