4. Index Registers E, F Design Examples 4.1 Summation of Continuous D Registers Control Purpose: z Summing up the values of D registers from D101 to DN (the number of N is determined by users) and storing the operation result in D100. If the result if the result > K32767, the carry flag = ON. Devices: Control Program: M1000 M1000 NEXT M1021 Y0 Y0 M1022 Y1 Program Description: z The key of the program is to use the index register E1 together with FOR ~ NEXT loop to vary the addend D100E1. When E1 = K1, D100E1 represents D101; when E1 = K2, D100E1 represents D102. Also, when E1 = K10, D100E1 represents D110.
z The number of continuous D registers is determined by the execution times of FOR ~NEXT loop which is set by D500. If the value in D500 ≤ 1, the loop will execute 1 time. If the value in D500 = K10, the loop will execute 10 times first and then execute the instructions behind DVP-PLC Application Examples 4-1 Device Function Y0 Borrow flag indicator. When the value in D100 Y1 Carry flag indicator. When the value in D100 > K32767, Y1 = ON E1 Index register D100 Storing the sum of all D registers D500 Storing the executing times of FOR-NEXT loop MOV K1 E1 MOV K0 D100 FOR D500 ADD D100 D100E1 D100 INC E1