ProSoft Technology MVI56-BAS User Manual

Page 221

Advertising
background image

MVI56-BAS ♦ ControlLogix Platform

Reference

BASIC Module (DB/BAS Compatible)

User Manual

ProSoft Technology, Inc.

Page 221 of 234

December 13, 2011

In order to enable the free running clock, the CLOCK1 statement must be used in

the BASIC program or in the Command Line. The real time clock starts running

until it is disabled by the CLOCK0 statement. The clock increments from 0 to

65535.995 seconds. When it reaches its maximum value, it will rollover to 0.
The current time value can be retrieved by the TIME statement which shows the

current time value. It is incremented once every 5 milliseconds. The TIME

statement can also be used to change the current time value.
For example (using the command line):

>CLOCK1
> PRINT TIME
45.655
> TIME = 0
>PRINT TIME
.115
>CLOCK0

There are also BASIC CALLs that allow the use of date and time information in

the BASIC programs. Refer to Wall Clock CALLs (page 137).
In order to compensate for the incompatibility between the timer in the

microprocessor and the MVI56-BAS, the ONTIME statement can be used. The

MVI56-BAS can operate a line in an order of milliseconds and the

microprocessor works in the order of microseconds. The ONTIME statement

generates an interrupt every time the TIME operator is equal or greater than the

expression following the ONTIME statement.

Example:

Ready
>list
10 TIME = 0
20 CLOCK1
30 ONTIME 2, 80
40 DO
50 WHILE TIME < 10
60 CLOCK0
70 END
80 PRINT "Timer interrupt at -", TIME, " seconds"
90 ONTIME TIME + 2, 80
100 RETI
Ready
>run
Timer interrupt at - 2.004 seconds
Timer interrupt at - 4.011 seconds
Timer interrupt at - 6.016 seconds
Timer interrupt at - 8.022 seconds
Ready
>

Advertising