Connecting to External mode
You can connect from your Simulink® environment to a running TcCOM object or an instance of the PLC function block in the TwinCAT XAR via External mode.
Restriction on code interface packaging The code interface packaging defines the behavior for multiple instances of a created class in TwinCAT. If the External mode is to be used, the setting C++ Class is not allowed. |
Simulation time in Simulink® set to "inf" Set the Simulink® simulation time to "inf". For operation in TwinCAT, it makes no sense to stop the execution of the module after a defined time. |
- Code generation settings in Simulink®
- 1. Under Code Generation > Interface, set the External mode parameter.
- Note the following for Code interface packaging:
- Nonreusable function: allowed
- Reusable function: allowed, set multi-instance code error diagnostic to None
- C++ Class: not allowed
- 2. Define the permissions of the External mode (separately adjustable for TcCOM and PlcFb).
- Shown in the following screenshot as an example for TcCOM.
- Connect to a runtime object with the External mode
- 3. Open the External mode control panel.
- 4. Select Connect.
- 5. Select the connected target and object instance.
- After selecting OK, you will be connected to the object. The Connect button on the External mode control panel has changed to Disconnect and you can see the simulation time transferred from the target in Simulink®.
As can be seen in the above graphic for selecting the object in a target, the External mode is available for TcCOM instances as well as for PLC-FB instances.
Bidirectional ADS route required For the External mode, a bidirectional ADS route is necessary. Unidirectional routes cause a timeout in communication. |