Description
You can use the "Read field" instruction to read out a specific component from the field specified in the MEMBER parameter and transfer its content to the tag in the VALUE parameter. You use the parameter INDEX to define the index of the field components that are to be read. At the parameter MEMBER you specify the first component of the field to be read.
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 parameter INDEX is not defined in the field specified at the parameter MEMBER.
-
Errors, such as an overflow, occur during execution.
Parameters
The following table shows the parameters of the instruction "Read 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 components whose content is read out |
|
MEMBER |
Input |
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 from which will be read |
|
VALUE |
Output |
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 |
I, Q, M, D, L, P |
Operand to which the contents of the field component are transferred. |
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 |
Tag |
Value |
|---|---|---|
|
INDEX |
a_index |
4 |
|
MEMBER |
"DB_1".Main_Field[-10] |
First component of the "Main_Field[-10..10] of REAL" field in the data block "DB_1" |
|
VALUE |
a_real |
Component with index 4 of the "Main_Field[-10..10] of REAL" field |
The field component with index 4 is read from the "Main_Field[-10...10] of REAL" field and written to the "a_real" tag. The field component to be read is defined by the value at the parameter INDEX.