Page 1 of 1
Float point help!
Posted: Wed Nov 14, 2007 11:10 pm
by Teo
Hi, I'm registrate user, please post example with convert 0-1023 to 0.00-100.00(2 decimals) use the thermometer and lcd components.Please post the real help for float point instructions and moore examples.Sory for my language.Thanks!!!!
Posted: Thu Nov 15, 2007 10:36 am
by Benj
Hello Teo
Everything you need to get started with floating point is available from here.
http://www.matrixmultimedia.com/support ... .php?t=505
Try doing a little bit at a time rather then taking on the entire task all at once.
Let me know if you get stuck.
Posted: Thu Nov 15, 2007 1:45 pm
by Teo
Hi,thanks for answer . How change the value of radius with value from ADC or thermometer component in float32 example? Thanks!!!!
Posted: Thu Nov 15, 2007 1:53 pm
by Benj
Hello
Firstly you need to read in the ADC value into an Int variable.
Then you will need to use C code to convert this Int into a float variable.
Then you will have to create a second float variable and assign the value of 10.23.
The you can devide the ADC result variable with the constant variable to get your range of 0 - 100.
You can then multiply the result by 10 to get a range of 0 - 10000. Then convert this variable back into an Int and you can then use flowcode to print out the number.
The 10000 wil represent 100.00
Posted: Thu Nov 15, 2007 2:11 pm
by Teo
Thank you very much! I declare 'a' int variable and radius = float32_from_int32( a );
and dont work
C:\Documents and Settings\dumitru.teodor\Desktop\FLOWCODE\float32\float32.c(564:31): error: unknown identifier 'a'
C:\Documents and Settings\dumitru.teodor\Desktop\FLOWCODE\float32\float32.c(564:29): error: arguments of 'float32_from_int32' don't match the parameters of call
C:\Documents and Settings\dumitru.teodor\Desktop\FLOWCODE\float32\float32.c(564:11): error: failed to generate expression
C:\Documents and Settings\dumitru.teodor\Desktop\FLOWCODE\float32\float32.c(564:11): error: invalid operand 'float32_from_int32( a )'
C:\Documents and Settings\dumitru.teodor\Desktop\FLOWCODE\float32\float32.c(564:9): error: failed to generate expression
float32.c success
please help!
Posted: Thu Nov 15, 2007 5:04 pm
by Benj
Hello
Ok I can see where your going wrong.
If you create a variable in flowcode eg "a" then the C equivalent of that variable is "FCV_A".
so to clarify
Flowcode variable a becomes C code variable FCV_A
Flowcode variable var1 becomes C code variable FCV_VAR1
etc.
Hope this helps.
Posted: Thu Nov 15, 2007 10:22 pm
by Teo
Thank you very much! Now is OK!!!!
