Description
You use the "Move block" instruction to move the content of a memory area (source range) to another memory area (target range). You can copy a complete ARRAY or elements of an ARRAY to another ARRAY of the same data type. The size (number of elements) of source and destination ARRAY may be different. You can copy multiple or single elements within an ARRAY.
The number of elements that are to be copied must not exceed the selected source range or target range.
If you use the instruction at the time the block is being created, the ARRAY does not yet have to be known, as the source and the target are transferred per VARIANT.
Counting at the parameters SRC_INDEX and DEST_INDEX always begins with the low limit "0", regardless of the later declaration of the ARRAY.
Enable output ENO returns the signal state "0" if one of the following conditions applies:
-
Enable input EN has the signal state "0".
-
More data is copied than is made available.
Parameters
The following table shows the parameters of the "Move block" instruction:
|
Parameters |
Declaration |
Data type |
Memory area |
Description |
|---|---|---|---|---|
|
EN |
Input |
BOOL |
I, Q, M, D, L or constant |
Enable input |
|
ENO |
Output |
BOOL |
I, Q, M, D, L |
Enable output |
|
SRC |
Input 2) |
VARIANT (which points to an ARRAY or an individual ARRAY element), ARRAY of <Data_type> |
L (The declaration is possible in the "Input", "InOut" and "Temp" sections of the block interface.) |
Source block from which to copy |
|
COUNT |
Input |
UDINT |
I, Q, M, D, L or constant |
Number of elements which are copied Assign the value "1" to the parameter COUNT, if no ARRAY is specified at parameter SRC or at parameter DEST. |
|
SRC_INDEX |
Input |
DINT |
I, Q, M, D, L or constant |
Defines the first element to be copied:
|
|
DEST_INDEX |
Input |
DINT |
I, Q, M, D, L or constant |
Defines the start of the destination memory area:
|
|
DEST |
Output 1) |
VARIANT |
L (The declaration is possible in the "Input", "InOut" and "Temp" sections of the block interface.) |
Destination area into which the contents of the source block are copied. |
|
RET_VAL |
Output |
INT |
I, Q, M, D, L |
Error information: If an error occurs during execution of the instruction, an error code is output at the RET_VAL parameter. |
|
1) The DEST parameter is declared as Output, since the data flow into the tag. However, the tag itself must be declared as InOut in the block interface. 2) With the SRC parameter, the data types BOOL and ARRAY of BOOL are not permitted. |
||||
You can find additional information on valid data types under "See also".
RET_VAL parameter
The following table shows the meaning of the values of the RET_VAL parameter:
|
Error code* (W#16#...) |
Explanation |
|---|---|
|
0000 |
No error |
|
80B4 |
The data types do not correspond. Instead of an ARRAY of Struct, use an ARRAY of PLC data type (UDT). |
|
8151 |
Access to the SRC parameter is not possible. |
|
8152 |
The operand at the SRC parameter is not typed. |
|
8153 |
Code generation error at the SRC parameter |
|
8154 |
The operand at the SRC parameter has the data type BOOL. |
|
8281 |
The COUNT parameter has an invalid value |
|
8382 |
The first element to be copied, defined via SRC_INDEX, is outside the source array. |
|
8383 |
The first element to be copied, defined via SRC_INDEX, is within the source array, and the last element to be copied, defined via SRC_INDEX + COUNT, is outside the source array. |
|
8482 |
The first target element defined via DEST_INDEX is outside the target array. |
|
8483 |
The first target element defined via DEST_INDEX is within the target array, and the last target element defined via DEST_INDEX + COUNT is outside the target array. |
|
8534 |
The DEST parameter is write protected |
|
8551 |
Access to the DEST parameter is not possible. |
|
8552 |
The operand at the DEST parameter is not typed. |
|
8553 |
Code generation error at the DEST parameter |
|
8554 |
The operand at the DEST parameter has the data type BOOL. |
|
*The error codes can be displayed as integer or hexadecimal value in the program editor. You can find information on switching the display formats under "See also". |
|
Example
The following example shows how the instruction works:
The following table shows how the instruction works using specific operand values:
|
Parameters |
Declaration in the block interface |
Operand |
Value |
|---|---|---|---|
|
SRC |
Input |
#SrcField |
The local operand #SrcField uses a PLC data type that was still unknown at the time when the block was programmed. (ARRAY[0..10] of "MOVE_UDT") |
|
COUNT |
Input |
Tag_Count |
2 |
|
SRC_INDEX |
Input |
Tag_Src_Index |
3 |
|
DEST_INDEX |
Input |
Tag_Dest_Index |
3 |
|
DEST |
InOut |
#DestField |
The local operand #DestField uses a PLC data type that was still unknown at the time when the block was programmed. (ARRAY[10..20] of "MOVE_UDT") |
If the "TagIn" operand returns signal state "1", the instruction is executed. Two elements are moved from the source range, starting from the fourth element of the ARRAY [0..10] of MOVE_UDT, to the target range. The copies are pasted in the ARRAY [10..20] of MOVE_UDT starting from the fourth element. If the instruction is executed without errors, the enable output ENO has the signal state TRUE and the "TagOut" output is set.
|
Note You can find more information on the MOVE_BLK_VARIANT instruction in the following article in the Siemens Industry Online Support: In STEP 7 (TIA Portal) how do you copy memory areas and structured data from one data block to another? |
See also
Overview of the valid data types
Basics of the EN/ENO mechanism
Switching display formats in the program status
VariantGet: Read out VARIANT tag value (S7-1200, S7-1500)
Basic information on VARIANT (S7-1200, S7-1500)
Memory areas (S7-1500)
Basic information on FBD
Memory areas (S7-1200)
Example of moving data (S7-1200, S7-1500)