Structures (UDT) and structure instances
For many devices with the same structure (pump, motor, valve), define the members once; give a base address for each device and the tags and their addresses are generated automatically.
What it is used for
A plant has dozens of devices with the same structure: each pump has running, fault, speed, current and pressure values. Instead of writing a separate tag and address for each one, you define the structure (the member list) once and add a structure instance for each device (name, connection, base address). Studio generates the tags named Ornek.Uye and their addresses for each instance.
There are three concepts:
- Structure (UDT)
- The list of members: name, data type, address relative to the start of the structure. It is defined on the Structures (UDT) tab.
- Structure instance
- Applying a structure to a device: name (
Pompa_P101), structure, connection and base address (DB30). It is defined on the Structure instances tab. - Generated tag
- Automatic tag for each instance × member:
Pompa_P101.Hiz. It appears in the Tags table with the STRUCTURE badge.
Step by step
- Define the structure
On the HMI tags › Structures (UDT) tab, create the structure with Add and type its name (e.g.
Pompa_Yapisi). The Usage column shows N members · M instances. - Add the members
Select the structure; the Structure members table opens below. For each member, enter Name, Data type, Relative address, if needed Length (String), Unit and Description.
123Structures (UDT) tab: Pompa_Yapisi and its members; the relative address is the byte (and bit) offset from the start of the structure. - Usage — number of members and instances of the structure.
- Relative address — byte (and bit) relative to the start of the structure.
- Data type — the type of the member; it determines the size letter.
- Add an instance
On the Structure instances tab, click Add; enter Name (device name), Structure (UDT), Connection and Base address. The Generated tags column shows the number of generated tags and their first names.
123Structure instances tab: each instance is a device; the base address differs from instance to instance. - Structure (UDT) — the structure from which the instance is generated.
- Base address — varies by instance (DB30, DB31, DB32).
- Generated tags — the number and names of the automatically generated tags.
- Use the tags
Tags with a YAPI badge are created in the Tags tab; they are bound to screen objects and alarms like other tags.
How a relative address and a base address are combined
The address of the generated tag is calculated from the base address of the instance and the relative address of the member; the result is always checked again against the driver rule of the connection.
| Driver | Base address | Relative address | Member type | Generated address |
|---|---|---|---|---|
| Siemens S7 | DB10 | 2 | Real | DB10.DBD2 |
| Siemens S7 | DB30 | 0.1 | Bool | DB30.DBX0.1 |
| Siemens S7 | DB10.DBX20.0 (structure starting at byte 20) | 0.3 | Bool | DB10.DBX20.3 |
| Modbus, Mitsubishi, Omron | 40001, D100 | 2, 4 | — | 40003, D104 (the number is added) |
| OPC UA | ns=3;s="Motor1" | Hiz (member name) | — | ns=3;s="Motor1".Hiz |
| Allen-Bradley | Motor1 | Hiz | — | Motor1.Hiz |
| MQTT | hat1/durum | motor.hiz | — | hat1/durum#motor.hiz |
| Simulator | not used | sinus(0, 100, 10) | — | the relative address is the signal itself |
- In S7, the relative address is written as
baytorbayt.bit; Studio adds the size letter (DBW,DBD…) from the type of the member. For long types (LReal,String…), the formDB30.DBX24.0is produced. - The base address can also be a marker such as
M100. - For connections whose driver is symbolic (OPC UA, Allen-Bradley), the member name is appended with a dot.
- If the base address is empty and the connection is not a simulator, Check project gives the warning Base address is empty; the member addresses remain incomplete.
Generated tags
- Locked fields: the name, connection, data type, length and address come from the structure and cannot be changed manually. Acquisition cycle, Start value, Lower / Upper limit, Unit and Description can be edited (unit and description start from the member definition and can then be changed in the tag). The read cycle is 1 s by default; scaling and a substitute value can also be defined.
- Group: the tag is placed in the group of its instance; moving the instance to a group also moves its tags.
- Deleting: a generated tag cannot be deleted on its own; This tag was generated from a structure instance; it cannot be deleted on its own. To remove it, delete the structure instance. When you delete the instance, its tags are removed as well.
- Excel and CSV: generated tags are exported but not imported (Tag generated from a structure instance; not imported.); structures and instances are transferred from their own tabs.
Propagation of the change
Every change made to a structure or to an instance is immediately reflected in all instances: when a new member is added, a new tag is generated for each instance; when a member is deleted, its tag in all instances is also deleted; when a member's name, type or relative address changes, the name, type and address of the tags are updated; when an instance's connection or base address changes, the connection and address of all tags of that instance are updated. Objects and alarms bound to the tag of a deleted member give the error bound to a deleted tag in the Check project list, and objects on a faceplate bound to the member without a prefix give the error bound to a deleted structure member; before deleting a member in a structure, check where it is used. A member newly added to the structure is not placed on an existing faceplate automatically.
Use with a faceplate
The real benefit of a structure is that a single faceplate screen is used for all instances:
- Create the faceplate
Open the New Faceplate window with the New Faceplate button on the toolbar (or Add›New faceplate), then select the structure and a template. The template places the members of the structure according to their roles (status lamp, alarm lamp, button, I/O field …) and binds them.
- Bind the objects to the members
The objects in the faceplate are bound not to a tag but to a member of the structure, without prefix (
Hiz); the tag selector shows the members of the screen's structure at the top of the list. - Open the window
Add the Open pop-up window (with tag prefix) function to the event of the object on the process screen and enter the name of the instance in the Tag prefix field (the suggestions come from the instances of the structure):
Pompa_P103. Live reads the unprefixedHizbinding asPompa_P103.Hiz. To embed it in a screen, the Screen window field of the Tag prefix object works the same way.
The old format also works: if the objects on the window screen are bound to the tags of an instance (Pompa_P101.Hiz), Live replaces the part of the tag name before the first dot with the prefix. If there is no tag matching the prefix, that property remains unbound (the object appears with bad quality). Details: Faceplate and pop-up window.