Push, Push -15, Example – Rockwell Automation 1746-BAS BASIC LANGUAGE User Manual

Page 111: Purpose

Advertising
background image

Publication 1746-RM001A-US-P

Execution Control and Interrupt Support Functions 8-15

Example

>1

REM EXAMPLE PROGRAM

>10

TIME = 0

>15

DBY(71) = 0

>20

CLOCK1

>30

ONTIME 2,100

>40

DO

>50

WHILE TIME < 10

>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

TIMER INTERRUPT AT - 8.01 SECONDS

TIMER INTERRUPT AT - 10.01 SECONDS

In the example above, the time printed out is .01 seconds later than the time that
was supposed to be printed. This is caused by the terminal used in the example
operating at 19200 baud which causes a .01 second delay in printing.

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

PUSH

Purpose

Use the PUSH statement to place the arithmetic expression or expressions in the
module argument stack. This statement evaluates the arithmetic expression, or
expressions, following the PUSH statement and then places them in sequence on
the argument stack.

The PUSH and POP statements provide a simple means of passing parameters to
CALL routines. In addition, the PUSH and POP statements are used to pass
parameters to BASIC subroutines and to SWAP variables. The last value PUSHed
onto the argument stack is the first value POPped off the argument stack.

Advertising