Working with floating point
Up to Project Discussion
Hi all,
Thanks for all the help I've got in the past, my current project is accumulate a value from analog input (integrate over time) and then display the integrated average on the serial i/f LCD display used in the RSS weather project.
I get stuck when it comes to converting the Double to string using fcvt():
void Energizer( int id ) // code that will get called by the timer every 1000 ms.
{
int value=0,i,dec_pt,sign;
double P,U,R=100; //R=100 ohm
static double E=0;
value=AnalogIn_GetValue( 7 );
U=(value/1023*3300); //U expressed in mV
P=U*U/R; //P expressed in mW
E+=P*1; // E expressed in mJ, t=1 s
Display(fcvt(E,3, &dec_pt,&sign));
}
Display(char *msg) //sends textstring to LCD
Only garbage comes out, also when E=1.5!
Is there something about fcvt() i misunderstood?
(Display() works fine with "Hello World" and such)
Any help is greatly appreciated
Kell Skogh
Ok, this seems a tough lesson..
seems there is no soft FP support???
So I gave up and tried doing the math in integer (will probably screw everything up but got to try something..)
so I tried the itoa() function in stdlib =
...which isn't there either, or? Oddly the fcvt() seemed to link..
My goal is to do some math, and send the result as a text string to a display via the serial port. doesn't seem hard, but unfortunately I don't seem to manage so... Help!
Hmmm sprintf() seems to be one way?
Thanks
/Kell

