Dataq DI-159 User Manual page 57

Table of Contents

Advertisement

StickOS
Timers
StickOS supports up to four internal interval timers (0 thru 3) for use by the program. Timer
interrupts are delivered when the specified time interval has elapsed since the previous interrupt
was delivered.
Timer interrupt intervals are configured with the statement:
configure timer n for m (s|ms|us)
This configures timer n to interrupt every m seconds, milliseconds, or microseconds.
Note that the minimum timer resolution is the clock tick, which is 0.25 milliseconds.
The timer interrupt can then be enabled, and the statement(s) to execute when it is delivered
specified, with the statement:
on timer n statement
If statement is a "gosubsubname ...", then all of the statements in the corresponding sub are
executed when the timer interrupt is delivered; otherwise, just the single statement is executed.
The timer interrupt can later be completely ignored (i.e., discarded) with the statement:
off timer n
The timer interrupt can be temporarily masked (i.e., held off but not discarded) with the state-
ment:
mask timer n
And can later be unmasked (i.e., any pending interrupts delivered) with the statement:
unmask timer n
Examples
> 10 dim ticks
> 20 configure timer 0 for 1000 ms
> 30 on timer 0 do print "slow"
> 40 configure timer 1 for 200 ms
> 50 on timer 1 do gosub fast
> 60 sleep 3 s
> 70 print "ticks is", ticks
> 80 end
57
DI-159 PLC Hardware Manual

Advertisement

Table of Contents
loading

Table of Contents