Ontime – Rockwell Automation 1771-DB BASIC MODULE User Manual

Page 177

Advertising
background image

Chapter
Statements

11

11 -25

Use the ONTIME expr, ln num statement to compensate for the
incompatibility between the timer/counters on the microprocessor and the
BASIC module. Your BASIC module can process a line in milliseconds
while the timer/counters on the microprocessor operate in microseconds.
The ONTIME statement generates an interrupt every time the special
function operator, TIME (page 9 -19), is equal to or greater than the
expression following the ONTIME statement.

Only the integer portion of TIME is compared to the integer portion of the
expression that gives you seconds. This comparison is performed at the
end (CR or : ) of each line of BASIC. The interrupt forces a GOSUB
(page 11 -13) to the line number after the expression in the ONTIME.

The ONTIME statement does not interrupt an input command or a call
routine. Since the ONTIME statement uses the special function operator,
TIME, you must execute the CLOCK1 statement (page 11 -5) for
ONTIME to operate. If CLOCK1 is not executed the special function
operator, TIME, does not increment.

To execute the ONTIME interrupt at a fraction of a second use the special
function operator DBY(71) = X (page 9 -18) where X = 0 to 200.
Each count represents a 5 millisecond time interval.

Syntax

ONTIME

expr, ln num

Example

>10 TIME = 0

>15 DBY(71) = 0

>20 CLOCK1

>30 ONTIME 2,100

>40 DO

>50 WHILE TIME < 7

>60 CLOCK0

>70 END

>100 PRINT “TIMER INTERRUPT AT – ”,TIME, “ SECONDS”

>110 ONTIME TIME+2,100

>120 RETI

READY

>RUN

TIMER INTERRUPT AT – 2.01 SECONDS

TIMER INTERRUPT AT – 4.005 SECONDS

TIMER INTERRUPT AT – 6.015 SECONDS

The time printed out is .01 seconds later than the time supposed to be
printed. The terminal used in the example operates at 19200 bit/s causing
a .01 second delay in printing

ONTIME

Advertising