User-defined types
A user-defined type, or UDT, groups related values under one name. You define it once as a structure in Data Types, then make as many tags of it as you need. Each tag holds its own copy of every member.
One type, many tags
A Motor structure with two members, and two tags made from it:
| Member | Type | Pump1 | Pump2 |
|---|---|---|---|
| Run | BOOL | Pump1.Run | Pump2.Run |
| Speed | DINT | Pump1.Speed | Pump2.Speed |
In a rung you name a member with a dot: Pump1.Run. Pump1 and Pump2 never share a value.
Make a structure
- Stop the PLC. In Project Explorer, open Data Types and click New structure.
- Type its name, such as
Motor, and a description. - Add each member with a name and a type, then click Add member. Members can be BOOL, SINT, INT, DINT, REAL or STRING.
- Click Create structure.
Make a tag of it
- In the Tags table, click + Tag and type a name, such as
Pump1. - In Type, choose
Motorunder Structures, and click Create. - Expand
Pump1in the Tags table to seeRunandSpeed.
Use the members in rungs
| Rung | What it does |
|---|---|
| XIC Start OTL Pump1.Run | Start latches the Run member on. |
| XIC Stop OTU Pump1.Run | Stop unlatches it. |
| XIC Pump1.Run OTE RunLamp | The lamp shows Pump1.Run. |
| MOV SpeedSet Pump1.Speed | Copies a speed into the Speed member. |
Good to know
- A member added to the structure reaches every tag of it at once. You do not add it to each tag.
- Tag export to a CSV file leaves structure tags out. Save the project file to keep them.
Learn it in a lesson
- User-defined typesIntermediate · 15 min