Page 1 of 1

"Millis" timer (like in Arduino)

Posted: Tue Dec 04, 2018 12:02 am
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.

Re: "Millis" timer (like in Arduino)

Posted: Tue Dec 04, 2018 9:23 am
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.

Re: "Millis" timer (like in Arduino)

Posted: Tue Dec 04, 2018 11:15 pm
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.

Re: "Millis" timer (like in Arduino)

Posted: Wed Dec 05, 2018 4:23 pm
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