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

Any one used Lm335 temperature sensor?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
kel



Joined: 17 Oct 2005
Posts: 68
Location: Brisbane

View user's profile Send private message

Any one used Lm335 temperature sensor?
PostPosted: Sat Jan 14, 2006 1:39 am     Reply with quote

I'm connecting the Lm335 pins directly to Pic16f877a ADC converter.
can some kindkly post the calculations for lm335 temperature and how the this could be used to calculate the temperature from the temperature read from adc i.e T=read_adc();
thanks
Ttelmah
Guest







PostPosted: Sat Jan 14, 2006 5:27 am     Reply with quote

Yes, have used these in the past for a simple 'ambient' temperature sensor.
The 'reading', will depend on the reference voltage you use on the ADC. Hwever assuming 5v supply, and Vref=Vdd, then the reading (with the ADC set to give 10bit accuracy), is:

temp_inDegC=(read_adc()*0.48828)-273.15;

Generally, you can 'cheat' and use integer arithmetic, assuming that a little error is not that important, and if you take:

temp_inDegC_int=(read_adc()-559L)/2;

Gives reasonable results over the 'room tempature' sort of range, without nearly so much work by the processor.

Best Wishes
kel



Joined: 17 Oct 2005
Posts: 68
Location: Brisbane

View user's profile Send private message

Lm335 temperature sensor
PostPosted: Sat Jan 14, 2006 10:05 pm     Reply with quote

Thanks alot Ttelmah...I can understand the first first equation but i still find it hard to decipher how you arrive to the second equation!
Code:
temp_deg_int = (read_adc()-559L)/2;

How did you get the
Code:
559L/2
?
thanks mate
cheers[/code]
Ttelmah
Guest







PostPosted: Sun Jan 15, 2006 3:23 am     Reply with quote

Not 559L/2.
Look where the brackets are.
(reading-559L)/2

You do the subtraction first.
Basically, a 0C reading, gives (nominally) 2.73v. With a 5v reference, this gives a reading of 559. So you subtract this from the incoming reading first. You now have a value of '0', for 0C, rising by just over 2 counts per degree. You will actually get 205 counts for 100C, after the subtraction, so division by 2, gives just over 2% error for the temperature. Not bad, and a lot simpler than the floating point version. :-)

Best Wishes
gs



Joined: 22 Aug 2005
Posts: 30
Location: Ioannina - Greece

View user's profile Send private message Visit poster's website

PostPosted: Sat Mar 18, 2006 7:37 pm     Reply with quote

Nice trick! ;)

But I dont understand the use of "L" after the number. Could you explain?

Thanks in advance.

Smile
_________________
www.hlektronika.gr
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Sat Mar 18, 2006 8:17 pm     Reply with quote

Long
kender



Joined: 09 Aug 2004
Posts: 768
Location: Silicon Valley

View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger

PostPosted: Sat Mar 18, 2006 8:46 pm     Reply with quote

Take a look at thisvery recent thread. The poster had the same plroblem with long.

http://www.ccsinfo.com/forum/viewtopic.php?t=26366
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
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