Calling a TcCOM object from the PLC
Creating a TcCOM wrapper FB
Set in the export configuration:
TcCom.TcComWrapperFb = 'true';
TcCom.TcComWrapperFbProperties = 'true'; % optional
Working with the TcCOM Wrapper FB
- 1. Create a PLC project.
- 2. Add the desired library under References.
- Under Pous/TcCOM Wrapper you get a function block that you can instantiate in the PLC. In addition, necessary data types are created in the Duts folder.
Referencing a static module instance
The function block can be used to access module instances previously created in the XAE, e.g. under System > TcCOM Objects. For this static case, the object ID of the corresponding module instance must be transferred during declaration of the function block instance. See red area in graphic below.
|
Dynamic instantiation and referencing from the PLC
The function block can also be used in such a way that a TcCOM object is generated from the PLC and linked to the wrapper. In the graphic below, this is the green area as a minimum example and the blue area with extended parameterization.
|
The source code for the graph shown above is available in MATLAB® via the Command Window:
TwinCAT.ModuleGenerator.Samples.Start('TcComWrapper TemperatureController')