The CppExamples repository is a collection of various sample code for PLCnext Technology controllers.
It is assumed that the reader has basic know-how of C++ programming and has read the key parts of the PLCnext Info Center.
Each example explains one or more topics on how to use C++11 with PLCnext Technology. Explanations are given in the README.md document and via comments in the example code.
Each example holds separate user components which can be instantiated on a PLCnext Control.
This project aims to supply, over time, examples and best practices of PLCnext Technology functions regarding C++11.
| # | Topic | Content | SourceCode |
|---|---|---|---|
| 01 | Program Component Interaction | This example shows two PLCnext programs interacting with a PLCnext component by getting or setting variables through reference. | SourceCode |
| 02 | Data Type Exchange Example | This example shows how to transfer data from a C++ project to the GDS. Variables published to the GDS can be accessed by other programs (IEC/C++/Simulink/C#) or the IOs | SourceCode |
| 03 | Include an Open Source Library | This describes how to use a third-party open-source library in a C++ project that is built for PLCnext Control using Eclipse | |
| 04 | Thread Example | This describes how to implement Threads in a component of C++ project. | SourceCode |
| 05 | Notification Example | This describes how to use the Notification Manager. | SourceCode |
| 06 | E-Learning: InternalFunctionExtensions | This describes how to use the Internal Function Extensions. | SourceCode |
- C++ programs in PLCnext Technology
- Required Installations for C++ programming
- Creating a new C++ project in Eclipse
There are different ways how to build your code:
- Install Eclipse IDE, CLI, SDK and Eclipse Add-in (how-to guide: see links in the "Getting started" section above)
- Clone this repository
- Navigate to the project you want to test, e.g.
cd Examples/ProgramComponentInteraction - Execute
plcncli new project -c DummyC -p DummyP && ls -la src && rm src/Dummy* - Execute
plcncli set target --add --name AXCF2152 --version 2020.6to specify details of the build target - Execute
plcncli generate allto generate intermediate code and Config files - Execute
plcncli buildto build the code. - Execute
plcncli deployto generate a .pcwlx file that can be included in PLCnext Engineer
- Create a new empty project named like the example you want to test
- Remove the source files located at
ProjectName/src - Move the source files from the example you want to use into your workspace at
ProjectName/src - Build the project
Compile using build-local.sh script
- Clone this Repository
- Modify the build-local.sh script to fit your needs
- select Hardware
- select Project
- Make sure it is executable for example with
chmod +x tools/build-local.sh - Execute the script
./tools/build-local.shorsh tools/build-local.sh
You can participate in this project by submitting bugs and feature requests.
Furthermore you can help us by discussing issues and letting us know where you have problems or where others could struggle.
- Ask a question in our Forum
- Request a new feature or example to be added on GitHub
- Vote for Popular Feature Requests
- File a bug in GitHub Issues
Copyright (c) Phoenix Contact GmbH & Co KG. All rights reserved.
Licensed under the MIT License.