Float point help!

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 2 and 3.

Moderators: Benj, Mods

Post Reply
Teo
Posts: 7
Joined: Wed Nov 14, 2007 10:21 pm
Location: Bucuresti , Romania
Contact:

Float point help!

Post 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!!!!

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Post 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.

Teo
Posts: 7
Joined: Wed Nov 14, 2007 10:21 pm
Location: Bucuresti , Romania
Contact:

Post by Teo »

Hi,thanks for answer . How change the value of radius with value from ADC or thermometer component in float32 example? Thanks!!!!

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Post 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

Teo
Posts: 7
Joined: Wed Nov 14, 2007 10:21 pm
Location: Bucuresti , Romania
Contact:

Post by Teo »

Thank you very much! I declare 'a' int variable and radius = float32_from_int32( a );
and dont work :oops:
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!

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Post 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.

Teo
Posts: 7
Joined: Wed Nov 14, 2007 10:21 pm
Location: Bucuresti , Romania
Contact:

Post by Teo »

Thank you very much! Now is OK!!!! :D

Post Reply