Mitsubishi Electronics Mitsubishi Digital Electronics Video Gaming Accessories FX3G ユーザーズマニュアル

ページ / 936
225
FX
3G
/FX
3U
/FX
3UC
 Series Programmable Controllers
Programming Manual - Basic & Applied Instruction Edition
8 Program Flow – FNC 00 to FNC 09
8.2 FNC 01 – CALL / Call Subroutine
1
In
trodu
ct
ion
2
O
ver
vi
ew
3
In
st
ru
ct
ion 
Li
st
4
D
evices 
in D
etail
5
Specifi
ed t
he
D
evice &
 
C
onst
ant
6
Bef
ore 
Pr
ogr
am
m
ing
7
B
asic 
In
st
ru
ct
ion
8
FNC0
0-F
NC0
9
Pr
ogr
am
 Flow
9
FN
C
10-FN
C
19
Mo
ve
 &
 Co
mp
are
10
FNC2
0-F
NC2
9
Ar
ith.
 &
 Logic 
O
per
ati
on
Caution
1. Using a label (P) number two or more times
In CALL instructions, a same number can be used two or more times in operands (P).
However, do not use a label (P) and number used in another instruction (CJ instruction).
Program examples
1. Example of fundamental use (no nesting)
2. Example of multiple CALL instructions in subroutines (multiple nesting)
CALL instruction can be used up to 4 times in subroutine programs.  Nesting of up to five layers is allowed.
Label
P 9
FNC 01
CALLP
P 9
X030
X020
FNC 00
CJ
P 9
User program
Bad
Label
P 10
FNC 01
CALL
P 10
FNC 06
FEND
FNC 02
SRET
END
X000
Main program
While X000 is ON, the program execution jumps to a
step with the label P10.
Subroutine program
When SRET instruction is executed after the subroutine
program has executed, the program execution returns to
the original step +1.
Label
P 11
Label
P 12
FNC 01
CALLP
P 11
FNC 06
FEND
FNC 01
CALL
P 12
FNC 02
SRET
FNC 02
SRET
END
Main program
When X001 turns ON from OFF, the program execution
jumps to the label P11 only once.
Subroutine program 1
When SRET instruction is executed, the program
execution returns to the main program.
If X002 is ON while the subroutine program 1 is
executed, the program execution jumps to a step with the
label P12.
Subroutine program 2
The subroutine program with P12 is executed, and then
the program execution returns to the subroutine program
with P11 by SRET instruction.
X001
X002
X003