671
Subroutines Section 3-18
Subroutines and
Differentiation
Observe the following precautions when using differentiated instructions
(DIFU(013), DIFU(014), or up/down differentiated instructions) in subroutines.
The operation of differentiated instructions in a subroutine is unpredictable if a
subroutine is executed more than once in the same cycle. In the following
example, subroutine 0001 is executed when CIO 0.00 is ON and CIO 100.00
is turned ON by DIFU(013) when CIO 0.01 has gone from OFF to ON. If
CIO 0.01 is ON in the same cycle, subroutine 0001 will be executed again but
this time DIFU(013) will turn CIO 100.00 OFF without checking the status of
CIO 0.01.
In contrast, the output of a differentiated instruction (DIFU(013) or DIFD(014))
would remain ON 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 0.00 is ON. Out-
put CIO 100.00 is turned ON by DIFU(013) when CIO 0.01 has gone from
OFF to ON. If CIO 0.00 is OFF in the following cycle, subroutine 0001 will not
be executed again and output CIO 100.00 will remain ON.
Flags
1
3
2
4
5
1
1
1
0.00
0.01
0.01
100.00
Subroutine
0001
The subroutine is
executed again.
1
3
2
1
1
100.00
0.00
0.01
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.