"Millis" timer (like in Arduino)

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

Moderator: Benj

MJU
Posts: 449
Joined: Wed Nov 07, 2007 6:51 pm
Location: Antwerp Belgium
Has thanked: 113 times
Been thanked: 102 times
Contact:

"Millis" timer (like in Arduino)

Postby MJU » Tue Dec 04, 2018 12:02 am

I'm thinking about building a project where I need to measure time between several occurrences.

In the Arduino community there is a lot written about the "Millis-function".
After a quick look into this command it looks like it is a 32bit timer that is increased every millisecond.
This would be perfect for what I want to do.

After a startsignal I want to check two I/O's and find out which of the two has changed first and.. I want to check for these both I/O's how long after the startsignal they changed.

The elapsed time of the two I/O's should be measured but this hasn't has to be 100% accurate. (the time between the start and the end is I guess something about 30 seconds).

If this Millis timer could be used in Flowcode this would be great for this project.
Is there a way I can use it in Flowcode?

The last post about this function was in a forum post from 2016.

User avatar
Steve
Matrix Staff
Posts: 3111
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 89 times
Been thanked: 398 times
Contact:

Re: "Millis" timer (like in Arduino)

Postby Steve » Tue Dec 04, 2018 9:23 am

My suggestion is to create a global variable representing this "tick" count and use a timer interrupt to increment it by 1 each millisecond (i.e. set the interrupt frequency to 1 kHz). You should then be able to read the value of this variable (or even reset it to zero) whenever you wanted in your main program thread.
These users thanked the author Steve for the post:
medelec35 (Fri Dec 14, 2018 4:01 pm)
Rating: 5%
 

User avatar
Benj
Matrix Staff
Posts: 14681
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4665 times
Been thanked: 4287 times
Contact:

Re: "Millis" timer (like in Arduino)

Postby Benj » Tue Dec 04, 2018 11:15 pm

The timer component in the storage category should do a similar job to the Arduino function and you can choose your timer via the properties.
These users thanked the author Benj for the post:
medelec35 (Fri Dec 14, 2018 4:02 pm)
Rating: 5%
 

MJU
Posts: 449
Joined: Wed Nov 07, 2007 6:51 pm
Location: Antwerp Belgium
Has thanked: 113 times
Been thanked: 102 times
Contact:

Re: "Millis" timer (like in Arduino)

Postby MJU » Wed Dec 05, 2018 4:23 pm

Benj wrote:The timer component in the storage category should do a similar job to the Arduino function and you can choose your timer via the properties.


Ok didn't know that one.
Will check it out..

Thanks
These users thanked the author MJU for the post:
Benj (Wed Dec 05, 2018 5:47 pm)
Rating: 5%