Program Blocks - Mitsubishi Electric MELSEC iQ-R Series Programming Manual

Hide thumbs Also See for MELSEC iQ-R Series:
Table of Contents

Advertisement

3.1

Program Blocks

A program block is a unit for making up a program.
Multiple program blocks can be created in a program file and executed in the order specified in the program file setting. If the
order is not specified in the program file setting, the program blocks are executed in ascending order of their names.
By separating program blocks for individual functions and processing, the order of programs can be changed easily and
programs can be exchanged easily.
The program of a program block is stored by each registration destination program in a program file.
Program block 1
Program block 2
Creating a main routine program, subroutine program, and interrupt program separately in individual program blocks enables
creation of easy-to-understand programs.
Program type
Main routine program
Subroutine program
Interrupt program
*1 Subroutine programs and interrupt programs cannot be created in safety programs. Subroutine programs cannot be executed from
safety programs.
For details on the main routine program, subroutine program, and interrupt program, refer to the following.
 MELSEC iQ-R CPU Module User's Manual (Application)
• Create a subroutine program and interrupt program after the FEND instruction of the main routine program. Any program
after the FEND instruction is not executed as a main routine program. For example, when the FEND instruction is used at
the end of the second program block, the third program block or later runs as a subroutine program or interrupt program.
• To create an easy-to-understand program, use a pair of instructions, such as the FOR and NEXT instructions or the MC
and MCR instructions, within a single program block.
• A simple program can be executed in the CPU module simply by writing the main routine in one program block.
3 PROGRAM ORGANIZATION UNITS
14
3.1 Program Blocks
Program file
*1
Description
A program beginning with step 0 and ending with the FEND instruction
A program beginning with a pointer (P) and ending with the RET instruction.
This program is executed only when it is called by a subroutine call instruction (such as the CALL and ECALL
instructions).
A program beginning with an interrupt pointer (I) and ending with the IRET instruction.
When an interrupt factor occurs, the interrupt program corresponding to the interrupt pointer number is executed.

Advertisement

Table of Contents
loading

Table of Contents