How do you program the overlaying of tags with the keyword "AT" in the STEP 7 (TIA Portal)?
You program overlaying of tags in the block interface of a function or function block.
You need the following to overlay tags with the keyword "AT".
- For S7-1200 at least STEP 7 (TIA Portal) V11.0+SP1+Update 2 (or higher) and firmware V2.0 (or higher).
- For S7-1500 at least STEP 7 (TIA Portal) V12 (or higher).
More information is available in the STEP 7 (TIA Portal) Online Help or in the manual under Overlaying tags with AT.
The example below shows how to access the separate bits of a tag of the Word data type with an Array of Bool.
- Create a function block.
Overlaying of tags is possible in the following blocks:
- FC/FB with standard access
- FB with optimized access for tags with the retain setting "Set in IDB"
Optimized access is set by default for all newly created blocks of the S7-1200/S7-1500. To set up standard access open the properties of the block and enable the "Optimized block access" function in the "Attributes".
- Open the block and block interface.
- In the declaration table you enter first the tag that you wish to overlay with a new data type. For example: Name: "statConveyor", Data type: "Word".
- Select the option "Set in IDB" from the drop-down menu of the "Retain" column.
- Mark the line with the tag to be overlaid and right-click.
- In the pop-up menu that opens you select "Add Line". You must declare the overlaying tag in the line directly under the tag to be overlaid.
- Enter the name of the tag in the added line, "statMotors", for example.
- In the "Data type" column you enter first just the letter "A" and wait until the window opens with the data types you can select.
- In the drop-down menu you select the keyword "AT" and then click in the "Name" column. In addition to the name of the tag ("statMotors", for example) the keyword with the tag to be overlaid is also displayed in the same field. In this example: AT "statConveyor".
- Click again in the "Data type" field and enter the declaration for the array, "Array[0..15] of Bool", for example.
Now the overlaying of the tags is completely declared and you can enter your program in the editor.
With some applications, it is necessary to group multiple signals in one control word or extract separate signals from a control word.
You can use the FB "BoolToWordAT" to group up to 16 bits in a word. The separate input tags of the Bool data type are assigned to the static "statMotors" array tag and overlaid with the keyword "AT" of the "statConveyor" tag. Then the content of the static "statConveyor" tag is transferred to the "conveyor" output tag.
Using the FB "WordToBoolAT" you can extract up to 16 signals (tags of the "Bool" data type) from a tag of the "Word" data type. The content of the "conveyor" input tag is transferred to the static "statConveyor" tag and overlaid with the keyword "AT" of the declared "statMotors" tag. Then the separate bits of the "statMotors" array tag are assigned to the output tags of the Bool data type.
These two functions are called and parameterized in OB1 "Main".
The download contains a library with blocks and tags.
- Drag-and-drop the blocks "BoolToWordAT", "BoolToWordAT_DB", "WordToBoolAT", "WordToBoolAT_DB", "DB" and "Main" to the block folder.
- Drag the "Tags" into the "PLC tags" folder.
Following Entry describes, how you open a library in STEP 7 (TIA Portal) 37364723.
For the example described above we recommend programming via slice accesses to achieve even better performance with the S7-1500. More information about slice accesses is available in Entry ID: 57374718.
The download and screens in this FAQ response were created with STEP 7 (TIA Portal) V13+SP1.