MOVE_BLK_VARIANT: Move block (S7-1200, S7-1500) - STEP 7

FBD (S7-1200, S7-1500)

ft:publication_title
FBD (S7-1200, S7-1500)
Product
STEP 7
Version
V20
Publication date
11/2024
Language
en-US
MOVE_BLK_VARIANT: Move block

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:

  • The SRC_INDEX parameter is calculated zero-based. If an ARRAY is specified at parameter SRC, the integer at parameter SRC_INDEX specifies the first element within the source area from which it is to be copied. Independent of the declared ARRAY limits.

  • If no ARRAY is specified at parameter SRC or only one single element of an ARRAY is specified, then assign the value "0" at parameter SRC_INDEX.

DEST_INDEX

Input

DINT

I, Q, M, D, L or constant

Defines the start of the destination memory area:

  • The DEST_INDEX parameter is calculated zero-based. If an ARRAY is specified at parameter DEST, the integer at parameter DEST_INDEX specifies the first element within the target range that is to be copied into. Independent of the declared ARRAY limits.

  • If no ARRAY is specified at parameter DEST, then assign the value "0" at parameter DEST_INDEX.

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?

https://support.industry.siemens.com/cs/ww/en/view/42603881