"Millis" timer (like in Arduino)

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

Moderator: Benj

Post Reply
MJU
Posts: 502
Joined: Wed Nov 07, 2007 6:51 pm
Location: Antwerp Belgium
Has thanked: 121 times
Been thanked: 108 times
Contact:

"Millis" timer (like in Arduino)

Post by MJU »

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: 3422
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times
Contact:

Re: "Millis" timer (like in Arduino)

Post by Steve »

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.

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: "Millis" timer (like in Arduino)

Post by Benj »

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.

MJU
Posts: 502
Joined: Wed Nov 07, 2007 6:51 pm
Location: Antwerp Belgium
Has thanked: 121 times
Been thanked: 108 times
Contact:

Re: "Millis" timer (like in Arduino)

Post by MJU »

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

Post Reply