31.16.1.6 System Variables Indicating Execution Results - SUM/SUMP

Program Example

SUM

Totals 1 through 5 in Data_1 and saves the total in Data_2.

  1. When the positive transition instruction turns ON, the SUM instruction will be executed. When the SUM instruction is executed, the total of array elements 0 through 4 of Data 1 is calculated and the result at D1 is stored in Data_2.
    When using a normally-open instruction, as long as the instruction variable is ON, the SUM instruction is always executed.

Array Variable Name

Data 1

5 Executed Instructions

Save in

Data 2

Element

Data_1[0]

+

Data_2[0]

Data_1[1]

+

Data_2[1]

Data_1[2]

+

Data_2[2]

Data_1[3]

+

Data_2[3]

Data_1[4]

+

Data_2[4]

Data_1[5]

 

 

Data_2[5]

Data_1[6]

 

 

Data_2[6]

Data_1[7]

 

 

Data_2[7]

Data_1[8]

 

 

Data_2[8]

Data_1[9]

 

 

Data_2[9]

Data_1[10]

 

 

Data_2[10]

SUMP

  1. The SUMP and SUM instructions differ in how they detect the instruction start. The SUMP instruction only detects the upward transition and executes the SUMP instruction even when using a normally open instruction. Even if the variable of the NO instruction stays ON, the SUMP instruction is executed only for one scan..