Data AcQuisition And Real-Time AnalysisScope - Spectrum - Spectrogram - Signal Generator
Software for Windows
Science with your Sound Card!
Contact us about
WaitCyclic Timer Macros
There are 10 independent WaitCyclic Timer Macros, WaitCyclic0 through WaitCyclic9. Like WaitSecs, each can accept entries in seconds or H:M:S format, and is limited to a cycle of just over 1193 hrs or 49.7 days.
For tasks that must be repeated at standard unit intervals like each month, week, day, hour, minute, or second, the preceding WaitTime command is ideal. But there is no way to use it to repeat a task every 15 minutes for an hour, for example. Depending on the task and the required resolution, you might use WaitSecs=15:00 to delay for 15 minutes between each repetition. But that assumes that the task itself takes no time to complete; in reality, the schedule would slip farther and farther behind.
WaitCyclic0=15:00, on the other hand, will repeat each 15 minutes, regardless of how long the task takes, as long as it takes somewhat less than 15 minutes. Typically, you would put this at the start of the macro that performs the test, and call that macro in a loop. Suppose the macro is called _TestQuarter and defined as:
WaitCyclic0=15:00 ;Wait for next 15-minute mark @_MyTest ;Do test
Now we call it in a loop, here preceded by WaitTime so that the test sequence begins at noon:
WaitTime=@12:00 ;Wait for noon @_TestQuarter=5 ;Run 5 times, 12:00-1:00 PM WaitCyclic0=0 ;Stop timer when done
The first time _TestQuarter is called, WaitCyclic0=15:00 sets a repeating interval timer for a 15 minute cycle and then runs _MyTest immediately. That is the end of the first pass through _TestQuarter.
On the next pass, WaitCyclic0=15:00 checks that the specified interval is unchanged from the last time it was called. If it is the same, as in this example, that means the interval timer is running, so macro processing is suspended until the current 15 minute cycle ends. Then _MyTest is run again, and the loop repeats.
Since the first pass through _TestQuarter was at noon, _MyTest runs at 12:00, 12:15, 12:30, 12:45, and 1:00 PM.
That timing results from the fact that the WaitCyclic0 timers doesn't wait the first time it is called, just sets the timer for the next pass. If, on the other hand, you want it to wait on the first pass, put a 'W' before the time value, as in WaitCyclic0=W15:00. That will result in _MyTest being run at 12:15, 12:30, 12:45, 1:00, and 1:15 PM.
Note that you should always stop a WaitCyclic timer when you are done using it, by setting its interval to 0. Not only does this prevent needless timer service interrupts, it also insures that the next time you use that timer you start fresh without a delay (assuming no 'W') if the next interval is the same.
On the other hand, if you want a subsequent test series to continue on the same interval schedule as the first, omit the reset until you are completely done with that schedule.
The avalability of 10 independent WaitCyclic timers allows construction of very complex timing schedules. These can be combined with recurring WaitTime intervals (as in the example above that waits for noon).
In general, WaitTime will give slightly greater accuracy over long periods composed of many short intervals, because it has higher initial resolution, and because it does not accumulate small errors like WaitCyclic can. The difference is like keeping time with a clock versus a stopwatch:
In this case the WaitTime "clock" has a high long-term accuracy, typically similar to a good digital watch. It can be the same as an "atomic" clock on systems that are connected to the internet regularly and have the "Internet Time" option set in Windows. Note, however, that any individual reading may be off by 10-15 msec (more on Win9x).
The WaitCyclic "stopwatch" has the same 10-15 msec resolution on each interval it times, not only for reading it but also for setting it as well. If you set a cycle of 1 minute and it is really 10 msec greater, that's an error of 0.0167 percent; not significant for most uses. But if you put it in a loop to count minutes, it will be off by 1 second after only 100 minutes.
Another difference between WaitTime and WaitCyclic is that the WaitTime clock is maintained between sessions, even when your computer is turned off. The WaitCyclic intervals must be re-synchronized each session (and preferably at each use), if you want intervals to start at particular clock times.
Questions? Comments? Contact us!We respond to ALL inquiries, typically within 24 hrs.
Over 30 Years of Innovative Instrumentation
© Copyright 2007 - 2020 by Interstellar Research
All rights reserved