[Tinyos-help] reading temp and converting to celcius

2006-12-20 Thread olcay çelik

hello
i took a graduation project which was measuring temperature and displaying 
on a webserver. I have searching internet since 1 mount and laslty found a 
header information from tinyos data and i found a C# code which is 
calculating temperature. but i was unable to understand some part of it. 
here i am pasting to code, may be you are helping to me to understand what 
is going on. here is :



/// summary
/// Calculates the temperature, in degrees Celsius of the:
///
/// Panasonic ERT-J1VR103J Thermistor
///
/// The formula in the MTS Series User Manual is:
/// 1/T(K) = a + b × ln(Rthr) + c × [ln(Rthr)]^3
///
/// where:
/// Rthr = R1(ADC_FS-ADC)/ADC
/// a = 0.00130705
/// b = 0.000214381
/// c = 0.00093
/// R1 = 10 kOhm
/// ADC_FS = 1023
/// ADC = output value from mote’s ADC measurement.
///
/// Note that an adjusted temp (adjTemp) is used because the
/// actual temp reading is a 10 bit value that has been compressed
/// into a single byte. As such it must be shifted left 2 bit places.
///
/// The value for _temp is the raw sensor reading from the SurgeMsg.
///
/// /summary
/// returnsTemperature in Degrees Celsius as a float./returns
float CalculateTempC()
{
int adjTemp = _temp  2;
// prevent divide by zero.
if(adjTemp == 0)
return 0F;
float temperature, a, b, c, Rthr;
a = 0.001307050F;
b = 0.000214381F;
c = 0.00093F;
Rthr = 1 * (1023 - adjTemp) / adjTemp;
temperature = 1 / (float)(a + b * Math.Log(Rthr) + c *
Math.Pow(Math.Log(Rthr),3));
temperature -= 273.15F; // Convert from Kelvin to Celcius
return temperature;
}
/// summary
/// Uses normal Celsius to Fahrenheit conversion formula:
///
/// Fahrenheit = Celsius * 9/5 + 32
///
/// /summary
/// returnsTemperature in degree F as a float./returns
float CalculateTempF()
{
return (CalculateTempC() * 9 / 5) + 32;
}



in this code especially in the variable declaration a, b, c and Rthr what is 
it ?  i did not understand

please someone help me because i have to write my own code. and

my second question is in the simulation environment how can i see the raw 
data for the calculating temperature by using surge-view application


if someone had did this measuring temperature please help me

_
Windows Live™ Messenger has arrived. Click here to download it for free!  
http://imagine-msn.com/messenger/launch80/?locale=en-gb


___
Tinyos-help mailing list
Tinyos-help@Millennium.Berkeley.EDU
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help


Re: [Tinyos-help] reading temp and converting to celcius

2006-12-20 Thread Benjamin Madore

On Wed, December 20, 2006 6:21 am, olcay çelik said:

 in this code especially in the variable declaration a, b, c and Rthr what is
 it ?  i did not understand
 please someone help me because i have to write my own code. and

 my second question is in the simulation environment how can i see the raw
 data for the calculating temperature by using surge-view application

 if someone had did this measuring temperature please help me


You know, I just fudged it, since it wasn't important for me. That and the
battery code seem to implement strangely through Surge. It never mentions
anywhere if there is any pre-conversion in code or what, but things are
either wildly off or inverted. I probably have something wrong, but it's not
worth it to me to figure out what.

Also, the included code doesn't seem to be mathematically simplified, making
it slightly more complicated for those who don't want to try to understand
the sensor operation, only want to display the result.

-- 
The difference between the right word and the almost right word is really a
large matter- it's the difference between a lightning bug and the lightning.
-Twain

___
Tinyos-help mailing list
Tinyos-help@Millennium.Berkeley.EDU
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help


Re: [Tinyos-help] reading temp and converting to celcius

2006-12-20 Thread Michael Schippling

Just a note on the battery code...if you are using mica2
(and perhaps others...) the reading called battery from
ADC7 is coming from a fixed voltage reference, however the
Vref for the converter _is_ the battery. Therefore, as the
battery droops, the apparent value on ADC7 _increases_.
That's why the calculation of actual battery voltage involves
an inversion. I posted an excruciatingly nerdly exegesis of
this about a year ago if you search for battery and ADC...

The convenient thing about this is that sensors which boil
down to voltage dividers (e.g., thermistors) that run off
the same battery do not need to account for bat-volt change.

MS

Benjamin Madore wrote:

On Wed, December 20, 2006 6:21 am, olcay çelik said:

in this code especially in the variable declaration a, b, c and Rthr what is
it ?  i did not understand
please someone help me because i have to write my own code. and

my second question is in the simulation environment how can i see the raw
data for the calculating temperature by using surge-view application

if someone had did this measuring temperature please help me



You know, I just fudged it, since it wasn't important for me. That and the
battery code seem to implement strangely through Surge. It never mentions
anywhere if there is any pre-conversion in code or what, but things are
either wildly off or inverted. I probably have something wrong, but it's not
worth it to me to figure out what.

Also, the included code doesn't seem to be mathematically simplified, making
it slightly more complicated for those who don't want to try to understand
the sensor operation, only want to display the result.


___
Tinyos-help mailing list
Tinyos-help@Millennium.Berkeley.EDU
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help