Delta AH500 — 6.14.2 Explanation of Structure Creation Instructions

AH500 Programming Manual API 1301 Symbol: Explanation: 1. The program between FOR and NEXT is executed N times. After the program between FOR and NEXT is executed N times, the program follows NEXT is executed. The instruction FOR specifies the number of times the program between FOR and NEXT is executed. 2. N should be within the range between 1 and 32,767. If N is less than 1, it is count as 1. 3. If the program between FOR and NEXT is not executed, it can be skipped by the use of the instruction CJ. 4. The following conditions result in errors.  The instruction NEXT is prior to the instruction FOR.  The instruction FOR exists, but the instruction NEXT does not exist.

 The instruction NEXT follows the instruction FEND or END.  The number of times the instruction FOR is used is different from the number of times the instruction NEXT is used. 5. FOR/NEXT supports the nested program structure. There are at most 32 levels of nested program structures. If the loop is executed many times, it takes more time for the program in the PLC to be scanned, and the watchdog timer error will occur. Users can use the instruction WDT to resolve the problem. Example 1: After program A is executed three times, the program follows the instruction NEXT is executed. Program B is executed four times every time program is executed.

Therefore, program B is executed twelve times in total. 6-310 Instruction code Operand Function NEXT - End of the nested loop Pulse instruction 16-bit instruction (1 step) 32-bit instruction - AH500 -