In addition to traditional PLC programming according to IEC 61131-3 and high-level language programming with C++, TwinCAT also supports MATLAB® and Simulink®. Furthermore, this application in the Beckhoff automation suite is already established as a successful software platform – with the use of MATLAB®/Simulink® by more than 2,000 engineers on more than 6,500 TwinCAT-controlled machines.
MATLAB®, with its numerous toolboxes, provides an ideal environment for developing advanced algorithms and analyzing data. It offers a multitude of functions for easy access to different data formats and is a perfect match for the different data logging mechanisms of TwinCAT. Simulink® is focused on integrated support for model-based design which involves development, testing and verification based on a system model. The subsequent, automatic code generation for platforms such as TwinCAT represents an optimal solution for applying the tested code in production.
Targets for Simulink® and MATLAB®
With TwinCAT Target for Simulink® (TE1400), models developed in Simulink® can be used within TwinCAT. Embedded MATLAB® function blocks are also supported. The models are automatically translated into C/C++ code using the Simulink Coder™ and converted into TwinCAT objects that can be implemented seamlessly in TwinCAT Engineering using TwinCAT Target for Simulink®. The block diagram embedded in the engineering can be used – in addition to the Simulink® External Mode – as a control for parameter adjustment as well as for debugging, signal and state monitoring. The automatically generated modules can be integrated into the TwinCAT solution as a TcCOM object and also as a PLC function block. These modules are then downloaded with the entire TwinCAT project to the TwinCAT Runtime and executed there within the real-time environment.
MATLAB® functions can be used with the TwinCAT Target for MATLAB® (TE1401) and are automatically transferred to TwinCAT objects and used seamlessly in TwinCAT Engineering. These automatically generated modules can also be integrated as TcCOM objects or PLC function blocks and executed within the TwinCAT real-time environment.
Interface for MATLAB®/Simulink®
TwinCAT Interface for MATLAB®/Simulink® (TE1410) establishes high-performance bidirectional communication between the TwinCAT Runtime and MATLAB® or Simulink®. This toolbox can be used in the engineering phase of a system for software-in-the-loop simulation and during machine runtime as a simple tool for distributed computing. This allows the local execution of MATLAB® functions on the controller or on the network for parameter optimization or preventive maintenance. In addition, machine visualizations based on MATLAB® apps are possible.