Description
The "Write field" instruction is used to transfer the content of the tag at the VALUE input to a specific component of the field at the MEMBER output. You use the value at the INDEX input to specify the index of the field component that is described. At the MEMBER output, enter the first component of the field which is to be written to.
The data types of the field component at parameter MEMBER, the index and the tags at parameter VALUE must correspond to the data type of the instruction "Read field" because implicit conversion is not possible.
The enable output ENO has the signal state "0" if one of the following conditions applies:
-
Enable input EN has the signal state "0".
-
The field component specified at the input INDEX is not defined in the field specified at the output MEMBER.
-
Errors, such as an overflow, occur during execution.
Parameters
The following table shows the parameters of the instruction "Write field":
|
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 |
|
INDEX |
Input |
DINT |
DINT |
I, Q, M, D, L, P or constant |
I, Q, M, D, L, P or constant |
Index of field component that is written with the content of VALUE |
|
VALUE |
Input |
Binary numbers, integers, floating-point numbers, timers, DATE, TOD, CHAR, WCHAR |
Binary numbers, integers, floating-point numbers, timers, DATE, TOD, LTOD CHAR, WCHAR |
I, Q, M, D, L, P or constant |
I, Q, M, D, L, P or constant |
Operand whose contents are copied |
|
MEMBER |
Output |
Binary numbers, integers, floating-point numbers, timers, DATE, TOD, CHAR and WCHAR as components of an ARRAY tag |
Binary numbers, integers, floating-point numbers, timers, DATE, TOD, LTOD, CHAR and WCHAR as components of an ARRAY tag |
D, L |
D, L |
First component of the field to which the content of VALUE is written. |
You can select the data type of the instruction from the "???" drop-down list of the instruction box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
The following table shows how the instruction works using concrete operand values:
|
Parameters |
Operand |
Value |
|---|---|---|
|
INDEX |
a_index |
4 |
|
VALUE |
a_real |
10.54 |
|
MEMBER |
"DB_1".Main_Field[-10] |
First component of the "Main_Field[-10..10] of REAL" field in the data block "DB_1" |
The value "10.54" of the "a_real" tag is written to the field component with index 4 of the "Main_Field[-10 ... 10] of REAL" field. The index of the field component to which the content of the tag "a_real" is transferred is specified by the value at the input INDEX.