4-128 Multitask function
4MELFA-BASIC V
4.3.4 Precautions for creating multitask program
(1) Relationship between number of tasks and processing time
During multitask operation, it appears as if several robot programs are being processed concurrently. How-
ever, in reality, only one line is executed at any one time, and the processing switches from program to pro-
gram (it is possible to change the number of lines being executed at a time. See the section for the "SLTn"
parameter in Page 438, "5 Functions set with parameters"). This means that if the number of tasks
increases, the overall program execution time becomes longer. Therefore, when using multitask operation,
the number of tasks should be kept to a minimum. However, programs of other tasks executing movement
instructions (the Mov and Mvs instructions) are processed at any time.
(2) Specification of the maximum number of programs executed concurrently
The number of programs to be run in parallel is set with parameter TASKMAX. (The default value is 8.) To
run more than 8 programs in parallel, change this parameter.
(3) How to pass data between programs via external variables
Data is passed between programs being executed in multitask operation via program external variables
such as M_00 and P_00 (refer to Page 144, "4.4.22 External variables") and the user-defined external vari-
ables (refer to Page 145, "4.4.24 User-defined external variables").
An example is shown below. In this example, the on/off status of input signal 8 is judged by the program
specified in task slot 2. Then this program notifies the program specified in task slot 1 that the signal is
turned on by means of the external variable M_00.
(4) Confirmation of operating status of programs via robot status variables
The status of the program running with multitask can be referred to from any slot using the robot status vari-
ables (M_Run, M_Wai, M_Err).
Example) M1 = M_Run (2) The operation status of slot 2 is obtained.
Refer to Page 155, "4.6 Robot status variables" for details on the robot status variables.
(5) The program that operates the robot is basically executed in slot 1.
The program that describes the robot arm's movement, such as with the Mov commands, is basically set
and executed in slot 1. To run the program in a slot other than slot 1, the robot arm acquisition and release
command (GetM, RelM) must be used. Refer to Page 168, "4.13 Detailed explanation of command words"
in this manual for details on the commands.
<Slot 1>
1 M_00=0 ; Substitute 0 in M_00
2 *L
3 If M_00=0 Then *L ; Wait for M_00 value to change from 0.
4 M_00=0 ; Substitute 0 in M_00
5 Mov P1 ; Proceed with the target work.
6 Mov P2
:
10 GoTo *L ; Repeat from step 2.
<Slot 2> (Program of signals and variables)
1 If M_In(8) <> 1 Then *A1 ; Branch to line 30 if input signal 8 is not ON.
2 M_00=1 ; Substitute 1 in M_00
3 *A1
4 Mov P1 ; Proceed with the target work.
: