IDEC MICROSmart FC6A Series Ladder Programming Manual page 276

Automation organizer windldr
Hide thumbs Also See for MICROSmart FC6A Series:
Table of Contents

Advertisement

13: P
B
ROGRAM
RANCHING
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 ladder line, separated from the LCAL
instruction.
Correct
MOV(W)
I0
LCAL
I0
MOV(W)
Separate the ladder line for each LCAL instruction.
Example: LCAL and LRET
The following example demonstrates a program that calls three different portions of program depending on the input. When the
subroutine is complete, program execution returns to the instruction following the LCAL instruction.
LCAL
I0
LCAL
I1
LCAL
I2
LABEL
0
M8121
LABEL
1
M8122
LABEL
2
M8123
13-4
I
NSTRUCTIONS
S1 –
D1 –
D0
D1
S1
0
S1 –
D1 –
D20
D21
When input I0 is on, program execution jumps to label 0.
S1
0
S1
When input I1 is on, program execution jumps to label 1.
1
When input I2 is on, program execution jumps to label 2.
S1
2
END
M8121 is the 1-s clock special internal relay.
When jump occurs to label 0, output Q0 oscillates in 1-s increments.
Q0
Program execution returns to the address of input I1.
LRET
M8122 is the 100-ms clock special internal relay.
When jump occurs to label 1, output Q1 oscillates in 100-ms increments.
Q1
Program execution returns to the address of input I2.
LRET
M8123 is the 10-ms clock special internal relay.
Q2
When jump occurs to label 2, output Q2 oscillates in 10-ms increments.
Program execution returns to the address of END.
LRET
FC6A S
MICROS
ERIES
MART
Incorrect
REP
S
M0
REP
I0 status may be changed by the subroutine upon return.
L
P
M
ADDER
ROGRAMMING
MOV(W)
S1 –
D0
I0
LCAL
S1
0
MOV(W)
S1 –
D20
FC9Y-B1726
ANUAL
D1 –
REP
D1
S
M0
D1 –
REP
D21

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents