703
3. Instructions
CS/CJ/NSJ Series Instructions Reference Manual (W474)
Subroutines
3
GSBS
• 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 global subroutine was not
called a second time.
In the following example, global subroutine 1 is executed if CIO 0.00 is ON. Output CIO 1.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 1 will not be executed again and output CIO 1.00 will remain ON.
Example Programming
When CIO 0.00 is ON in the following example,
global subroutine 1 is executed and program
execution returns to the next instruction after
GSBS(750).
When CIO 0.01 is ON in the following example,
global subroutine 1 is executed and program
execution returns to the next instruction after
GSBS(750).
GSBS
1
0.00
GSBN
1
DIFU
100
0.01
GRET
Cyclic task 1
Interrupt task 0
The subroutine is
not executed in
following cycles.
GSBN
1
END
B
GSBS
n
A
0.00
GRET
END
END
D
GSBS
n
C
0.01
CIO 0.00 ON
Cyclic or interrupt task Cyclic or interrupt task
Interrupt task 0
Global
subroutine
program S
CIO 0.01 ON
Status of CIO
0.00
Order of program
execution
ON A → S → B
OFF A → B
Status of CIO
0.01
Order of program
execution
ON C → S → D
OFF C → D