Parameterization of several module instances
In the above section it was described that an instance of a TcCOM can be parameterized in TwinCAT, even deviating from the parameters in Simulink®.
If several instances of a TcCOM are used in a TwinCAT Solution, different options exist with regard to the individual parameterization of the instances. To implement the following three options, you must use the Code interface packaging setting in Simulink®.
Make sure that the setting Default parameter behavior is set to Tunable under Optimization.
- All instances should have the same parameters.
- 1. Set the parameter to "Reusable function". This is the default value when selecting the target TwinCatGrt.tlc.
- 2. Create several instances of your TcCOM in TwinCAT.
- 3. Under Parameters (Init), configure the <ModelName>_P_Sharing parameter to define or inherit. Define specifies the parameterization of all dependent instances configured with inherit.
- Only one instance with define may be configured.
- It should be possible to parameterize each instance individually.
- 1. Set the parameter to "C++ class".
- 2. Create several instances of your TcCOM in TwinCAT.
- No <ModelName>_P_Sharing parameter is generated. Each instance can be parameterized individually.
- Only one instance should be allowed in the project.
- 1. Set the parameter to "Nonreusable function".
- If you create several instances of your TcCOM in TwinCAT, you receive an error message when activating the solution.
- Whether an instance of a TcCOM can be instantiated multiple times can be seen in the TC3 BlockDiagram.
- 2. To do this, go to the parameter range on the right. Under Block Identification a parameter "SingleInstance" is visible.
- The value False means multi-instantiable. Accordingly, True means one instantiation.
Settings also apply to the use of the PLC function blocks The setting of the Code Interface Packaging has the same meaning for the use of the TcCOM as well as for the use of the PLC function blocks. |
Open sample for parameterization In MATLAB®, open the Multi Instance sample: |