6.29. FOR(FOR) Block Repeat
6.29. FOR(FOR):Block Repeat
Symbol | |
Relay combination | |
Factor | idx: Index relay. Init: Initial value relay or number. final: Final value relay or number step: Relay or number that will be used as step. |
Description | If Rung is activated, repeat the block from init to final by increasing the idx relay value with the value of step, until it reaches to NEXT. When FOR clause is executed, enter the init value to the idx. FOR/NEXT clause can be nested up to 10 times. → FOR() FOR() FOR() ….NEXT NEXT NEXT. If step>0, and init>final, then do not execute and jump to NEXT. If step<0, and init<final, then do not execute and jump to NEXT. Final and step only uses the initial value from the beginning of for clause, even if they are assigned as variable. In order to exit from the middle of FOR clause exceptionally, you may use JMP(negative number) command. (Refer to JMP command description). Caution) FOR command do not provide additional process for branches |
Usage example | FOR(RB10,1,4,1): Repeatedly execute until it reaches to NEXT command from RB10=1 to RB10=4 by increasing 1 each time. {|--[FOR(SW61,1,256,1)]-—[XIC(X-1)]—-[OTL(Y-1)]—-[NEXT]--|}: Repeatedly execute {XIC(X-1), OTL(Y-1)} command from SW61=1 to SW61=256 by increasing 1 each time. Among X1~X256, only the Y relay number that correspond to High signal number will be output and Y output of not entered number will retain the previous status. It is because of that idx is using a relay for indirect addressing (SW61~SW69) and the X relay of XIC and the Y relay of OTL is “-1” which will apply the number of SW61 value. Reference) Indirect addressing refers to as below. For any types of relay, if the address is set to -1 ~ -9, the value that saved in SW61~SW69 will be designated for the relay address. |