Basic programming guide – Remote Processing BASIC for the CX-10 Modbus User Manual

Page 47

Advertising
background image

BASIC PROGRAMMING GUIDE

2-38

ONTICK

Syntax:

ONTICK time,line number
Where: time = time interval from 0.01 to 327

line number = line to branch

Function:

Calls subroutine at line number every time interval.

Mode:

Run

Use:

ONTICK 1.25,500

DESCRIPTION

ONTICK calls a subroutine every time interval. time ranges from 0.010 seconds to 327.7 seconds
(approximately 5.5 minutes). time can be specified in increments as small as 0.005 seconds. ONTICK
interrupts are turned off when time = 0. A line number must still be provided even though it is not used.

The interval period can be reset at any time in a program. When an ONTICK statement is executed, an
interrupt will occur in time seconds. Time accumulated since the last interrupt is discarded.

NOTE: Use the RETI command to exit this subroutine. Failure to do so prevents future ONTICK interrupts.

Make sure your ONTICK subroutine can finish before the next interrupt. If the program is in the subroutine
longer than the specified time interval, the next one will be missed.

This interrupt has the highest priority of any others. ONITR can interrupt any other routine, but no other
interrupt can take over this one.

RELATED

RETI

ERRORS

BAD ARGUMENT When time > 327.6 or negative
BAD SYNTAX

When any parameters left out

INVALID LINE

When line number not found

EXAMPLE

The following example will interrupt 5 times before it is canceled at line 220.

10 A = .15
20 ONTICK A,200
30 IF C<4 THEN A=A+1 : GOTO 30
40 END
200 PRINT A
210 C = C + 1
220 IF C = 5 THEN ONTICK 0,200
230 RETI

>run

145.15
286.15
431.15
575.15

The IDLE command may be used to "wait" for an ONTICK interval interrupt.

Advertising