30
•
Chapter 7 Application Programming
CDS-3310
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 #POSERR or #LIMSWI) is executed, the subroutine
stack is incremented by 1. 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 a limit occurs and the #LIMSWI
routine is executed, it is often desirable to restart the program sequence instead of returning to the
location where the limit occurred. To do this, give a ZS command at the end of the #LIMSWI routine.
Auto-Start Routine
The CDS-3310 has a special label for automatic program execution. A program which has been saved
into the controllers non-volatile memory can be automatically executed upon power up or reset by
beginning the program with the label #AUTO. 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 CDS-3310
program sequences. The CDS-3310 can monitor several important conditions in the background.
These conditions include checking for the occurrence of a limit switch, a defined input, position error,
or a command error. Automatic monitoring is enabled by inserting a special, predefined label in the
applications program. The pre-defined labels are:
SUBROUTINE DESCRIPTION
#LIMSWI
Limit switch on any axis goes low
#ININT
Input specified by II goes low
#POSERR
Position error exceeds limit specified by ER
#MCTIME
Motion complete timeout occurred. Timeout period set by TW command
#COMINT Communication
interrupt
#CMDERR
Bad command given
#TCPERR
TCP/IP communication error
#AMPERR Amplifier
error
#AUTOERR
Label for checksum error on power up. See _RS.
For example, the #POSERR subroutine will automatically be executed when any axis exceeds its
position error limit. The commands in the #POSERR subroutine could decode which axis is in error
and take the appropriate action. In another example, the #ININT label could be used to designate an
Instruction Interpretation
#M
Begin Main Program
CB1
Clear Output Bit 1
JS #MySub
Jump to square subroutine
EN
End Main Program
#MySub subroutine
MG “In subroutine”
EN End
subroutine
Содержание CDS-3310
Страница 26: ...18 i Chapter 2 Getting Started CDS 3310 THIS PAGE LEFT PLANK INTENTIONALLY...
Страница 32: ...24 i Chapter 3 Connecting I O CDS 3310 THIS PAGE LEFT PLANK INTENTIONALLY...
Страница 124: ...CDS 3310 Chapter 8 Hardware Software Protection i 63 THIS PAGE LEFT PLANK INTENTIONALLY...
Страница 138: ...CDS 3310 Chapter 10 Theory of Operation i 77 THIS PAGE LEFT BLANK INTENTIONALLY...