Hi,
I'm trying to use float variable only because I need to calculate the displacement of an object with an optical encoder on 32bit variable.
I thought in a float variable, I could get a number between -2 147 483 648 and + 2 147 483 647 but in the simulation, I can get an number like + 5 000 000 000.
What are the real end authorized by a float variable in Flowcode?
Thanks,
Mathy
How works float variable in Flowcode 4 for PIC ?
Moderator: Benj
- 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:
Re: How works float variable in Flowcode 4 for PIC ?
Hello Mathy,
This Wikipedia page may help as it has a section detailing the range of Floating point variables.
http://en.wikipedia.org/wiki/Floating_point
This Wikipedia page may help as it has a section detailing the range of Floating point variables.
http://en.wikipedia.org/wiki/Floating_point
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 333
- Joined: Mon Oct 05, 2009 2:39 pm
- Has thanked: 30 times
- Been thanked: 33 times
- Contact:
Re: How works float variable in Flowcode 4 for PIC ?
It is like chinese to me
I don't need floating point in my application. Only the integer.
Is it annoying to use floating point in my case ?
Or, Is it possible to use 32 bit integer in Flowcode ?
I just need to count pulse from my optical encoder.
Thank you.
I don't need floating point in my application. Only the integer.
Is it annoying to use floating point in my case ?
Or, Is it possible to use 32 bit integer in Flowcode ?
I just need to count pulse from my optical encoder.
Thank you.
- DavidA
- Matrix Staff
- Posts: 1076
- Joined: Fri Apr 23, 2010 2:18 pm
- Location: Matrix Multimedia Ltd
- Has thanked: 58 times
- Been thanked: 258 times
- Contact:
Re: How works float variable in Flowcode 4 for PIC ?
Hello Mathy,
Unfortunately in Flowcode v4 you cannot use 32bit integers natively, in Flowcode v5 we will be changing this and adding more options.
However for the time being you can use techniques described in this article to break down your int into smaller chunks.
http://www.matrixmultimedia.com/article.php?a=366
Unfortunately in Flowcode v4 you cannot use 32bit integers natively, in Flowcode v5 we will be changing this and adding more options.
However for the time being you can use techniques described in this article to break down your int into smaller chunks.
http://www.matrixmultimedia.com/article.php?a=366
-
- Posts: 333
- Joined: Mon Oct 05, 2009 2:39 pm
- Has thanked: 30 times
- Been thanked: 33 times
- Contact:
Re: How works float variable in Flowcode 4 for PIC ?
Ok Thanks for the article. I will read it.
In the mean time, is it possible to use float variable to count pulse in clock wise and counter clock wise ?
I ask this because if I make a decision : if FLOAT1>0 then put C1=1 --> works well
But if make : if FLOAT1<0 then put C1=0 --> the result is C1=1 in the real hardware. C1=0 in simulation
Do you have an idea ?
Thanks a lot.
Mathy
In the mean time, is it possible to use float variable to count pulse in clock wise and counter clock wise ?
I ask this because if I make a decision : if FLOAT1>0 then put C1=1 --> works well
But if make : if FLOAT1<0 then put C1=0 --> the result is C1=1 in the real hardware. C1=0 in simulation
Do you have an idea ?
Thanks a lot.
Mathy
- 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:
Re: How works float variable in Flowcode 4 for PIC ?
Hello,
Floats and BoostC do not work well together. To do a floating point comparison on PIC you have to use the floating point functions.
Eg
Calculation: INTvar = float_le(FLOATvar, 0)
Decision: INTvar
All the floating point functions are available in the functions list for the calculation icon.
If you do not specifically want floating point then I would either use several byte variables or create a long variable in C code and use this to do your calculations and decisions.
Floats and BoostC do not work well together. To do a floating point comparison on PIC you have to use the floating point functions.
Eg
Calculation: INTvar = float_le(FLOATvar, 0)
Decision: INTvar
All the floating point functions are available in the functions list for the calculation icon.
If you do not specifically want floating point then I would either use several byte variables or create a long variable in C code and use this to do your calculations and decisions.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 333
- Joined: Mon Oct 05, 2009 2:39 pm
- Has thanked: 30 times
- Been thanked: 33 times
- Contact:
Re: How works float variable in Flowcode 4 for PIC ?
I just try with the floating point function but without any success. It works only on simulation.
Floats works with Hitech C compiler ?
Floats works with Hitech C compiler ?
- 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:
Re: How works float variable in Flowcode 4 for PIC ?
Hello,
Yes Floats work as expected with HiTech.
Can you post your program using the float function and I will see if I can spot what's gone wrong.
Yes Floats work as expected with HiTech.
Can you post your program using the float function and I will see if I can spot what's gone wrong.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel