TEMP=@IN[1]|@IN[2]
TEMP is equal to 1 if either Input 1 or Input 2 is high
JS#COND, TEMP=1
Jump to subroutine if TEMP equals 1
JP#LOOP
Loop back if TEMP doesn’t equal 1
EN
End of main program
#COND
Begin subroutine “COND”
IF (@IN[1]=0)
IF conditional statement based on input 1
2
nd
IF conditional statement executed if 1
st
IF
conditional true
IF (@IN[2]=0)
Message to be executed if 2
nd
IF conditional is true
MG "INPUT 1 AND INPUT 2 ARE
INACTIVE"
ELSE command for 2
nd
IF conditional statement
ELSE
Message to be executed if 2
nd
IF conditional is false
MG "ONLY INPUT 1 IS ACTIVE”
End of 2
nd
conditional statement
ENDIF
ELSE command for 1
st
IF conditional statement
ELSE
Message to be executed if 1
st
IF conditional statement
MG"ONLY INPUT 2 IS ACTIVE"
End of 1
st
conditional statement
ENDIF
#WAIT
Label to be used for a loop
JP#WAIT,(@IN[1]=0) & (@IN[2]=0)
Loop until both input 1 and input 2 are not active
EN
End of subroutine
Stack Manipulation
It is possible to manipulate the subroutine stack by using the ZS command. Every time a JS instruction,
interrupt or automatic routine (such as #ININTn or #CMDERR) is executed, the subroutine stack is
incremented by 1 (up to a maximum of 16). Normally the stack is restored with an EN instruction.
Occasionally it is desirable not to return back to the program line where the subroutine or interrupt was
called. The ZS1 command clears 1 level of the stack. This allows the program sequencer to continue to the
next line. The ZS0 command resets the stack to its initial value. For example, if an interrupt occurs and the
#ININT1 routine is executed, it may be desirable to restart the program sequence instead of returning to the
location where the interrupt occurred. To do this, give a ZS (ZS0) command at the end of the #ININT1
routine.
Auto-Start Routine
The RIO has a special label for automatic program execution. A program that has been saved into the RIO
non-volatile memory can be automatically executed upon power up or reset, simply by beginning the
program with the label #AUTO.
Note:
The program must be saved into non-volatile memory using the command, BP.
Automatic Subroutines for Monitoring Conditions
Often it is desirable to monitor certain conditions continuously without tying up the host or RIO program
sequences. The RIO can monitor several important conditions in the background. These conditions include
checking for the occurrence of a defined input, position error, a command error, or an Ethernet
communication error. Automatic monitoring is enabled by inserting a special, predefined label in the
applications program. The pre-defined labels are:
SUBROUTINE DESCRIPTION
#AUTO
Automatic Program Execution on power up
#AUTOERR
Automatic Program Execution on power up if error condition occurs
#ININTn
Input specified by II goes low (n from 0 to 3)
#CMDERR
Bad command given
RIO-47xxx
Chapter 5 Programming
●
59