FX Series Programmable Controlers Applied Instructions 5
5-7
5.1.2 CALL (FNC 01)
Points to note:
a) Man
CALL statements can reference a sin
le subroutine.
b) Each subroutine must have a unique pointer number. Subroutine pointers can be selected
from the ran
e P0 to P62. Subroutine pointers and the pointers used for CJ (FNC 00)
instructions are NOT allowed to coincide.
c) Subroutines are not normall
processed as the
occur after an FEND instruction. When
the
are called, care should be taken not to overrun the watchdo
timer settin
. For more
information on watchdo
timers please see pa
e 5-12.
d) Subroutines can be nested for 5 levels includin
the initial CALL instruction. As an example the
pro
ram shown opposite shows a 2 level nest.
When X1 is activated the pro
ram calls subroutine
P11. Within this subroutine is a CALL to a second
subroutine P12. When both subroutines P11 and
P12 are active simultaneousl
, the
are said to be
nested. Once subroutine P12 reaches its SRET
instruction it returns the pro
ram control to the
pro
ram step immediatel
followin
its ori
inal
CALL (see
). P11 then completes its operation,
and once its SRET instruction is processed the
pro
ram returns once a
ain to the step followin
the CALL P11 statement (
see
).
Mnemonic Function
Operands
Program steps
D
CALL
FNC 01
(
C
all sub-
routine
Executes the
subroutine
pro
ram startin
at the identified
pointer position
Valid pointers from the ran
e 0 to 62
Nest levels: 5 includin
the initial CALL
CALL, CALLP:
3 step
Subroutine pointer
P
PP
: 1 steps
X0
P 10CALL
FEND
SRET
P10
[ D ]
Subroutine D10
Operation:
When the CALL instruction is active it forces the
pro
ram to run the subroutine associated with the
called pointer (area identified as subroutine P10). A
CALL instruction must be used in con
unction with
FEND (FNC 06) and SRET (FNC 02) instructions. The
pro
ram
umps to the subroutine pointer (located after
an FEND instruction) and processes the contents until
an SRET instruction is encountered. This forces the
pro
ram flow back to the line of ladder lo
ic
immediatel
followin
the ori
inal CALL instruction.
X1
P 11CALL
FEND
SRET
P11
P 12CALL
SRET
P12
1
2