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
how to generate ulong variable in V4.5?
Moderator: Benj
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: how to generate ulong variable in V4.5?
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
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
Re: how to generate ulong variable in V4.5?
wonderful it works perfect
many thanx to you medelec35 (where is the thanx button???)
goingo
many thanx to you medelec35 (where is the thanx button???)
goingo
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: how to generate ulong variable in V4.5?
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
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 361 times
Martin