BLKMOV: Move block (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
BLKMOV: Move block

Description

You can use the "Move block" instruction to move the content of a memory area (source area) to another memory area (destination area). The move operation takes place in the direction of ascending addresses. You use VARIANT to define the source and destination areas.

Note

The tags of the instruction can only be used within memory areas in which the "Optimized block access" attribute is not activated. This applies to data blocks (DBs), organization blocks (OBs), functions (FCs), bit memory (M), inputs (I), and outputs (Q).

If a tag of the instruction has been declared with the retentivity setting "Set in IDB", however, you can use this tag in memory areas "with optimized block access".

The following figure shows the principle of the move operation:

Consistency of source and destination data

Make sure that the source data remain unchanged during the execution of the "Move block" instruction. Otherwise, consistency of the destination data cannot be guaranteed.

Interruptibility

There is no limit to the nesting depth.

Memory areas

You can use the "Move block" instruction to move the following memory areas:

  • Areas of a data block

  • Bit memory

  • Process image input

  • Process image output

General rules for moving

The source and destination areas must not overlap. If the source and destination area have different lengths, only the length of the smaller area will be moved.

If the source area is smaller than the destination area, the entire source area will be written to the destination area. The remaining bytes of the destination area remain unchanged.

If the destination area is smaller than the source area, the entire destination area will be written. The remaining bytes of the source area are ignored.

If a block of data type BOOL is moved, the tag must be addressed absolutely and the specified length of the area must be divisible by 8, otherwise the instruction cannot be executed.

Rules for moving character strings

You can use the "Move block" instruction to also move source and destination areas of the STRING data type. If only the source area is STRING data type, the characters will be moved that are actually contained in the character string. Information on the actual and maximum length are not written in the destination area. If the source and destination area are both STRING data type, the current length of the character string in the destination area is set to the number of characters actually moved.

If you want to move the information on the maximum and actual length of a character string, specify the areas in bytes to the SRCBLK and DSTBLK parameters. Alternatively, you can use the "Serialize" / "Deserialize" instructions.

Parameters

The following table shows the parameters of the instruction "Move block":

Parameters

Declaration

Data type

Memory area

Description

EN

Input

BOOL

I, Q, M, D, L, T, C or constant

Enable input

ENO

Output

BOOL

I, Q, M, D, L

Enable output

SRCBLK

Input

VARIANT

I, Q, M, D, L, P

Specifies the memory area to be moved (source area).

RET_VAL

Output

INT

I, Q, M, D, L, P

Error information:

If an error occurs during execution of the instruction, an error code is output in the RET_VAL parameter.

DSTBLK

Output 1)

VARIANT

I, Q, M, D, L, P

Specifies the memory area to which the block is to be moved (destination area).

1) The DSTBLK 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.

Parameter RET_VAL

The following table shows the meaning of the values of the RET_VAL parameter:

Error code*
(W#16#...)

Explanation

0000

No error

8092

The source or destination area is located in the load memory only.

8152

The WSTRING, WCHAR, BOOL, ARRAY of STRING, ARRAY of WSTRING and ARRAY of WCHAR data types are not supported at the SRCBLK parameter.

8352

The WSTRING, WCHAR, BOOL, ARRAY of STRING, ARRAY of WSTRING and ARRAY of WCHAR data types are not supported at the DSTBLK parameter.

General error information

See also: "GET_ERR_ID: Get error ID locally"

*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:

If the "TagIn" operand has signal state "1", the instruction is executed. The instruction copies 10 bytes starting from MB100 and writes them to DB1. If an error occurs during the move operation, its error code is output in the "Tag_RetVal" tag.