View previous topic :: View next topic |
Author |
Message |
kel
Joined: 17 Oct 2005 Posts: 68 Location: Brisbane
|
Any one used Lm335 temperature sensor? |
Posted: Sat Jan 14, 2006 1:39 am |
|
|
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
|
|
Posted: Sat Jan 14, 2006 5:27 am |
|
|
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
|
Lm335 temperature sensor |
Posted: Sat Jan 14, 2006 10:05 pm |
|
|
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 ?
thanks mate
cheers[/code] |
|
|
Ttelmah Guest
|
|
Posted: Sun Jan 15, 2006 3:23 am |
|
|
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
|
|
Posted: Sat Mar 18, 2006 7:37 pm |
|
|
Nice trick! ;)
But I dont understand the use of "L" after the number. Could you explain?
Thanks in advance.
_________________ www.hlektronika.gr |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Sat Mar 18, 2006 8:17 pm |
|
|
Long |
|
|
kender
Joined: 09 Aug 2004 Posts: 768 Location: Silicon Valley
|
|
|
|