C++ programs in PLCnext Technology
With PLCnext Technology, you can use programs created with C++ in the real-time context of a PLC along with conventional IEC 61131‑3 programs. To use programs and program parts created in C++ within the scope of PLCnext Technology, Phoenix Contact provides tools and add-ins that help to integrate your C++ program in your real-time application in an easy way.
Tools
- Software Development Kits (SDKs) with important toolchains and libraries for both Windows® and Linux® are available for all PLCnext Control devices.
- The PLCnext Technology Toolchain provides the following:
- Administration of the SDKs
- Build environment
- Automatic generation of required metadata and configurations
- Automatic creation of complete libraries
- PLCnext CLI (PLCnext Command Line Interface), based on the .NET Core Framework and can be used on Windows® and Linux® operating systems.
- You can use the freely available Eclipse® software with the Phoenix Contact Add-in as your C++ development environment for PLCnext Control devices. That add-in allows for easy connection to the PLCnext Technology platform and provides the PLCnext CLI functions out of your Eclipse® workbench.
- If you prefer working with Microsoft® Visual Studio® there is a PLCnext Technology extension available, too.
How to
These are the steps to go for programming something in C++ to run on your PLCnext Control. All tools and ressources mentioned or linked here are available openly and free of charge.
- Preparing the software and tools
- Install the PLCnext Engineer software and get familiar with the basics tasks: Getting started with PLCnext Engineer.
- Install the PLCnext Technology Toolchain.
- Install and integrate your preferred IDE plug-in/add-in, preferably under the path C:\Program Files\PHOENIX CONTACT\PLCnext_Toolchain\ide-plugins”.
- Install the SDK for your PLCnext Control device by means of the PLCnext Technology Toolchain or via your IDE workbench.
- Preparing the controller and station
- Hook up and start the PLCnext Control (see the user manual).
- Log in to its Web-based Management and perform a firmware update to the latest LTS release.
- Shut down the PLCnext Control to attach your I/O modules, then restart the PLCnext Control.
- Creating your automation project with a C++ program in it
- Open PLCnext Engineer and create a PLC project based on the template for the firmware release on your PLCnext Control.
- Create a bus configuration with the attached IO modules; in case of Axioline F modules, see Configuring Axioline F modules.
- Start your IDE, create a C++ project (Working with Eclipse or Working with Visual Studio) and create your program.
- In PLCnext Engineer, declare the port variables with data types according to the process data.
- In your IDE, compile your project and build a library for PLCnext Engineer (Working with Eclipse or Working with Visual Studio).
- In PLCnext Engineer, import that library into your automation project.
- Instantiate your C++ program from that library, then assign the C++ port variables to the process data.
- Transfer your project to the PLCnext Control and execute the C++ program.
Reference
- The PLCnext API documentation for C++ programming is publicly available for firmware releases from 2020.0 LTS on.
- In addition, read about the common classes in PLCnext Technology.
See also
• Published/reviewed: 2025-02-17 ☃ Revision 077 •