20
•
Chapter 7 Application Programming
CDS-3310
1. Only the main thread, thread 0, may use the input command, IN.
2. When automatic subroutines are implemented for limit switches, position errors or command errors,
they are executed in thread 0.
To begin execution of the various programs, use the following instruction:
XQ #A, n
Where n indicates the thread number. To halt the execution of any thread, use the instruction
HX
n
where n is the thread number.
Note that both the XQ and HX commands can be performed by an executing program.
The example below produces a waveform on Output 1 independent of a move.
Instruction Interpretation
#TASK1 Task1
label
AT0
Initialize reference time
CB1
Clear Output 1
#LOOP1 Loop1
label
AT 10
Wait 10 msec from reference time
SB1
Set Output 1
AT -40
Wait 40 msec from reference, then initialize reference
CB1
Clear Output 1
JP #LOOP1
Repeat Loop1
#TASK2 Task2
label
XQ #TASK1,1
Execute Task1
#LOOP2 Loop2
label
PR 1000
Define relative distance
BGX Begin
motion
AMX
After motion done
WT 10
Wait 10 msec
JP #LOOP2,@IN[2]=1
Repeat motion unless Input 2 is low
HX Halt
all
tasks
The program above is executed with the instruction XQ #TASK2,0 which designates TASK2 as the
main thread (ie. Thread 0). #TASK1 is executed within TASK2.
Debugging Programs
The CDS-3310 provides commands and operands which are useful in debugging application programs.
These commands include interrogation commands to monitor program execution, determine the state
of the controller and the contents of the controllers program, array, and variable space. Operands also
contain important status information which can help to debug a program.
Trace Command
The trace command causes the controller to send each line in a program to the host computer
immediately prior to execution. Tracing is enabled with the command, TR1. TR0 turns the trace
function off.
Summary of Contents for CDS-3310
Page 26: ...18 i Chapter 2 Getting Started CDS 3310 THIS PAGE LEFT PLANK INTENTIONALLY...
Page 32: ...24 i Chapter 3 Connecting I O CDS 3310 THIS PAGE LEFT PLANK INTENTIONALLY...
Page 124: ...CDS 3310 Chapter 8 Hardware Software Protection i 63 THIS PAGE LEFT PLANK INTENTIONALLY...
Page 138: ...CDS 3310 Chapter 10 Theory of Operation i 77 THIS PAGE LEFT BLANK INTENTIONALLY...