Wed 07 Apr 2010 06:16:41 AM UTC, original submission:
Hello,
Using the folowing code results to compile/link errors:
#include <math.h>
/***************************************************************
Project: SHTxx
***************************************************************/
typedef union
{
unsigned int i;
float f;
} value;
//--------------------------------------------------------------
// calculates dew point
// input:humidity [%RH], temperature []
// output: dew point
//--------------------------------------------------------------
float calc_dewpoint(float h, float t)
{
float logEx;
float dew_point;
/**/
// Original code (ERROR!!!):
logEx = 0.66077 + 7.5 * t / (237.3 + t) + (log10(h) - 2);
dew_point = (logEx - 0.66077) * 237.3 /
(0.66077 + 7.5 - logEx);
/**/
/*
// Modified code (just for the test):
logEx = 0.66077 + 7.5 * t / (237.3 + t) + (1.0 - 2);
dew_point = (logEx - 0.66077) * 237.3 /
(0.66077 + 7.5 - logEx);
*/
return dew_point;
}
//--------------------------------------------------------------
// sample program that shows how to use SHT11 functions
//--------------------------------------------------------------
int main(void)
{
value humi_val;
value temp_val;
float dew_point;
while (1)
{
//converts integer to float
humi_val.f = (float)humi_val.i;
temp_val.f = (float)temp_val.i;
//calculate dew point
dew_point = calc_dewpoint(humi_val.f,
temp_val.f);
}
return 0;
}
I'm using the WinAVR20100110 compiler, but the WinAVR20090313 has the same problem. I also use Studio4 4.18 SP2 build 700. The used micro is a ATXmega128A1.
See function calc_dewpoint(). When I compile with the original code, it results in an compile error, so I modified the code and replaced the log10(h) code into 1.0. Now it is compiled without any errors.
Hope this problem will be fixed soon.
Regards,
Robert.
|