COUNT UP TO 100000

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

Moderators: Benj, Mods

Post Reply
User avatar
miguelmauricior
Flowcode V4 User
Posts: 42
Joined: Tue May 05, 2009 12:13 pm
Location: COLOMBIA
Contact:

COUNT UP TO 100000

Post by miguelmauricior »

Hi,
I am working in a application that must count up to 100000 so . Can somebody tell me what I have to do to achieve it?
I know if I use a variable as INT I just count up to 32767, but

1.How can I display the complete number up to 32767
2.How can show big number than 32767?

I work with PICS I know they mathematics is very restricted but is possible but HOW?

Let know any comment.

Thanks.
MMRZ

Jaspervdw
Posts: 12
Joined: Fri Dec 12, 2008 4:45 pm
Been thanked: 3 times
Contact:

Re: COUNT UP TO 100000

Post by Jaspervdw »

Work with 6 counters: hundreds, tens, ...

User avatar
miguelmauricior
Flowcode V4 User
Posts: 42
Joined: Tue May 05, 2009 12:13 pm
Location: COLOMBIA
Contact:

Re: COUNT UP TO 100000

Post by miguelmauricior »

Hi,

Thanks for your reply. But Can you give me a clue. How can I get the total result from a division operation?. Currently if I divide something I just can get the entire part.

Let know any comment please.
MMRZ

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:

Re: COUNT UP TO 100000

Post by Benj »

Hello

If you are wanting to do calculations on a number this big then you are going to have to use C code.

You could do something similar to the following.

C code Icon:

long var;
var = 100000;

Also if you need to get the fractional part of a division operation then you will need to use the floating point library. There is an example available from here.

http://www.matrixmultimedia.com/support ... .php?t=505

User avatar
miguelmauricior
Flowcode V4 User
Posts: 42
Joined: Tue May 05, 2009 12:13 pm
Location: COLOMBIA
Contact:

Re: COUNT UP TO 100000

Post by miguelmauricior »

Hello Benj,

I was reading the example you suggested me and I found helpful but I have a doubt.

1.After declaring a variable with a 100000 long how I do to separate the whole and the fraction.

The technique showed in the example to separate the part is clear, or I can converted in string and shift every part of the entire number to display it after but my doubt is related with the question above. So let know about any comment or example or referece.

Benj, tell me please how to load the information in the variable and then separate every part?

Thanks again.
MMRZ

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:

Re: COUNT UP TO 100000

Post by Benj »

Hello

Posting red text, large red text and reposting messages are all likely to get you removed from the forum. You have been warned. I have removed the large red text repost.

If you are not getting a responce then try to provide a bit more detail or try to show that you are giving it some thought yourself and trying to work it out. Thats the way to improve your skills.

The Long variable is a 32-bit Integer variable so there is no fraction part. If you need variables that can go up to 100000 with fractions then you need to use floating point variables.

The floating point example shows how to seperate the real and fractional portions of the numbers to allow you to display them on a LCD etc.

User avatar
miguelmauricior
Flowcode V4 User
Posts: 42
Joined: Tue May 05, 2009 12:13 pm
Location: COLOMBIA
Contact:

Re: COUNT UP TO 100000

Post by miguelmauricior »

Hello Benj,

I am so sorry for the text appereance but I did not know. Respect with the example as I told you it is clear in the separation of parts.But my question is how I do that with one variable.
Imagine I am using and ADC PIC module and I want to convert the bits count in a voltage with a single math operation but I want to see all the full and detailed range in the LCD. If the input reads 511(which means 2,497V) how I do to get it using the float point?

Thanks and excuse me again.
MMRZ

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:

Re: COUNT UP TO 100000

Post by Benj »

Hello

Flowcode V4 will do this conversion to a floating point voltage automatically for you.

One way to do this in V3 would be to take the analogue reading and then use C code to convert the number to floating point, divide it by the 1024 and then multiply by the voltage eg 5. You would then have to shift out the integer and real portions back into integer variables to allow for the values to be displayed on a LCD etc.

Another way would be to use a lookup table. Eg have two arrays of data containing the seperate integer and real portions of the analogue value. You could then use the analogue ReadAsByte function and this would give you a result between 0-255. This value would then be used as the index for the two arrays to collect the integer and real portions. The arrays would have to both be 256 bytes long and the data would have to be created in excel etc.

Here is an example of the data in the arrays

5V / 256 = 0.02V approx

array1_int = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0..............
array2_real = 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20............

I think Sean posted a lookup table example in the articles section.

User avatar
miguelmauricior
Flowcode V4 User
Posts: 42
Joined: Tue May 05, 2009 12:13 pm
Location: COLOMBIA
Contact:

Re: COUNT UP TO 100000

Post by miguelmauricior »

Hello Benj,

Thanks for your reply I have a clue about a Look up table means.According wiht it I must create a table which relates the value of ADC in BITS with the voltaje desired.
Plase tell me if I am right and let know about the exmples you told me in your previous reply.

Thanks.
MMRZ

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:

Re: COUNT UP TO 100000

Post by Benj »

Hello

Yes you would take your ADC reading and use it as the index for the array values to allow you to pull out the correct values. Eg your ADC value is used to look up the voltage. The two arrays are required for the seperate real and integer portions of the voltage.

Here is the article.
http://www.matrixmultimedia.com/mmforum ... =26&t=4869

When printing out the real portion of the number you might run into the following problem. the real portion gives a reading of 5 which translates to say 2.05. However when printing to a display you will get the result 2.5. To get around this problem you can check if the number is less then 10. If it is then print a 0 character before printing your number to give you the correct result 2.05.

Post Reply