When the range of the array is exceeded (when the execution result exceeds the range), an instruction will not be executed.
When an error occurs, #L_Error turns ON.
The results in D1 and D2 maintain the values from the previous successfully run instruction.
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
XCH
Exchanges the contents of Data_1 and Data_2.
When the positive transition instruction turns ON, the XCH instruction will be executed. When the XCH instruction is executed, the summary of the Data_1[0] in D1 and the Data_2[0]in D2 will be switched.
When using a normally-open instruction, as long as the instruction variable is ON, the XCH instruction is always executed.
Array Variable Name |
Data 1 |
Instruction Execution |
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] |
XCHP
When the positive transition instruction turns ON, the XCHP instruction will be executed. When the XCHP instruction is executed, the summary of the Data_1[0] in D1 and the Data_2[0]in D2 will be switched.
Even when the operation is a normally open instruction, the XCHP instruction will execute only when an upward transition is detected.
As a result, even if the instruction is always on, the XCHP instruction is executed only for one scan.