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:

MemberTypePump1Pump2
RunBOOLPump1.RunPump2.Run
SpeedDINTPump1.SpeedPump2.Speed

In a rung you name a member with a dot: Pump1.Run. Pump1 and Pump2 never share a value.

Make a structure

  1. Stop the PLC. In Project Explorer, open Data Types and click New structure.
  2. Type its name, such as Motor, and a description.
  3. Add each member with a name and a type, then click Add member. Members can be BOOL, SINT, INT, DINT, REAL or STRING.
  4. Click Create structure.

Make a tag of it

  1. In the Tags table, click + Tag and type a name, such as Pump1.
  2. In Type, choose Motor under Structures, and click Create.
  3. Expand Pump1 in the Tags table to see Run and Speed.

Use the members in rungs

RungWhat it does
XIC Start OTL Pump1.RunStart latches the Run member on.
XIC Stop OTU Pump1.RunStop unlatches it.
XIC Pump1.Run OTE RunLampThe lamp shows Pump1.Run.
MOV SpeedSet Pump1.SpeedCopies 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

Related