Create and configure the TcCOM-Wrapper-FB
Navigate to Configuration Parameters > Code Generation > TC TcCom Wrapper.
Check the checkbox TcCom Wrapper FB here. The checkbox is unchecked in the standard configuration.
You can use the checkbox TcCom Wrapper FB properties to configure whether the module parameters on the FB are to be created as properties. See Configuration of data access to data of a TcCOM object, especially Parameter: Initial values.
You can learn how to apply the generated wrapper here: Applying the TcCOM Wrapper FB.
Sample
By setting the Parameter: Initial Values under Tc TcCom Interfaces, the model parameters are created as module parameters (switched on by default). Now create the "TcCom Wrapper FB" with the option "TcCom Wrapper FB properties". Set the property monitoring to "CyclicUpdate" to see the value change of the property directly in the online view.
Then you can access the module parameters as follows, for example:
PROGRAM MAIN
VAR
// dynamic instance: create TcCOM from PLC
InitStrDyn : ST_FB_TempCtrl_TcCOM_InitStruct_InitStruct := (
TaskOid:= 16#02010030, // take TaskOID of PlcTask
eModuleCaller:= ModuleCaller.Module ); // set module caller to "call by module"
fbTempCtrDyn : FB_TempCtrl_TcCOM_InitStruct(InitStrDyn);
Outputs : ExtY_TempCtrl_T; // input
Inputs : ExtU_TempCtrl_T; // output
Parameters : P_TempCtrl_T; // parameter
bChange: BOOL;
END_VAR
fbTempCtrDyn(TempCtrl_U := Inputs, TempCtrl_Y => Outputs);
IF bChange THEN
Parameters.Kp := 10;
fbTempCtrDyn.TempCtrl_P := Parameters;
END_IF
In the "advanced" configuration level, the monitoring attribute of the properties can also be specified. In the default case, "No Monitoring" is set, i.e. no attribute is set.
Setting in Simulink® | Attribute on property |
---|---|
ExecutionUpdate | {attribute 'monitoring' := 'variable'} |
CyclicUpdate | {attribute 'monitoring' := 'call'} |
Monitoring attributes influence the visibility of the attribute values in the online view, i.e. when you have logged into the PLC and want to monitor the current values of the properties on the FB.
- No Monitoring: the values are not visible in the online view.
- Cyclic Update: the values of the properties are updated and displayed cyclically.
In the logged-in state in the PLC additional code is executed. - Execution Update: the values of the properties are only updated in the online view if getter/setter methods for the properties are called in the execution code. This quickly leads to irritation and is only relevant in rare cases.
No TcCOM Wrapper for Online Change-capable modules If the TcCOM is Online Change-capable, no TcCOM-Wrapper-FB is generated, since the version of the PLC library and the version of the TcCOM object must always match, which cannot be guaranteed for the Online Change of the TcCOM. |