This error message appears. "math.h" is included. Can anyone help me?
Best regards Kucky
c:/winavr/bin/../lib/gcc/avr/4.3.3/../../../../avr/lib/avr6\libm.a(modf.o): In function modff': (.text.avr-libc.fplib+0x3e): relocation truncated to fit: R_AVR_13_PCREL against symbol __subsf3' defined in .text section in c:/winavr/bin/../lib/gcc/avr/4.3.3/avr6\libgcc.a(_addsub_sf.o)
make: *** [Robot4.elf] Error 1
There's not enough of your sketch here to say for sure.
I notice that your #defines are commented out. And that they are syntactically incorrect to begin with, because there's an "=" in there. I uncommented and corrected them and and added some missing bits t o get this, which builds fine:
#include <math.h>
int port = A0;
void setup() {
// put your setup code here, to run once:
float val = 0;
float _val = 0;
#define SHARPFRONTLEFTFAC 15972.0
#define SHARPFRONTLEFTEXP -0.89
val = SHARPFRONTLEFTFAC * pow(((float)analogRead(port)), SHARPFRONTLEFTEXP);
}
I no longer believe that there is a problem with "pow". I rather think it is due to the variable declaration. But I'm probably blind. I 'do not see the error.
//-----------------------------------------------------------------------------
float readAnalog(int port)
{
float val = 0;
for (int i = 0; i <= 3; i++)
{
val = val + analogRead(port);
}
val = val/3;
return val;
}
//-----------------------------------------------------------------------------
int CalcSharpDistance(int port, int sharpNr)
{
double val = 0;
float _val = 234.0;
float test = 1.0;
_val = analogRead(port);
val = pow(_val, test); ERROR
val = pow(_val, 1.0); No ERROR
return val;
}
It is certainly a trifle. But I do not see it. Who can help. :~
Kucky
float readAnalog(int port)
{
float val = 0;
for (int i = 0; i <= 3; i++) // <<<<<< that is four times so
{
val += analogRead(port);
}
return val/4 ; // <<<<<<<<<<<<<<<<<<<<< divide by 4 not by 3 ....
}
c:/winavr/bin/../lib/gcc/avr/4.3.3/../../../../avr/lib/avr6\libm.a(modf.o): In function `modff':
(.text.avr-libc.fplib+0x3e): relocation truncated to fit: R_AVR_13_PCREL against symbol `__subsf3' defined in .text section in c:/winavr/bin/../lib/gcc/avr/4.3.3/avr6\libgcc.a(_addsub_sf.o)
make: *** [Robot4.elf] Error 1
A bit more information please. What chip is this? How big is your code? Is it possible it is too large to fit?
My guess is that this is the case. I think this is a linker error.
So you're not using the Arduino IDE to do the compile?
What compile command ARE you using?
The "relocation doesn't fit" error usually happens if you have some compiler switch for small code (ie from bootloaders) combined with a library that needs full-sized calls/etc.
Had written yesterday, that I have eliminated the error. Oddly, the posting has not been published. Should it have someone read, the error still exists. Unfortunately. =(
LGK
I was not idle. I activated a previous version again. The changes I've grudge, so it is all so again, as in the erroneous code. No error message in the said place. Several times compiled and flashed. Everything OK.
Then I wrote a code in the same place, which is to calculate an angle. And what do you think? Right, the error is back.
I note that the error is always associated with...
pow, asin or sqrt.
I've included the WProgram.h Arduinio from version 0.22. Even if I am explicitly added math.h, the error occurs.
#include<WProgram.h>
#include<math.h>
I once read that makes math.h in Eclipse problems. Find the information but no longer. You can start here with what?
For your help, I would like to thank you in advance.