
814
Subroutines
Section 3-19
In contrast, a differentiated instruction (UP, DOWN, DIFU(013) or DIFD(014))
would maintain the ON status if the instruction was executed and the output
was turned ON but the same subroutine was not called a second time.
In the following example, subroutine 0001 is executed if CIO 000000 is ON.
Output CIO 000100 is turned ON by DIFU(013) when CIO 000001 has gone
from OFF to ON. If CIO 000000 is OFF in the following cycle, subroutine
0001 will not be executed again and output CIO 000100 will remain ON.
Flags
Precautions
Each subroutine must have a unique subroutine number. Do not use the same
subroutine number for more than one subroutine.
SBS(091) and the corresponding SBN(092) must be programmed in the same
task. An error will occur if the corresponding SBN(092) is not in the task.
SBS(091) will be treated as NOP(000) when it is within a program section
interlocked by IL(002) and ILC(003).
When SBS(091) is executed in the following cases, the subroutine will not
actually be called and the Error Flag will be turned ON:
1,2,3...
1.
The specified subroutine is not defined within the current task.
2.
The subroutine is calling itself.
3.
Subroutine nesting exceeds 16 levels.
4.
The specified subroutine is being executed.
Examples
Example 1: Sequential (Non-nested) Subroutines
When CIO 000000 is ON in the following example, subroutine 1 is executed
and program execution returns to the next instruction after SBS(091). The
remainder of the main program (through the instruction just before SBN(092)
1) is then executed.
1
3
2
1
1
000100
The subroutine is not executed
in following cycles.
Name
Label
Operation
Error Flag
ER
ON if nesting exceeds 16 levels.
ON if the specified subroutine number does not exist.
ON if a subroutine calls itself.
ON if a subroutine being executed is called.
ON if the specified subroutine is not defined in the current
task.
OFF in all other cases.
Summary of Contents for SYSMAC CS Series
Page 2: ......
Page 4: ...iv ...
Page 30: ...xxx ...
Page 186: ...146 List of Instructions by Function Code Section 2 4 ...
Page 1320: ...1280 Model Conversion Instructions Unit Ver 3 0 or Later Section 3 35 ...
Page 1390: ...1350 CJ series Instruction Execution Times and Number of Steps Section 4 2 ...
Page 1391: ...1351 Appendix A ASCII Code Table ASCII SP Four leftmost bits Four rightmost bits ...
Page 1392: ...1352 ASCII Code Table Appendix A ...
Page 1404: ...1364 Revision History ...