5-17
5 Understanding Programming
CJ2 CPU Unit Software User’s Manual
5-2 Tasks
5
5-2-2 Cyclic Tasks
z Task Control Instructions
Use the Task Control Instructions to start or stop a cyclic task from a program. The instructions used
to start and stop tasks depend on the programming language as shown in the following list.
• TASK ON and TASK OFF Instructions
The TASK ON and TASK OFF instructions can be used to change any cyclic task between READY
and STANDBY status at any time. A cyclic task that is in READY status will maintain that status in
subsequent cycles, and a cyclic task that is in STANDBY status will maintain that status in subse-
quent cycles. The TASK ON and TASK OFF instructions can be used only in cyclic tasks. They can-
not be used in interrupt tasks.
Note At least one cyclic task must be in READY status in each cycle. If there is no cyclic task in
READY status, the Task Error Flag (A295.12) will turn ON, and the CPU Unit will stop.
Using Cyclic Tasks
• Ladder programming and ST pro-
gramming:
TKON(820) (TASK ON instruction) and TKOF(821) (TASK OFF
instruction)
• SFC programming: SFCON(789) (SFC ON instruction) and SFCOFF(790) (SFC OFF
instruction)
TKON
N
TKOF
N
A task will go to READY status
when the execution condition is
ON. The corresponding Task Flag
will turn ON.
A task will go to STANDBY status
when the execution condition is
ON. The corresponding Task Flag
will turn OFF.
N = Task number
N = Task number
A
TKON 1
TKON 3
TKON 2
B
C
TKOF
D
1) Task 0 will go to
READY status at the start
of operation.
Other tasks will remain in
DISABLED status.
(Activated at the
start of operation)
2) Task 1 will go to
READY status if A
is ON, and tasks 2
and 3 will remain In
DISABLED status.
3) Task 0 will go to
STANDBY status if D
is ON.
Other tasks will
remain in their
current status.
: READY status
: STANDBY/DISABLED status
Cyclic task 1
Cyclic task 2
Cyclic task 3
Cyclic task 1
Cyclic task 2
Cyclic task 3
Cyclic task 0
Example: Cyclic Task
Cyclic task 0
Cyclic task 1
Cyclic task 2
Cyclic task 3
Cyclic task 0
Cyclic task 1
Cyclic task 2
Cyclic task 3
Cyclic task 0