User guide

Chapter 1. Programming Fundamentals
29
Program Interrupts
(ON Conditions)
While executing a program, the 6000 controller can interrupt the program based on several
possible ON conditions: programmable input(s) status, user status, or the value of numeric
variables #1 or #2. These ON conditions are enabled with the ONCOND command, and are
defined with the commands listed below. After the ON conditions are enabled (with the
ONCOND command), an ON condition interrupt can occur at any point in program execution.
When an ON condition occurs, the controller performs a GOSUB to the program assigned as
the ON program and then passes control back to the original program and resumes command
execution at the command line from which the interruption occurred.
Within the ON program, the programmer is responsible for checking which ON condition
caused the branch (if multiple ON conditions are enabled with the ONCOND command). Once
a branch to the ON program occurs, the ON program will not be called again until after it has
finished executing. After returning from the ON program, the condition that caused the branch
must evaluate false before another branch to the ON program will be allowed.
SETUP FOR PROGRAM INTERRUPT (see programming example below)
1. Defined a program to be used as the ON program to which the controller will GOSUB when
an ON condition evaluates true.
2. Use the ONP command to assign the program as the ON program.
3. Use the ONCOND command to enable the ON conditions that you are using. The syntax
for the ONCOND command is ONCOND<b><b><b><b>, where the first <b> is for the ONIN
condition, the second for ONUS, the third for ONVARA, and the fourth for ONVARB.
ON conditions:
ONIN ............ Specify an input bit pattern that will cause a GOSUB to the program
assigned as the ON program (see programming example below).
ONUS ............ Specify an user status bit pattern that will cause a GOSUB to the ON
program. The user status bits are defined with the INDUST command.
ONVARA ........ Specify the range of numeric variable #1 (VAR1) that will cause a GOSUB
to the ON program. For example, ONVARAØ,2Ø establishes the condition
that if the value of VAR1 is 0 or 20, the ON program will be called.
ONVARB ........ This is the same function as ONVARA, but for numeric variable #2 (VAR2)
Programming Example: Configures the controller to increment variable #1 when input #1 goes active. If
input #1 does go active, control will be passed (GOSUB) to the ON program (onjump), the commands within
the ON program will be executed, and control will then be passed back to the original program.
DEF onjump ; Begin definition of program onjump
VAR1=VAR1+1 ; Increment variable 1
END ; End definition of program onjump
VAR1=0 ; Initialize variable 1
ONIN1 ; When input 1 becomes active, branch to the ON program
ONP onjump ; Assign the onjump program as the ON program
ONCOND1000 ; Enable only the ONIN function. Disable the ONUS, ONVARA,
; and ONVARB functions, respectively
Situations in which
ON conditions WILL
NOT interrupt
immediately
These are situations in which an ON condition does not immediately interrupt the program in
progress. However, the fact that the ON condition evaluated true is retained, and when the
condition listed below is no longer preventing the interrupt, the interrupt will occur.
While motion is in progress due to GO, GOL, GOWHEN, HOM, JOY, JOG, or PRUN and the
continuous command execution mode is disabled (COMEXCØ).
While a WAIT statement is in progress
While a time delay (T) is in progress
While a program is being defined (DEF)
While a pause (PS) is in progress
While a data read (DREAD, DREADF, or READ) is in progress