×
Siemens Industry Online Support
Siemens AG
Entry type: FAQ Entry ID: 40651586, Entry date: 09/07/2010
(1)
Rate

How do you program the "FieldRead" and "FieldWrite" instructions in STEP 7 Basic V10.5?

  • Entry
  • Associated product(s)

Instructions
From STEP 7 Basic Version 10.5 + SP2 (Service Pack 2) you have indexed access to the array elements with the following commands:

  • FieldRead (read from an array with variable index) and
  • FieldWrite (write to an array with variable index).
No. Procedure
1 The "FieldRead" and "FieldWrite" commands are neither in the "Instructions" palette nor in the "Advanced Instructions" palette. You have to select these two commands from the drop-down list of an empty box.

In the block editor, select the "Instructions" palette and open the "General" folder. Then use drag-and-drop to insert an empty box into your network.


Fig. 01

2 Move the cursor on the yellow triangle in the empty box until the symbol for opening the drop-down list appears.


Fig. 02

3 Open the drop-down list and from it you select the "FieldRead" command (at the very bottom).


Fig. 03

4 Insert the "FieldWrite" command in a second network by repeating Steps 1 to 3 above.
5 Parameterizing the "FieldRead" instruction
When you click on the "FieldRead" box, a yellow triangle appears in the field for selecting the data type. Move the cursor on the yellow triangle until the symbol for opening the drop-down list appears. Open the drop-down list and from it you select the data type that you have declared for your variables (e.g. Byte).

In this example, the value of the ARRAY component Variable[1] is read from DB5.

  1. Parameterize the "MEMBER" input with the first component of the ARRAY variables, e.g. "DB_Modul_5".Variable[1].
  2. Parameterize the "INDEX" input with a variable of the data type DINT (e.g. "ArrayCompRead"). This index stands for the ARRAY component from which you want to read the value.
  3. You obtain the value of the ARRAY component at the "Value" output.


Fig. 04

Fig. 04 shows the variable declaration in DB5 and the parameterization of the "FieldRead" instruction in FC1.

6 Parameterizing the "FieldWrite" instruction
When you click on the "FieldWrite" box, a yellow triangle appears in the field for selecting the data type. Move the cursor on the yellow triangle until the symbol for opening the drop-down list appears. Open the drop-down list and from it you select the data type that you have declared for your variables (e.g. Byte).

In this example, the value of the ARRAY component Variable[1] is written in DB6.

  1. The "VALUE" input receives the value to be written. The data type must match the ARRAY element.
  2. Parameterize the "INDEX" input with a variable of the data type DINT (e.g. "ArrayCompWrite"). This index stands for the ARRAY component from which you want to read the value.
  3. Parameterize the "MEMBER" output with the first component of the ARRAY variables, e.g. "DB_Modul_6".Variable[1].


Fig. 05

Fig. 05 shows the variable declaration in DB6 and the parameterization of the "FieldWrite" instruction in FC1.

Creation environment
The figures in this FAQ were created with STEP 7 Basic V10.5 + SP2.

Security information
In order to protect technical infrastructures, systems, machines and networks against cyber threats, it is necessary to implement – and continuously maintain – a holistic, state-of-the-art IT security concept. Siemens’ products and solutions constitute one element of such a concept. For more information about cyber security, please visit
http://www.siemens.com/industrialsecurity.