1. FOR-NEXT Loop Instruction

ในหน้านี้3 หัวข้อ

1.1. Instruction Description#

When the input terminal is turned on, execute this command. Each FOR instruction must be paired with a NEXT instruction, and all instruction segments between FOR and NEXT instructions will be executed repeatedly (CNT) times. The instruction must specify the number of iterations CNT value. The NEXT instruction marks the end of the FOR loop.

CNT values can be modified during the execution of the FOR/NEXT loop. When the loop is allowed again, the number of loops is executed according to the new CNT value. When allowed next time, the FOR/NEXT instruction resets itself.

When the input terminal is enabled as' disconnected ', the program will skip all instruction segments between FOR and NEXT and directly execute the instructions after the NEXT instruction.

Note: The maximum number of nested layers for the FOR -- NEXT loop is 8

1.2. The valid operands of the instruction#

Input/Output Data Type operand Description
N 16 bit integer D/CV/TV/AI/AO/K/H/V/Z/FD, bit composite word (X/Y/M/C/T/S), local variable (LW) tags

1.3. Example#

command table:

NETWORK 000

LDP X000

FOR K10 // for loop 10 times

NETWORK 001

LD X001

INC D0 D0 // Add 1 D0 per cycle

NETWORK 002

NEXT

FOR11

图1 FOR11

FOR12

图2 FOR12

อุปกรณ์ที่ใช้กับคู่มือนี้
2 รายการ
FAT-16MT-DC-E
FAT-16MT-DC-E

PLC 16 I/O 24V DC Transistor Output รองรับ Modbus RTU/RS485 TCP/IP

฿2,590

FAs-32MR-AC-E
FAs-32MR-AC-E

PLC 32 I/O 220V AC Relay Output รองรับ Modbus RTU/RS485 TCP/IP

฿3,690