Handling of data types
In order to create or modify a data type via the TwinCAT 3 type system, select the New or Edit command from the context menu of the first table column on the appropriate tab of the type system editor. Both commands open the TMC editor in which you can edit the data type.
Data types from PLC projects
Data types (DUTs) can be created and saved in a PLC project. These data types initially exist locally in the PLC project and are not usable from the point of view of TwinCAT 3. If the data types are used in the input/output memory map (%I* / %Q*), they are imported into the TwinCAT 3 type system so that they can also be linked through the mapping.
With the Convert to Global Type command in the context menu of a DUT in the PLC project tree you can transfer the DUT to the type system of the higher-level TwinCAT project. Thereafter the data type is usable in the PLC via the external types and is managed in the TwinCAT 3 type system.
To transfer a data type from the TwinCAT 3 type system to a PLC project, you can use the source code in the “Data Types” dialog.
Data types from C++ projects
In C++ projects the data types are defined in the TMC editor in parallel with the modules. Like the internal DUTs in the PLC project, these data types are local and thus invisible in the TwinCAT 3 type system.
Through the use of the data types in a C++/Matlab module, which has also been instanced, the data types are inserted into the TwinCAT 3 type system.
You can also insert a data type into the TwinCAT 3 type system without using the data type in an instanced C++ module by activating the Persistent (even if unused) check box.
Use of data types in several projects
In some cases it may be useful to use data types in several projects. In particular for EAP/network variables it can be useful to use the same data type on both the publisher and subscriber side.
You can create individual TMC files for this under the "Type System" node.
A check box appears in front of every data type in the editor window of the TMC files. Using the check box you can specify which data type is to be deposited in the respective TMC file.
The data types are additionally deposited in the TMC files. You can use these files on different computers and in different projects, for example, by means of file exchange or version control.
However, the file itself must not be used by different projects at the same time, so that these are normally stored in the project directory and this project is then available as a copy on different computers, e.g. via version control.
Since the GUID is used to identify the data type, the type system recognizes this double deposition automatically.
When using data types after they have been integrated in several projects, make sure that changes to the data types are made as far as possible only in one place. Otherwise the different variants can no longer be merged to a common version.
See also: