Page 1 of 1

how to generate ulong variable in V4.5?

Posted: Sat Jan 05, 2013 11:02 pm
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

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

Posted: Sun Jan 06, 2013 12:41 am
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

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

Posted: Sun Jan 06, 2013 12:59 pm
by goingo
wonderful it works perfect :D
many thanx to you medelec35 (where is the thanx button???)

goingo

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

Posted: Sun Jan 06, 2013 2:26 pm
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