OdepnoutPřipnoutZavřít

Sídlo Česká republika
Beckhoff Automation s.r.o.

Sochorova 23
61600 Brno, Česká republika

+420 511 189-250
info.cz@beckhoff.com
www.beckhoff.com/cs-cz/

Jun 28, 2022

C++ as a programming language for machine control

Heavily relied upon in IT and computer science circles, C++ is one of the most widely used programming languages, especially when it comes to hardware-related programming. The continuous development of C++, which has been reflected over the last decades in the advancement of compilers and tooling, is driven by an active developer community. This was reason enough for Beckhoff to offer C++ as a real-time programming language in TwinCAT automation software.

TwinCAT 3 C++ implements a real-time execution of C++ code on an Industrial PC, for which Beckhoff provides its own TwinCAT Software Development Kit (SDK) and a Common Runtime (CRT). Beckhoff relies on the widely used compiler from Microsoft to execute highly efficient code. Using these components and extensive code generation in engineering, a module is written that can later be executed cyclically by tasks - just like the PLC programs. A wide range of Visual Studio® debugging interfaces have been upgraded by Beckhoff and supplemented with real-time-typical displays, simplifying development. An important aspect is the seamless interaction between different real-time modules, as this allows the PLC and C++ to exchange information in different ways – and of course this exchange is also real-time capable.

An important difference between typical PLC programming and other programming languages is the possibility to exchange code without restarting the machine controller – the so-called online change. Beckhoff offers this functionality for TwinCAT C++ modules, too. Beckhoff also continually adapts updates to the programming language for TwinCAT C++ so that these are also available to the customer in real-time.

Why PLC and why C++?

The programming languages have different advantages depending on the intended use, which also results in different scenarios for the use of TwinCAT C++. C++ is established as a programming language in some industries. In addition, mixed code based on PLC languages and C++ is often used in one machine. Typically, the algorithm is then developed in C++, whereas the actual sequence control of the machine is traditionally written in a PLC language.

Many TwinCAT components and advanced products are also based on TwinCAT C++, such as TwinCAT 3 Target for Simulink® (p. 40), which generates C++ code that can be used as a TwinCAT C++ module. Beckhoff provides a powerful interface for TwinCAT users here in its usual open manner. In some places, this also goes beyond PLC programming, for example when it comes to the real-time integration of third-party hardware, which is not possible with a conventional PLC approach.

Applications besides real-time

Besides the TwinCAT C++ interface for real-time capable machine control, other programs and code written in C++ can also be executed by the operating system on Beckhoff Industrial PCs. The open standard ADS provides a license-free interface as a library for interaction with the real-time environment, whereby ADS simultaneously abstracts from the programming language in real-time: Access via ADS is thus completely independent of the project within the real-time environment.

Further information