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.
"Millis" timer (like in Arduino)
Moderator: Benj
- 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)
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.
- 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)
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- 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)
Ok didn't know that one.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.
Will check it out..
Thanks