Calling a TcCOM object from the PLC
Creating a TcCOM wrapper FB
Set in the export configuration:
TcCom.TcComWrapperFb = 'true';
TcCom.TcComWrapperFbProperties = 'true'; % optional
Create instance of the TcCOM Wrapper function block
- 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.

Version 1: 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.
![]() |
|
Declaration
// link wrapper with a static instance
InitStrStatic : ST_FB_TempCtrl_TcCOM_InitStruct := (noid := 16#01010010); // OID from object1 in System > TcCOM Objects
fbTempCtrStatic : FB_TempCtrl_TcCOM_InitStruct(InitStrStatic);
Inputs : ST_TempCtrl_U_T; // data type defined in TempCtrl library
Outputs : ST_TempCtrl_Y_T;
Execution code
fbTempCtrStatic(stTempCtrl_U := Inputs, stTempCtrl_Y => Outputs);
Version 2: 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.
![]() |
|
Declaration
// dynamic instance: create TcCOM from PLC
InitStrDyn : ST_FB_TempCtrl_TcCOM_InitStruct := (
nTaskOid := 16#02010030, // take TaskOID of PlcTask
eModuleCaller := E_ModuleCaller.Module ); // set module caller to "call by module"
fbTempCtrDyn : FB_TempCtrl_TcCOM_InitStruct(InitStrDyn);
OutputsDyn : ST_TempCtrl_Y_T;
Execution code
fbTempCtrDyn(stTempCtrl_U := Inputs, stTempCtrl_Y => OutputsDyn);
![]() | The source code for the graph shown above is available in MATLAB® via the Command Window
|