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

Description

You can use the "Fill block" instruction to fill a memory area (target range) with the value of the IN input. The target range is filled beginning with the address specified at the OUT output. The number of repeated copy operations is specified with the COUNT parameter. When the instruction is executed, the value at the input IN is moved to the target range as often as specified by the value of the COUNT parameter.

The instruction can only be executed if the source range and the target range have the same data type.

Enable output ENO has the signal state "0" if one of the following conditions applies:

  • The EN enable input has the signal state "0".

  • The maximum number of elements changed is the number of elements in the ARRAY or structure. If you copy more data than there are elements at the OUT output, you will get an unintended result.

When a ARRAY of BOOL is copied, the enable output ENO for an overflow is set to "1" until the byte limit of the ARRAY structure is exceeded. If the byte limit of the ARRAY structure is exceeded by the value at the COUNT input, the ENO enable output is reset to "0".

Note

Use of ARRAYs

The instruction reads the content from the selected element from the source range and copies this content n-times (n = depending on the value at the parameter COUNT) to the destination, starting at the specified index.

Filling structures

As well as the elements of an ARRAY, you can also fill multiple elements of a structure (STRUCT, PLC data type) with the same value. The structure whose elements you want to fill must only contain individual elements of the same elementary data type. The structure itself can, however, be embedded in another structure.

Parameters

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

Parameters

Declaration

Data type

Memory area

Description

S7-1200

S7-1500

S7-1200

S7-1500

EN

Input

BOOL

BOOL

I, Q, M, D, L or constant

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

Enable input

ENO

Output

BOOL

BOOL

I, Q, M, D, L

I, Q, M, D, L

Enable output

IN

Input

Binary numbers, integers, floating-point numbers, timers, DATE, TOD, CHAR, WCHAR

Binary numbers, integers, floating-point numbers, timers, DATE, CHAR, WCHAR, TOD, LTOD

I, Q, M, D, L, P, or constant

I, Q, M, D, L, P, or constant

Element used to fill the target range

COUNT

Input

USINT, UINT, UDINT

USINT, UINT, UDINT, ULINT

I, Q, M, D, L, P, or constant

I, Q, M, D, L, P, or constant

Number of repeated move operations

OUT

Output

Binary numbers, integers, floating-point numbers, timers, DATE, TOD, CHAR, WCHAR

Binary numbers, integers, floating-point numbers, timers, DATE, CHAR, WCHAR, TOD, LTOD

D, L

D, L

Address in target range from which filling starts

For additional information on valid data types, refer to "See also".

Example with an ARRAY

The following example shows how the instruction works when you want to fill an ARRAY:

The following table shows how the instruction works using specific operand values:

Parameters

Operand

Value

IN

FillValue

The data type of the operand is INT.

COUNT

Tag_Count

3

OUT

TargetArea

The data type of the operand TargetArea is ARRAY[1..5] of INT. It consists of five elements of data type INT.

If the operands "TagIn_1" and "TagIn_2" have signal state "1", the instruction is executed. The instruction copies the value of the operand #FillValue to the #TargetArea output tag three times, starting with the first element. If the instruction is executed without errors, the TagOut operand at the "ENO" enable output is set to signal state "1".

Examples with a structure

The following examples show how the instruction works when you want to fill a structure:

Create a global data block with the following elements:

Data_block_1

Data type

MyStruct1

STRUCT

 

Member_1

INT

Member_2

INT

Member_3

INT

Member_4

INT

MyStruct2

STRUCT

 

SubArray

ARRAY[1..2] of STRUCT

 

SubArray[1]

STRUCT

 

NestedStruct

STRUCT

 

Member_1

INT

Member_2

INT

Member_3

INT

Member_4

INT

SubArray[2]

STRUCT

 

NestedStruct

 

STRUCT

 

Member_1

INT

Member_2

INT

Member_3

INT

Member_4

INT

Generate the following program code to address the MyStruct1 tag:

Generate the following program code to address the MyStruct2 tag:

In each of the two examples, the value 10 of the IN parameter is copied twice to the operand at the OUT parameter, starting with the element Member_2. This means that the value 10 is copied to the elements Member_2 and Member_3. The other two elements, Member_1 and Member_4, are not changed. If the instruction is executed without errors, the TagOut operand is set to signal state "1".