Executing programs - multitasking, Where n is the thread number – Yaskawa LEGEND-MC User Manual
Page 293
283
LEGEND-MC User’s Manual
Executing Programs - Multitasking
Two programs can run independently. The programs (threads) are numbered 0 through 3. 0 is the main
thread. The main thread differs from the others in the following points:
1. Only the main thread may use the input command, IN.
2. In a case of interrupts, due to inputs, limit switches, position errors or command errors, it is thread 0
which jumps to those subroutines.
The execution of the various programs is done with the 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 functions can be performed by an executing program.
Multitasking is useful for executing independent operations such as PLC functions that occur
independently of motion. The example below produces a waveform on Output 1 independent of a move.
The program above is executed with the instruction XQ #TASK2,0 which designates TASK2 as the main
thread. #TASK1 is executed within TASK2.
#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 time, 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