EasyManua.ls Logo

Mitsubishi Electric MELSEC iQ-R-R00CPU - Subroutine Program

Mitsubishi Electric MELSEC iQ-R-R00CPU
1028 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
66
1 RUNNING A PROGRAM
1.6 Subroutine Program
1.6 Subroutine Program
Subroutine program is a program that is executed from a pointer (P) through the RET instruction. It is executed only when
called by a subroutine call instruction (such as the CALL instruction or the ECALL instruction). A pointer type label can also be
used instead of a pointer (P). The subroutine program is used for the following purposes.
By grouping programs executed multiple times in a single scan into a single subroutine program, the total number of steps
in a single program can be decreased.
By making a program which is only executed in a certain condition a subroutine program, the scan time can be shortened
for that program execution.
*1 The pointers are not required to be defined in an ascending order.
Making a program a standby type allows it to be managed as a separate program. ( Page 63 Standby
type program) Use the ECALL instruction and other similar instructions to call program files.
For details on nesting (nesting structure) of subroutine programs, refer to the nesting (N) ( Page 360
Nesting (N))
Precautions
The following lists the precautions when using the subroutine program.
When using a local device, setting of SM776 (Local device setting at CALL) allows for using a local device of a program file
at the storage location of the subroutine program.
Do not use the timer (T, ST). However, the timer can be used if the timer coil (the OUT T instruction) is executed only
once per scan.
If the RET instruction is not used to return to the calling program and then the program is terminated, an error will occur.
If a pointer (P) or pointer type global label exists within FB or FUN, an error will occur.
(1) The end of the main routine program
FEND
RET
RET
RET
END
P0
P8
P1
(1)
Main routine program
Program A
Subroutine program 1
Subroutine program 2
Subroutine program 3
Pointer
*1

Table of Contents

Related product manuals