Page 1 of 1

Float to string problem

Posted: Mon Dec 10, 2012 9:00 am
by MarkW
Hi Ben and other guys

Got a major problem. Using FC4 and just about finished my program/project....with
a hiccup at 12th hour. The project calls for sending a string out the serial port
that is generated from float calculations. I did see a post somewhere that the
float to string is internally limited by integer data type. I need to have a float
to string routine that can handle maybe up to 7 or 8 digits in the whole part
of the number.

Problem is i cannot goto FC5 just yet, as this project is already stressed
timewise and i do not have enough time to sort out new licences/code
porting etc etc....

Guys, i am really in a pickle here. This is the last project i am doing using FC4
so i really need a solution urgently.
After this i am will be going to FC5 which i believe supports long type var
for the whole variable.

Help!

Thanx

Mark

Re: Float to string problem

Posted: Mon Dec 10, 2012 11:17 am
by Benj
Hello Mark,

Please make a backup of the internals.h file located in the "Flowcode v4/FCD" folder and then replace the file with the file located here.
internals.h
(73.23 KiB) Downloaded 310 times
This should allow up to 7 digits on the whole number though I have not tried a compile.

Let me know how you get on.

Re: Float to string problem

Posted: Mon Dec 10, 2012 12:10 pm
by MarkW
Hi Ben

I had an idea the internals needed some surgery :)

anyway, i did try with new internals file but it gives compile error....

Float_test3.c
Starting preprocessor: c:\PROGRA~1\MATRIX~1\FLOWCO~2\boostc\pp.exe Float_test3.c -i c:\PROGRA~1\MATRIX~1\FLOWCO~2\boostc\include -d _PIC18F2610 -la -c2 -o Float_test3.pp -v -d _BOOSTC -d _PIC18 -d _CHAR_INDEX


.............

C:\Program Files\Matrix Multimedia\Flowcode V4\FCD\internals.h(1483:15): error: unknown identifier 'FCI_LONG_TOSTRING'
C:\Program Files\Matrix Multimedia\Flowcode V4\FCD\internals.h(1483:15): error: failed to generate expression
C:\Program Files\Matrix Multimedia\Flowcode V4\FCD\internals.h(1483:15): error: invalid operand 'FCI_LONG_TOSTRING(whole, temp_string, 7)'
C:\Program Files\Matrix Multimedia\Flowcode V4\FCD\internals.h(1483:13): error: failed to generate expression
C:\Program Files\Matrix Multimedia\Flowcode V4\FCD\internals.h(1485:18): warning: local variable 'str_length' may be used uninitialized
Float_test3.c success

failure

Return code = 1

Flowcode was unable to compile the flowchart's C code due to the following errors:


If your flowchart contains C code, please review this carefully. If your flowchart contains no C-code or you have thoroughly reviewed the code, contact Technical Support.

FINISHED


Can you give it another go? I have a test file if you want to use that to compile with. It is a very simple program.

Cheers

Mark

Re: Float to string problem

Posted: Mon Dec 10, 2012 12:15 pm
by MarkW
Hi Ben

Simple float to str test program

Mark

Re: Float to string problem

Posted: Mon Dec 10, 2012 12:34 pm
by Benj
Hi Mark,

This new one seems to compile correctly now.

Re: Float to string problem

Posted: Mon Dec 10, 2012 12:54 pm
by MarkW
Hi Ben

Big improvement! I can now get up to 6 whole digits....

however, i still need 7 to 8 digits....if i goto 1 million on
the whole, it puts in odd char in digit 6...the zero following the 1
as in 1 millon

I am actually testing on 18F2620 with 232 chip to hyperterm.
Everything works great but see example output on hyperterm

START TEST (1 x 999999)
999999.000000
OK


START TEST (1 x 1000000)
1:00000.000000
Not OK

Re: Float to string problem

Posted: Mon Dec 10, 2012 3:36 pm
by MarkW
Hi Ben

Any further progress on the fix for the corrupt 6th digit when doing
7 digit string?

If we can sort that out it will be champion :D

Thanx

Mark

Re: Float to string problem

Posted: Tue Dec 11, 2012 3:42 pm
by Benj
Hello Mark,

Sorry for the delay.

Here is a file that should hopefully work a bit better.
internals.h
(73.48 KiB) Downloaded 323 times
If there is still an issue then look at line 1505 and edit it to this.

Code: Select all

str_length = FCI_LONG_TOSTRING(whole, temp_string, 8);		//Convert integer numbers to strings

Re: Float to string problem

Posted: Tue Dec 11, 2012 8:28 pm
by MarkW
Hi Ben,

That did the trick thanx :D
My apologies for asking for rapid answer, had unusually tight deadline.

This project is now complete, and will be moving onto FC V5...yay!
Consider that another sale in the bag for MM :D

For all those observing this thread, you may use this latest attached
internals.h file to achieve larger float to string in FC4 due to
Benj's great support.

Thank you very much!

Mark