TwinCAT Library in Simulink®

In Simulink®, TwinCAT-specific input and output function blocks can (not mandatory) be used to define the signals/buses connected to these function blocks as inputs or outputs in the subsequent TcCOM in TwinCAT. A common way is to use the standard input ports (In) and output ports (Out) of Simulink®. This is usually also the best practice way, unless the additional functions of the TwinCAT-specific input and output function blocks described below are required.

The TwinCAT-specific input and output function blocks can be found in the
Library Browser under Beckhoff TwinCAT Target.

TwinCAT Library in Simulink® 1:

If you use the input and output function blocks provided by Beckhoff, you will benefit from the following additional functionalities, compared to the standard Simulink® input and output ports:

When using automatic mapping, please note that if the TcCOM is instantiated more than once in TwinCAT, you will end up with a mapping conflict which you must resolve by manual mapping. This option is therefore not recommended for multiple instantiations.

In addition to TwinCAT-specific input and output function blocks, a TwinCAT Environment View Block is also provided. This can be used in the Simulink® environment to simply display TwinCAT and TE1400 versions on the system.

Example

A Simulink® model is created, which outputs two negated inputs. An input is placed in a subsystem, see figure below.

TwinCAT Library in Simulink® 2:

The inputs and outputs of the model are automatically mapped to digital inputs and outputs via the properties of the TC Modules Input and Output. The necessary tree items can be found in TwinCAT 3 by selecting the desired input or output and then copying the string in the Variable tab under Full Name.

TwinCAT Library in Simulink® 3:

A list of shortcuts for quick access can be found in the documentation of the Automation Interface > API > ITcSysManager > ITcSysmanager::LookupTreeItem.

When the Simulink® model described above is compiled and integrated into TwinCAT 3, a mapping to the corresponding inputs and outputs is automatically created. The automatically generated mappings are marked with a blue symbol to distinguish them from manual mapping, while manual mapping symbols appear white.

TwinCAT Library in Simulink® 4: