1057
3. Instructions
CS/CJ/NSJ Series Instructions Reference Manual (W474)
Block Programming Instructions
3
Block Programming Instructions
Tasks and Block Programs
Block programs can be located within tasks. While tasks are used to divide large programming units,
block programs can be used within tasks to further divide programming into smaller units controlled with
a single ladder diagram execution condition.
Just like tasks, block programs that are that are not executed (i.e., which have an OFF execution
condition) do not require execution time and can thus be used to reduce the cycle time (somewhat the
same as jumps). Also like tasks, other blocks can be paused or restarted from within a block program.
There are, however, differences between tasks and block programs. One difference is that input
conditions are not used with block programs unless intentionally programmed with IF(802), WAIT(805),
EXIT(806), IEND(810) or other instructions. Also, there are some instructions that cannot be used
within block programs, such as those that detect upward and downward differentiation.
Block programs can be used either within cyclic tasks or interrupt tasks. Each block program number
from 0 to 127 can be used only once and cannot be use again, even in a different task.
Using Block Programming Instructions
• Basically speaking, IF(802), ELSE(803), and IEND(810) are used for execution conditions (along with
bits) inside block programs.
If “A” or “B” is to be executed then IF A ELSE B IEND are used as shown below.
If “A” or nothing is to be executed, IF A IEND are used as shown below.
• If execution is to wait until an execution condition or bit is ON (e.g., for step progressions), then
WAIT(805) is used.
• If execution is to wait until for a specified period of time (e.g., for timed step progressions), then
TIMW(813), TIMX(816), TMHW(815), or TMHWX(817) is used.
Program
Block program 001
Block program n
Tas k 1
Tas k 2
Tas k n
"B" executed
(after ELSE).
"A" executed (be-
tween IF and ELSE).
Execution
condition ON?
Execution
condition
Execution
condition
Execution
condition ON?
"A" executed (be-
tween IF and IEND).