Home / Experiments / Timing is everything!

Timing is everything!

Programming the NXT is nice.  However, sometimes you run into limits that you think shouldn’t be there.  This morning I hit one of those and scratched my head: “How to fix this?”.  Normally there are 4 timers at your disposal in ROBOTC (this also goes for NXC, as far as I am aware of).  I am not sure why we only get 4 of them and why not, say, 10. 

My BobBot Mk2 needs quite a number of timers and reusing the 4 at my disposal isn’t really an option.  I had an itch and it needed scratching.  This is how most programs get started, it’s the reason the driver suite came to be.  So, after a little fiddling and fumbling, I present to you: TMR-driver.h and a little test program.  These two will become part of the next release of the driver suite, so they may be subject to change without notice and all that. 

The usage should be fairly straightforward, the example program uses two timers to make the NXT beep at different intervals.

Please note that there is no roll-over checking done at all.  So if you plan to run your program for more than 596 hours straight, prepare for some weirdness. 

You can download the code here: [LINK]. (version 0.2)

Edit: Link has been changed to  version 0.2.  The separate task is gone now and code has been cleaned up a bit more.

About Xander

Xander Soldaat is a Software Engineer and former Infrastructure Architect. He loves building and programming robots. He recently had the opportunity to turn his robotics hobby into his profession and has started working for Robomatter, the makers of ROBOTC and Robot Virtual Words.