![IDEC OpenNet series User Manual Download Page 264](http://html.mh-extra.com/html/idec/opennet-series/opennet-series_user-manual_617384264.webp)
18: P
ROGRAM
B
RANCHING
I
NSTRUCTIONS
O
PEN
N
ET
C
ONTROLLER
U
SER
’
S
M
ANUAL
18-3
LCAL (Label Call)
Valid Operands
For the valid operand number range, see page 6-2.
When T (timer) or C (counter) is used as S1, the timer/counter current value is read out.
When designating S1 using other than a constant, the value for the label is a variable. When using a variable for a label,
make sure that all probable LABEL numbers are included in the user program.
Since the LCAL instruction is executed in each scan while input is on, a pulse input from a SOTU or SOTD instruction
should be used as required.
LRET (Label Return)
Valid Operands
Correct Structure for Calling Subroutine
When a LCAL instruction is executed, the remaining program instructions on the same rung may not be executed upon
return, if input conditions are changed by the subroutine. After the LRET instruction of a subroutine, program execution
begins with the instruction following the LCAL instruction, depending on current input condition.
When instructions following a LCAL instruction must be executed after the subroutine is called, make sure the subroutine
does not change input conditions unfavorably. In addition, include subsequent instructions in a new line, separated from
the LCAL instruction.
Operand
Function
I
Q
M
R
T
C
D
L
Constant
Repeat
S1 (Source 1)
Label number to call
X
X
X
X
X
X
X
X
0-255
—
Operand
Function
I
Q
M
R
T
C
D
L
Constant
Repeat
—
—
—
—
—
—
—
—
—
—
—
—
When input is on, the address with label 0 through 255 designated by S1 is called. When
input is off, no call takes place, and program execution proceeds with the next instruc-
tion.
The LCAL instruction calls a subroutine, and returns to the main program after the
branch is executed. A LRET instruction (see below) must be placed at the end of a pro-
gram branch which is called, so that normal program execution resumes by returning to
the instruction following the LCAL instruction.
Note:
The END instruction must be used to separate the main program from any subrou-
tines called by the LCAL instruction.
A maximum of 10 LCAL instructions can be nested.
LCAL
S1
*****
This instruction is placed at the end of a subroutine called by the LCAL instruction. When the sub-
routine is completed, normal program execution resumes by returning to the instruction following
the LCAL instruction.
The LRET must be placed at the end of the subroutine starting with a LABEL instruction. When the
LRET is programmed at other places, a user program execution error will result, turning on special
internal relay M8004 and the ERROR LED.
LRET
I0
LCAL
S1
0
REP
S1 –
D0
D1 –
D1
MOV(W)
Correct
I0
LCAL
S1
0
REP
S1 –
D0
D1 –
D1
MOV(W)
REP
S1 –
D20
D1 –
D21
MOV(W)
Incorrect
Separate the ladder line for each LCAL instruction.
I0 status may be changed by the subroutine upon return.
M0
S
I0
REP
S1 –
D20
D1 –
D21
MOV(W)
M0
S
Phone: 800.894.0412 - Fax: 888.723.4773 - Web: www.clrwtr.com - Email: [email protected]