Overview

MATLAB® and Simulink®

MATLAB® and Simulink® have become globally established environments for a wide variety of applications, even among budding engineers. There are many reasons for this development. MATLAB® and Simulink® provide environments where you can focus on the engineering task. This is perfect for didactic concepts in teaching environments and efficient in industrial applications. MATLAB®, with its numerous toolboxes, provides an ideal environment for developing algorithms and analyzing data. MATLAB® offers numerous functions for easy access to different data formats and harmonizes with the different data logging mechanisms of TwinCAT. Simulink® is focused on integrated support for Model-Based Design (MBD). This 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. Simulink® provides all the resources required for modeling multi-physics simulations and generating algorithms for controlling, regulating and AI. As a result, only high-quality codes tested on models are used on controllers.

Technologies and products for TwinCAT 3

TE1400 TwinCAT 3 Target for Simulink®

With the TwinCAT 3 Target for Simulink® it is possible to make models developed in Simulink® usable in TwinCAT 3. Various toolboxes, e.g. SimScape™, Stateflow™ or DSP System Toolbox™ can be integrated in Simulink®. Embedded MATLAB® function blocks are also supported. The models are automatically compiled in C/C++ code with the aid of the Simulink Coder™ and transformed into real-time capable TwinCAT objects with TwinCAT 3 Target for Simulink®. TwinCAT objects created from Simulink® have the same interfaces and properties as all other TwinCAT objects. They can be used fully in TwinCAT 3 Engineering, e.g. expand to a complete project with a PLC source code, debug and link with fieldbus devices, see the documentation TE1400 TwinCAT 3 Target for Simulink®.

TE1401 TwinCAT 3 Target for MATLAB®

TwinCAT 3 Target for MATLAB® enables MATLAB® functions to be used in TwinCAT 3. The functions are automatically transferred to TwinCAT objects and used seamlessly in TwinCAT 3 Engineering. The automatically generated modules can be integrated into the TwinCAT solution on the one hand as a TcCOM object and on the other hand as a PLC function block, also as part of a specially created PLC library. The inserted modules are downloaded with the complete TwinCAT project into the TwinCAT 3 runtime, where they are executed within the real-time environment like all other objects, see the documentation TE1401 TwinCAT 3 Target for MATLAB®.

TE1410 TwinCAT 3 Interface for MATLAB®/Simulink®

TwinCAT 3 Interface for MATLAB®/Simulink® establishes high-performance bidirectional communication between the TwinCAT runtime and MATLAB® or Simulink®. You can even use it for software-in-the-loop simulation with Simulink® during the system engineering phase. During the machine runtime you realize with this product for example:

To the documentation of the TwinCAT 3 Interface for MATLAB®/Simulink®

TE1421 TwinCAT 3 Simulation Runtime for FMI

With the TwinCAT 3 Simulation Runtime for FMI, the control logic executed in TwinCAT can be directly linked to a Simulink® model. This allows models created with TE1400 TwinCAT 3 Target for Simulink® and integrated into a TwinCAT project to be tested together with other parts of the control logic, such as PLC programs, against realistic plant and multiphysics models from Simulink® and Simscape™. For this purpose, the TwinCAT 3 UserMode Runtime is exported as a Functional Mockup Unit (FMU) and integrated into Simulink®. This enables a software-in-the-loop simulation of the complete TwinCAT control project and supports the validation of the interaction between the control components as well as virtual commissioning before the control software is deployed on the actual machine.

To the documentation for the TwinCAT 3 Simulation Runtime for FMI

TwinCAT basic technologies for MATLAB® and Simulink®

The tools presented in the following are free of license costs and are part of the TwinCAT 3 XAE or Full Setup.

TwinCAT 3 Block Diagram

The Block Diagram Viewer enables the display, debugging and parameterization of a TcCOM module via a block diagram displayed in the TwinCAT Engineering System. This tab is only available for TcCOM modules generated with Target for MATLAB® or Target for Simulink®. The export of the block diagram is optional for both targets.

Block diagram

TwinCAT 3 Automation Interface

The TwinCAT 3 Automation Interface is a programming interface for TwinCAT projects, i.e. you can create a configuration in the System Manager, create a PLC and insert code, and instantiate TcCOM objects without opening TwinCAT via Visual Studio or the TwinCAT XAE. This API is also available for MATLAB®, among others.

TwinCAT Automation Interface: use in MATLAB®