![Omron CJ1G-CPUxx Instructions Manual Download Page 743](http://html1.mh-extra.com/html/omron/cj1g-cpuxx/cj1g-cpuxx_instructions-manual_742491743.webp)
722
Subroutines
Section 3-19
Note A subroutine can be called more than once in a program.
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 000000 is ON and
CIO 000100 is turned ON by DIFU(013) when CIO 000001 has gone from
OFF to ON. If CIO 000001 is ON in the same cycle, subroutine 0001 will be
executed again but this time DIFU(013) will turn CIO 000100 OFF without
checking the status of CIO 000001.
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 wasn’t 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 won’t be executed again and output CIO 000100 will remain ON.
1
3
2
4
5
Subroutine
0001
The subroutine is
executed again.
1
1
1
1
3
2
The subroutine is not executed
in following cycles.
1
1
000100
Summary of Contents for CJ1G-CPUxx
Page 3: ...iv N o t i c e ...
Page 5: ...vi ...
Page 21: ...xxii Conformance to EC Directives 6 ...
Page 35: ......
Page 1131: ...1110 CJ series Instruction Execution Times and Number of Steps Section 4 2 ...