Skip to content

math log() function crashes with reboot. #354

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
cornelalexa opened this issue May 28, 2015 · 5 comments
Closed

math log() function crashes with reboot. #354

cornelalexa opened this issue May 28, 2015 · 5 comments

Comments

@cornelalexa
Copy link

Hi,

I have a dew point calculation function which use log() and when used the ESP crashes and reboots.
Here is the code for it.

float dewPointFast(float celsius=0, float humidity=0)
{
if(celsius==0 && humidity ==0) return (float) 0.00;
const float a = 17.271;
const float b = 237.7;
float temp = (float)((a * celsius) / (b + celsius));
temp+= log(humidity/100); //this crashes and reboots
float Td = (float)((b * temp) / (a - temp));
return Td;
}

It seems that log10() does the same so it might worth having a look at that too.

Thanks!

@cornelalexa
Copy link
Author

Not sure if it helps, below is the data from crash:

ets Jan 8 2013,rst cause:4, boot mode:(3,0)

wdt reset
load 0x40100000, len 28832, room 16
tail 0
chksum 0x80
load 0x3ffe8000, len 1564, room 8
tail 4
chksum 0x8e
load 0x3ffe8620, len 4796, room 4
tail 8
chksum 0x43
csum 0x43
rd

@holgerlembke
Copy link
Contributor

Crashes here, too.

Try to live with that:

float log(float dings) {
static float ln10 = -1;

if (ln10<0) {
ln10 = ln(10);
}
return ln(dings)/ln10;
}

float ln(float x) {
float zw1 = (x-1)/(x+1);
float zw2 =zw1*zw1;
float res = 0;

int c=1;
do {
res+=zw1/c;
c+=2;
zw1*=zw2;
ESP.wdtFeed();
} while (zw1>1/1000.0); // resolution...

return res+res;
}

Oh. And "somethingfloat==somethingother" is always wrong.

@igrr
Copy link
Member

igrr commented May 29, 2015

Same as #233.

@cornelalexa
Copy link
Author

Thank you.

The above functions works as a fix for me. Hope they will be able to fix in the toolchain also. It seems that many functions related to math have issues...

@igrr
Copy link
Member

igrr commented Jun 19, 2015

Fixed in esp8266 branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants