MATLAB and Simulink: Established Programming Standards


October 28, 2021

MATLAB and Simulink have grown worldwide and become established programming environments for diverse applications, including among budding engineers. There are many reasons for this development. MATLAB and Simulink provide solutions that enable a complete focus on the engineering task. This is perfect for didactic concepts in teaching environments and efficient in industrial applications.

What is MATLAB?

The MATLAB programming environment is widely used both in science and industry. MATLAB is a script language that is perfectly suited to the development of algorithms and mathematical models. It offers in particular efficient advantages as regards the collection, processing and analysis of data, and their visualization. Applications include predictive maintenance, image and signal processing as well as machine learning and optimization methods.

What is Simulink?

Simulink focuses on providing continuous support for Model-Based Design (MBD) where a virtual system model is developed, tested and verified. Thanks to virtual commissioning based on physical models and the resulting early verification of software functionality, it is possible to identify already in the early stages of the project the risks of faulty software with exact analysis and without the need for hardware prototypes and to avoid their use in real conditions. The subsequent automatic code generation constitutes an ideal solution to apply 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 controls.

Advantages of MATLAB and Simulink

  •    –   early validation of software functionality through simulation
  •    –   virtual commissioning based on physical model
  •    –   direct import of CAD models
  •    –   development and test of control software and process logic
  •    –   analysis of measurement and process data
  •    –   interactive apps for the development of algorithms
  •    –   train and optimize AI algorithms
  •    –   Parallel Computing


From MATLAB and Simulink to TwinCAT3

Using TE1401 TwinCAT 3 Target for MATLAB and TE1400 TwinCAT 3 Target for Simulink, it is possible to transfer directly into the TwinCAT world the analyses and simulations developed in the globally used programming languages MATLAB and Simulink. The programming, which was first validated and transferred to the actually connected TwinCAT system landscape, can immediately assume the control and monitoring tasks in the customer applications as a productive code without incurring the risk of unforeseeable errors in the development phase.

Target for MATLAB: Data Science in control

With TwinCAT 3 Target for MATLAB, it is possible to use the MATLAB functions in TwinCAT 3. The functions are automatically transferred into the TwinCAT objects and used seamlessly in TwinCAT 3 Engineering. The modules that are automatically generated can be integrated both as a TcCOM object and as a PLC function module in the TwinCAT solution. The integrated modules are downplayed with the complete TwinCAT project in the TwinCAT-3 runtime and are executed there like all other objects within a real-time environment.

Predictive maintenance, Machine Learning or Test and measurement technology – these MATLAB key functions can be seamlessly integrated in the control with the TwinCAT 3 Target for MATLAB.

Predictive maintenance is one of the most important factors for increasing OEE. The Predictive Maintenance ToolboxTM from Mathworks is ideal for developing state indicators and perform predictions. The integration of algorithms in the PLC makes it possible to synchronously access all relevant machine data. The monitoring system is transparently integrated in the control and is not a separate black box solution.

Machine Learning functions from MATLAB, in combination with TwinCAT 3, present great advantages: classifiers perform product tests synchronously and directly in the control or detect system faults. Regression algorithms execute virtual sensors, parameterize a system depending on the situation or are embedded directly in a control loop for model-predictive regulation. The algorithms are trained outside TwinCAT real-time and can be changed on-the-fly during the machine runtime without stopping the machine.

The integration of Test and measurement technology in the machine control system reduces the complexity and costs of the testing systems, eases engineering and leads to faster testing procedures. The Beckhoff I/O portfolio provides the raw data to the control. There these can be both saved directly in databases for documentation and (pre-)processed in the real-time environment. The extensive MATLAB signal processing algorithms, in combination with integrated simulation models for HiL testing, constitute an outstanding basis for the realization of integrated, modern and powerful test systems.

Target for Simulink: seamless Model-Based Design

With TwinCAT 3 Target for Simulink, it is possible for models developed in Simulink to be used in TwinCAT 3. Various toolboxes, such as SimScape or Stateflow or DSP System Toolbox can be integrated in Simulink. Embedded MATLAB function modules can also be supported. The models are automatically translated into C/C++-Code using the Simulink Coder and converted in 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 stations. The block diagram visualization from Simulink is assumed in TwinCAT Engineering. The block diagram embedded in Engineering can, in addition to the Simulink External Mode, be used as a control for parameters adjustment, debugging, signal and state monitoring. The modules that are automatically generated can be both integrated as a TcCOM object and as a PLC function module in the TwinCAT solution. The integrated modules are downplayed with the complete TwinCAT project in the TwinCAT-3 runtime and are executed there like all other objects within a real-time environment.

TwinCAT objects can be assigned to different CPU cores in real-time environment. This means that even large projects can be easily scaled, e.g. for the simulation of an entire windfarm. If speed is required in individual objects, it is also possible to parallelize calculations on several cores. That way applications from simple controllers to complete machine controls and real-time simulations can be comprehensively supported with one tool.


Related Articles

Latest Articles

  • All You Need to Know: Disconnect Switches from ABB

    June 1, 2023 Disconnect switches are essential safety devices that play a critical role in electrical circuitry, both in industrial settings and in everyday life. These switches are designed to ensure the safe de-energization of electrical circuits during emergency stoppages, maintenance, or repairs. ABB, a leading global technology company, offers a wide range of high-quality… Read More…

  • Guillevin: Your Trusted Distributor of Breakers and Panels

    May 31, 2023 Guillevin is one of Canada’s largest distributors of electrical products in Canada. Founded in 1906 by François-Xavier Guillevin in Montreal, Quebec, they have enjoyed considerable expansion to become a leading distributor of electrical materials and products. Growth is something Guillevin is familiar with, and since their founding, they have opened numerous locations… Read More…

Featured Article

Humber Students Take Home Gold at Skills Ontario Competition in Mechatronics

Humber Students Take Home Gold at Skills Ontario Competition in Mechatronics
Paxton C. (left) and Dillon K. (right) win gold at 2023 Skills Ontario Competition in Mechatronics (Team of 2)

Skills Ontario recently held the 2023 Skills Ontario Competition in person at the Toronto Congress Centre. It was the first in-person event after three years of it being held virtually during the COVID pandemic.

Paxton C. and Dillon K. won gold and advanced to compete in Toronto against the best-of-the-best from the province in the Mechatronics Contest. 

Read More


  • C-more CM5 HMIs from AutomationDirect

    June 5, 2023 AutomationDirect has added the next generation of the popular C-more HMI product line. The CM5 HMI series offers lower cost, high-performance HMIs in sizes from 4 inches to an impressive 22 inches. These HMIs have an amazing 1.6 GHz processor in the larger units (10” and above), 43 Mbytes of memory, and… Read More…

  • Emerson’s Enhanced NextGen Smart Firewall Perimeter Defense Solution Simplifies Network Security for Distributed Control Systems

    June 5, 2023 Emerson is improving perimeter security for the DeltaV distributed control system (DCS) with its new NextGen Smart Firewall, a purpose-built control system firewall designed to provide easy-to-install and easy-to-maintain perimeter security for all industries. More ruggedized construction, increased bandwidth, and role-based access provide users with increased performance and more granular access control. Manufacturers need to… Read More…