Creating a “Hello World” Application¶
In the tree view right-click on App node and add a new object.
- ⇒
In the following dialog select C_Code_App and click Add object.
Select the compiler to be used for the new C/C++ application and click Add.
- ⇒
In the following dialog select POU and click Add object.
- ⇒
Select the type for the POU object and click Open.
- ⇒
Enter a parameter and variable declaration.
Right-click at the desired code position and select Input Assistant in order to define the data type:
- ⇒
Then, click Apply to update the interface. As an alternative the interface can be displayed tabularly. Tabular view is a comfortable way to edit parameters:
- ⇒
On the C_Code_App tab open the Compiler options tab. Select a compiler and configure compiler settings for the C/C++ application. These settings enable the compiler to interprete and process the source files listed on the C-Code tab.
- ⇒
Open the C-Code tab. The following files are listed:
- C_Code_App.c: Implementation of POU.
- C_Code_App.h: C/C++ Interface of POU.
- C_Code_App_Init.c: Initialization of POU variables and parameters.
- C_Code_App_Shell.c: Main module.
- ⇒
Note
Double-click the Folder icon to open the directory in Windows Explorer.
To edit the POU implementation double-click or right-click a file and select Open…). The *.c and *.h files are opened in your operating system’s default editor.
- ⇒
Save your settings and click Compile on the right side of the screen. The object files are generated from source code. Compilation errors are reported within a message window. Details on the error can be found in the compiler.log file.
- ⇒
Save your project. In the tree view double-click Application. CODESYS is started with C/C++ interface. From the C_Code_App node an external library is generated. This library can be found in CODESYS 2.3 in the Library Manager.
Call the C/C++ code POU from your IEC application.
- ⇒
Note
In order to lookup C/C++ POUs, press F2 and open section
.
Build the project via
: C/C++ application parts are linked together with IEC application.- ⇒
Application is ready for download.