This EasyStep will show you how to get timebase intervals other than the default 10mS, so you can easily generate very short or very long intervals.
Published, fittingly, on the 50th anniversary of the first episode of Doctor Who, the Time Lord.
The "SuperTimer" timing instructions all count time in intervals of 10mS. This allows you to generate delays from 10mS up to about 46 hours. There may however be occassions when you need intervals shorter than 10mS or longer than 46 hours. You can achieve this by changing the timebase to something other than the default 10mS. You can make the timers run up to 10 times faster or about 25 times slower than the default. In the EC1 the settability is individual per task, so you could have one task timing down to the millisecond and another generating an interval of 48 days in a single Pause instruction.
Here is a code snippet that will set the timebase of the current task only to 3mS
Here is a slightly different version that could easily be used to create a subroutine
Here is a complete program for the EC1. It simply flashes the two LEDs on the EC1 board, using two separate MultiTrack tasks. For the green LED it speeds up the timebase of the task by 10x (sets a 1mS timebase), but compensates by pausing for 1000 "units". For the red LED it uses the default timebase of 10mS, and it pauses for 100 units of time. The end result is that the two LEDs flash at the same rate.
The fact the two LEDs flash at the same rate proves that the timebase settings are independent per task.
The following program illustrates a subtle point. It has two tasks, as before, flashing two LEDs. This time, however, I generate the delays in a subroutine that is shared by the two tasks. Both tasks call the same subroutine, but get delays related to their individual timebase settings.
- The timers can generate intervals down to 1mS. However, it can take your program some time before it actually tests the timer for expiration. This is called latency, and is a function of how much other work the program is doing.