WriteToArrayDBL: Write to ARRAY data block in load memory (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
WriteToArrayDBL: Write to ARRAY data block in load memory

Description

The instruction "Write to ARRAY data block in load memory" is used to write the element to which the index references to a data block of the ARRAY DB block type in load memory.

An ARRAY data block is a data block that consists of exactly one ARRAY of <Data type>. The elements of the ARRAY can be of PLC data type or any other elementary data type. Counting of the ARRAY always begins with the low limit "0".

If the ARRAY data block has been designated with the block attribute "Only store in load memory", it will only be stored in the load memory.

The instruction is executed when a positive signal edge is detected at the REQ parameter. The BUSY parameter then has the signal state "1". If a negative signal edge is detected at the BUSY parameter, the instruction is terminated and the value at the VALUE parameter is written to the data block. The DONE parameter then has the signal state "1" for one program cycle.

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

  • Enable input EN has the signal state "0".

  • If an error occurs during the execution of the instruction.

Parameters

The following table shows the parameters of the "Write to ARRAY data block in load memory" instruction:

Parameter

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

REQ

Input

BOOL

I, Q, M, D, L or constant

REQ = "1": Start writing to the array DB

DB 1)

Input

DB_ANY

I, Q, M, D, L

ARRAY data block to which data is written

INDEX

Input

DINT

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

Element in the DB to which data is written. The specification can be a constant, a global tag or an indexed value.

VALUE 1)

Input

VARIANT

D (element of a global data block)

L (The declaration is possible in the "Input", "InOut" and "Temp" sections of the block interface.)

Pointer to the DB in the work memory that is to be read and the value of which is to be written.

No local constants or tags from the TEMP section must be used.

BUSY

Output

BOOL

I, Q, M, D, L

BUSY = "1": The array DB is still being written

DONE

Output

BOOL

I, Q, M, D, L

DONE = "1": The instruction was executed successfully

ERROR

Output

INT

I, Q, M, D, L, P

Error information:

If an error occurs during execution of the instruction, an error code is output at the ERROR parameter.

1) The data blocks must be created with the "Optimized" block property.

Parameter ERROR

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

Error code*

(W#16#...)

Explanation

0000

No error

80B4

The element data type stored in the ARRAY data block does not match the element data type transferred in the VARIANT.

8230

The data block number is incorrect.

8231

The data block does not exist.

8232

The data block is too short, or is not located in load memory.

8234

The data block is write protected.

8235

The data block is not an ARRAY DB.

8254

The data block has the incorrect data type.

8382

The value at the INDEX parameter is outside the limits of the ARRAY.

8450

The data type VARIANT at parameter VALUE provides the value "0".

8751

Code generation error

8752

Code generation error

8753

The size of the VALUE parameter does not match the element length in the ARRAY data block.

* The error codes can be displayed as integer or hexadecimal values in the program editor. You can find information on switching the display formats under "See also".

You can find descriptions of the error codes triggered by the instructions "READ_DBL" and "WRIT_DBL" in the corresponding descriptions of the instructions.

Example

The following example shows how the instruction works:

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

Parameters

Operand

Value

REQ

TagReq

BOOL

DB

ArrayDB

The "ArrayDB" operand is an ARRAY DB of the data type ARRAY [0 to 10] of INT.

INDEX

2

2nd element of the "ArrayDB"

VALUE

SourceField

The "SourceField" operand is a global tag of the data type INT.

BUSY

TagBusy

BOOL

DONE

TagDone

BOOL

If the "TagIn1" operand has the signal state "1" and a positive edge is detected at the "TagReq" operand, the instruction is executed. As soon as a negative signal edge is detected at the "TagBusy" operand, the instruction is terminated and the value at the VALUE parameter is written to the 2nd element of "ArrayDB". If the instruction is executed without errors, the enable output ENO has the signal state TRUE and the "TagOut" output is set. After the instruction has been processed, the "TagDone" operand has the signal state TRUE.