beautypg.com

Clock1 – Rockwell Automation 1771-DB BASIC MODULE User Manual

Page 157

background image

Chapter
Statements

11

11 -5

Use the CLOCK1 statement to enable the free running clock resident on
the BASIC module. The special function operator TIME (page 9 -19)
increments once every 5 milliseconds after you execute CLOCK1.
CLOCK1 uses an internal timer to generate an interrupt once every
5 milliseconds. Because of this, the special function operator TIME has a
resolution of 5 milliseconds. The special function operator TIME counts
from 0 to 65535.995 seconds. After reaching a count of 65535.995
seconds TIME overflows back to a count of 0. The interrupts associated
with CLOCK1 cause the module programs to run at about 99.6% of normal
speed. This means that the interrupt handling for the free running clock
uses about 0.4% of the total CPU time.

Important: This does not include additional overhead for ONTIME user
interrupt handling execution.

Syntax

CLOCK1

Example

>10 TIME = 0

>15 DBY(71) = 0 :REM RESET NONINTEGER PORTION OF TIME

>20 CLOCK1

>30 ONTIME 2,100

>40 DO

>50 WHILE TIME < 10

>60 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.015 SECONDS

TIMER INTERRUPT AT – 6.01 SECONDS

TIMER INTERRUPT AT – 8.01 SECONDS

TIMER INTERRUPT AT – 10.01 SECONDS

CLOCK1