400
8 APPLICATION INSTRUCTION
8.4 Structuring Instruction
• While the command input is ON, the CALL instruction is executed and the program execution jumps to a step with a label
(Pn). Then, a subroutine program with the label (Pn) is executed. When the RET (SRET) instruction is executed, the
program execution returns to the step following the CALL instruction. At the end of the main program, put FEND instruction.
Put a label (Pn) for the CALL instruction after the FEND instruction.
• The CALL(P) instructions can be nested up to 16 levels. However, the 16 levels are the total of the CALL(P) and XCALL
instructions.
Precautions
• In the CALL instruction, the 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).
• In a subroutine (or interrupt routine), use timers for routine programs. These timers count when a coil instruction or END
instruction is executed. After a timer reaches the set value, the output contact is activated when the coil instruction or END
instruction is executed. Because general timers count only when the coil instruction is executed, they do not count if they
are used in subroutines in which the coil instruction is executed only under some conditions.
• If a retentive type 1 ms timer is used in a subroutine (interrupt routine), note that the output contact is activated when the
first coil instruction (or subroutine) is executed after the timer reaches its set value.
• Devices which were set to ON in a subroutine (or interrupt routine) are latched in the ON status even after the subroutine is
finished. (Refer to the program example shown below). When the RST instruction for a timer or counter is executed, the
reset status of the timer or counter is latched also. For turning OFF such a device latched in the ON status or for canceling
such a timer or counter latched in the reset status, reset such a device in the main program after the subroutine is finished,
or program a sequence for resetting such a device or for deactivating the RST instruction in the subroutine. (Refer to the
program example shown below).
A: User program
(1): Main program
Program area from the step 0 to FEND instruction
(2): Subroutine program
Program area from a label Pn to RET instruction
A: User program
Pn
CALL
FEND
RET
SM400
Command
A
A
A
(1)
(2)
Pn
RUN Monitor
(normally on)
P0
CALL
FEND
RET
RET
RET
END
P0
P10
P20
CALL
P10
CALL
P20
P9
CJ
P9
CALLP
X20
X30
A
P9
Содержание MELSEC iQ-F FX5
Страница 1: ...MELSEC iQ F FX5 Programming Manual Instructions Standard Functions Function Blocks ...
Страница 2: ......
Страница 17: ...15 CONTENTS ...
Страница 24: ...22 MEMO ...
Страница 25: ...23 PART 1 PART 1 OVERVIEW Part 1 consists of the following chapter 1 OVERVIEW 2 PRECAUTIONS ON PROGRAMMING ...
Страница 126: ...124 6 SEQUENCE INSTRUCTIONS 6 3 Output Instructions Operation error There is no operation error ...
Страница 132: ...130 6 SEQUENCE INSTRUCTIONS 6 3 Output Instructions Operation error There is no operation error ...
Страница 140: ...138 6 SEQUENCE INSTRUCTIONS 6 3 Output Instructions Operation error There is no operation error ...
Страница 191: ...7 BASIC INSTRUCTIONS 7 2 Arithmetic Operation Instructions 189 7 Operation error There is no operation error ...
Страница 202: ...200 7 BASIC INSTRUCTIONS 7 2 Arithmetic Operation Instructions Operation error There is no operation error ...
Страница 278: ...276 7 BASIC INSTRUCTIONS 7 4 Bit Processing Instructions Operation error There is no operation error ...
Страница 280: ...278 7 BASIC INSTRUCTIONS 7 4 Bit Processing Instructions Operation error There is no operation error ...
Страница 915: ...18 TYPE CONVERSION FUNCTIONS 18 13 Converting DWORD to WORD 913 18 Operation error There is no operation error ...
Страница 917: ...18 TYPE CONVERSION FUNCTIONS 18 14 Converting DWORD to INT 915 18 Operation error There is no operation error ...
Страница 932: ...930 18 TYPE CONVERSION FUNCTIONS 18 26 Converting DINT to WORD Operation error There is no operation error ...
Страница 1050: ...1048 26 TIME DATA FUNCTIONS 26 4 Division MEMO ...
Страница 1068: ...1066 29 COUNTER FUNCTION BLOCKS 29 4 Counter Function Block Operation error There is no error ...
Страница 1107: ...I 1105 MEMO ...
Страница 1111: ......