Creation of an EAP variable There are two common methods in TwinCAT to create user-defined data types. On the one hand a data type of your own can be created via the System node of the project tree on the Data Types tab (see next but one illustration). Such a data type is then available to all modules of the TwinCAT project. It is thus a global data type. In the following illustration you can see that the data type MyType is defined in the PLC. This data type has additionally been used for an output variable of the PLC program. Nevertheless, the user-defined data type does not appear in the list of available data types if a variable of this data type is to be created in the Publisher Box of the EAP device. A corresponding note that a data type is used only locally can be found on the basis of the data type list on the Data Types tab via the System node. In the following illustration the data type with the name MyType appears in the list. However, there is a remark under the Type property that the data type concerned is a temporary one (Tmp). This means that the data type concerned is one that is not global. If it should be necessary to use a local data type from the PLC in a global context, the corresponding DUT can be converted into a global data type (see following illustration). 1. Click on the command [Convert to Global Data Type] in the context menu of the DUT. ⇨ The node of the DUT is automatically removed from the PLC project and a global declaration of the type is created (see following illustration). The description for one and the same data type must be unique in TwinCAT. For this reason the definition of the data type (the original DUT) is removed from the PLC. Instead of that, the definition of the data type can be found in the XML-based TwinCAT project file following the conversion, and in this way the data type is globally available to the entire TwinCAT project.
Once the user-defined data type has been converted to a global data type, it can be selected from the list of available data types during the creation of a Publisher or Subscriber Variable in the EAP device (see following illustration). Changing a global data type Once a data type has been converted to a global data type, its definition is no longer under the control of the PLC project. The definition of the data type is located in the XML-based TwinCAT project file. This data type must now be changed in the TwinCAT project via the Data Types tab of the System node (see following illustration). 1. Select the data type that you wish to change from the list. 2. Right-click on it and select the command [Edit] in the context menu. ⇨ The TMC Editor opens (TMC = TwinCAT Module Configuration). 3. With the help of the TMC Editors you can change the data type as desired and subsequently save it. ⇨ The change is accepted in the TwinCAT project by creating a new version of the data type following the saving procedure and marking the original version in the TwinCAT project as Hidden. A PLC program that uses the data types concerned automatically uses the latest version of the data types. So that the change of the data type is also accepted in the machine code, the PLC project must be recompiled following the change. If a PLC variable of this data type exists and it is linked with a corresponding Publisher or Subscriber Variable of an EAP device, the latest version of the data type is also used with the Publisher/Subscriber Variable as soon as the PLC project is recompiled. |
|