When the execution results in an error, the error code is stored in #L_CalcErrCode.
When checking the result using system variables, make sure the check takes place after the instruction has been executed. When checking the state after multiple instructions have been executed, system variables will store the result only of the last processed instruction.
Program Example
SUM
Totals 1 through 5 in Data_1 and saves the total in Data_2.
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
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..