how to generate ulong variable in V4.5?

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

Post Reply
goingo
Flowcode v5 User
Posts: 10
Joined: Wed Aug 31, 2011 4:53 pm
Has thanked: 5 times
Contact:

how to generate ulong variable in V4.5?

Post by goingo »

hallo
i would like to generate an long or ulong variable with v4.5 (i know that v5 is supporting this feature)

my problem is that i am using a timer for generating long delays between 1 minute and xxx minutes

cristal: 19,6608 Mhz
timer with interupt : prescaler 1:1 --> 75Hz
int variable: max. value 32768 -->causes max time from about 7 minutes

thanx for any help :D

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: how to generate ulong variable in V4.5?

Post by medelec35 »

Hi goingo,
You don't need a ulong variable to have long delays.


At the start of your Flowchart before main loop you can have:
seconds = 0
minutes = 0
hours = 0

With in your interrupt you can have:
count=count+1
If count =75 then count=0: seconds = seconds+1: If seconds = 60 then seconds=0:minutes = minutes + 1:if minutes = 60 then minutes = 0:hours = hours + 1
etc.
If you want to have a 46220 seconds delay for example.
In main you can have:
If (hours = 12) && (minutes =50) && (seconds = 20) then: output 1 to port A1 etc.

There are clock examples on the forums.
If you get stuck just yell and I can help you further.

Martin
Martin

goingo
Flowcode v5 User
Posts: 10
Joined: Wed Aug 31, 2011 4:53 pm
Has thanked: 5 times
Contact:

Re: how to generate ulong variable in V4.5?

Post by goingo »

wonderful it works perfect :D
many thanx to you medelec35 (where is the thanx button???)

goingo

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: how to generate ulong variable in V4.5?

Post by medelec35 »

Hi goingo,
Glad it works for you :)

Attached is another version that counts up to 8355584 using just 1 byte and 1 int.
The idea being int counts up to 32767, then byte = byte +1 :int = 0 etc.
If you want 8 million seconds and using a calculator:
8000000/32767 = required bytes (disregard any decimal numbers)
X 32767= Required Integer

Buttons to press on a calculator:
8000000/32767 =
-244 =
X 32767
=
For 8 million seconds:
Byte = 244
Int= 4852

Hope I have made this clear enough?

To thank someone for a useful post:
You need to be logged in, then look for a thumbs up icon on the top right of the post that has been useful, and click on it.

Martin
Attachments
Upto8.3millionSecondsCounter1.fcf
(5 KiB) Downloaded 347 times
Martin

Post Reply