meta data for this page
UDT
The structure of the UDT (User Defined Type) is identical to that of the STRUCTURE type; you can create more complex variables from existing variables, structures, and their arrays. The key difference is that while a STRUCTURE is valid within a specific function (FB, FC, OB), a UDT is a universal type that must be defined in a separate library within the TIA Portal (PLC > PLC data types). Variables created from the UDT can be used throughout the entire program, which is especially useful for large-scale functions like communication, where maintaining an identical structure is important. However, when modifying a UDT, be aware that it may sometimes cause the program to crash.
Variables created from the UDT can be used throughout the entire program, which is especially useful for large-scale functions like communication, where maintaining an identical structure is important. However, when modifying a UDT, be aware that it may sometimes cause the program to crash.
The UDTs shown here fall into two categories: The normal UDTs (icon:
) are fully editable and can be modified freely. The locked UDTs (icon:
) are connected to closed (typically system) functions; modifying them could cause major issues in the program.
A locked UDT is also shown by an icon (
) in the corner of the editor window.
PLC data types (UDT) can be nested up to 8 levels deep. Starting from firmware V4.0, CPUs in the S7-1500 series support nesting up to 26 levels. Each ARRAY of STRUCT/UDT uses 3 hierarchy levels.
The UDT type can be imported and exported quickly. To export: right-click on the specific type, choose “Generate source from blocks,” and select “Selected blocks only.” To import: go to PLC, then External source files, click “Add new external file,” right-click the external file, and select “Generate block from source.”

