Application
The "Symbolic access during runtime" function gives external applications access to the tags in the PLC program during runtime. External applications can be, for example, HMI applications, OPC UA functions or other communication functions. The tags can be read or written.
Read or write access is not programmed statically when the program is being created. In fact, access takes place dynamically during runtime. Users enter the symbolic tag names they wish to access manually or program-controlled during runtime.
The "Symbolic access during runtime" function can process optimized as well as non-optimized data. This means it is more flexible and efficient than an ANY pointer that can only access non-optimized data.
The function enables, for example, the tracing of tags through external devices or applications.
Constraints
The following constraints apply to the symbolic access during runtime:
-
The symbolic access is only available for S7-1500 as of firmware version V3.0.
-
The tags must have the attribute "Accessible from HMI/OPC UA/Web API" or "Writable from HMI/OPC UA/Web API".
The following table shows the data you can access:
|
Access to |
V3.0 |
V3.1 |
|---|---|---|
|
PLC tags (I, Q, M) |
✓ |
✓ |
|
Data blocks |
- |
- |
|
Elements of data blocks |
✓ |
✓ |
|
Technology objects |
- |
- |
|
Elements of technology objects |
- |
- |
|
Data blocks based on a PLC data type/system data type |
- |
✓ |
|
Elementary data types |
✓ |
✓ |
|
ARRAY and STRUCT* |
✓ Access to individual elements |
✓ Access to individual elements ✓ Access to the entire structure |
|
STRING and WSTRING |
- |
✓ |
|
DTL |
- |
✓ |
|
PLC data types and system data types |
- |
✓ |
|
Hardware data types |
✓ |
✓ |
|
IEC timers and counters |
- |
✓ |
|
I/O (Tag name: P) |
- |
- |
|
Timers (T) and counters (T or C) |
- |
- |
|
Elements in the load memory |
- |
- |
|
Write-protected elements |
- |
- |
|
References |
- |
- |
|
Pointer, Any, Remote, Block_FB, Block_FC, Multi-FB |
- |
- |
|
Data in fail-safe programs |
- |
- |
|
Note * Point to note when using tags of the STRUCT data type If you want to access a tag of the STRUCT data type, you need to select Little-Endian (mode:= 2#1) as memory format. |
Principle of operation
Two steps are necessary to access tags during runtime:
-
The symbolic tag names that are entered via HMI, for example, must be "resolved". This means that references to the respective tags are created in the PLC program. References are typed pointers by which you can address the tags in the PLC program. To resolve the symbolic tags, use the asynchronous instruction "ResolveSymbols".
-
Special Move instructions are available to read or write the tag values. The Move instructions are synchronous instructions. They address the tags using the previously generated references.
Example of step 1
The following example shows how the symbolic tag names are resolved with the instruction "ResolveSymbols":
-
At the parameter "nameList", specify an Array of WSTRING that contains the tag names you wish to resolve.
-
At the parameter "referenceList", specify an Array of ResolvedSymbol (SDT) in which the references to the tags are saved.
-
The two Arrays must have the same limits.
As a result, you receive a reference for each symbolic tag name at the parameter "referenceList". The reference is contained in a structure of the system data type "ResolvedSymbol".
See also:
ResolveSymbols: Resolve several symbols
System data type ResolvedSymbol
Example of step 2
The following example shows you how to read the tag values with the instruction "MoveResolvedSymbolsToBuffer" and write them to a buffer:
-
At the parameter "src", specify the Array of ResolvedSymbol (SDT) that contains the references to the resolved tags.
-
At the parameter "dst", specify an Array of BYTE . It serves as a target buffer to which the tag values are written.
When you execute the instruction "MoveResolvedSymbolsToBuffer", the tag values are read using the references and written to the target buffer.
See also:
MoveResolvedSymbolsToBuffer: Read values from resolved symbols and write them into buffer