FILL: Fill 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
FILL: Fill block

Description

You can use the "Fill block" instruction to fill a memory area (destination area) with the content of another memory area (source area). The "Fill block" instruction moves the content of the source area to the destination area until the destination area is completely written. 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".

For blocks with the "Optimized block access" attribute, you can use the "FILL_BLK instruction. Fill block" instruction.

The following figure shows the principle of the move operation:

Consistency of source and destination data

Note that while the instruction "Fill block" is being executed, the source data remains unchanged; otherwise the consistency of the destination data cannot be guaranteed.

Memory areas

You can use the "Fill 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 destination area to be preset is not an integer multiple of the length of the BVAL input parameter, the destination area is nevertheless written up to the last byte.

If the destination area to be preset is smaller than the source area, the function only copies as much data as can be written to the destination area.

If the destination or source area actually present is smaller than the assigned memory area for the source or destination area (BVAL, BLK parameters), no data is transferred.

If the ANY pointer (source or destination) is of the data type BOOL, it must be addressed absolutely and the length specified must be divisible by 8; otherwise the instruction is not executed.

If the destination area is data type STRING, the instruction writes the entire string including the administration information.

Rules for moving structures

When you transfer a structure as an input parameter you must bear in mind that the length of a structure is always oriented to an even number of bytes. The structure will need one byte of additional memory space if you declare a structure with an odd number of bytes.

Parameters

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

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

BVAL

Input

VARIANT

I, Q, M, D, L, P

Specification of the memory area (source area), the content of which is used to fill the destination area at the BLK parameter.

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.

BLK

Output 1)

VARIANT

I, Q, M, D, L, P

Specification of the memory area that will be filled with the content of the source area.

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

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

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 BVAL parameter.

8352

The WSTRING, WCHAR, BOOL, ARRAY of STRING, ARRAY of WSTRING and ARRAY of WCHAR data types are not supported at the BLK 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 the source area from MW14 to MW20 and fills the destination area from MW100 to MW118 with the content of the 4 words contained in the memory area in the BVAL parameter.