Integrating C Modules
With the CODESYS C code integration, modules developed in C can be integrated as a library into a CODESYS project. The module is stored as a dynamic runtime module in a library along with the IEC interface which is implemented in it. Moreover, multiple variants of a module for different target systems may be stored in a library.
The library is displayed to the user like any other IEC 61131-3 library. When the library is used in an application, then CODESYS automatically downloads the suitable module from the library to the controller and executes it from the CODESYS Control runtime system.
Application examples:
Reuse of existing C code
Integration of code generated by modeling tools, such as Matlab®/Simulink®
Dynamic integration of device-specific functions created in C code
All dynamic modules of an application are transferred and loaded to the runtime system during the download. The runtime system must support dynamic linking for this.
License for the runtime system
The runtime system requires a license that permits C modules to be loaded. Without this license, dynamic modules cannot be linked during the download, and therefore the download will be aborted.
The dynamic modules are part of the boot application and they are reloaded and activated when the controller is restarted. The Reset Origin command unloads all C code modules in the application. The Reset Cold and Reset Warm commands do not lead to a repeated initialization of the C code modules.
CODESYS does not support the monitoring of variables in C code files or the setting of breakpoints in C source code.
Assigning precompiled runtime modules to devices and saving them in libraries
Requirement: A library (*.library
) is open in CODESYS.
Click
.The POUs view opens and displays the library project and its objects.
Select the library project and click
.Click Add in the Add C-Implemented Library dialog.
CODESYS adds the
C-Implemented Library object to the POUs view.
Double-click the
C-Implemented Library object.
The object opens in its editor
Click Add in this editor.
The Select Device dialog opens.
In the Object file input field, specify the name of a dynamically loadable module in the format
*.dll
or*.so
.Important
The
*.dll
file has to contain the title of the library project in its name. Example: If the library project is namedXYlib
, then the Object File has to be named:<name>_XYlib.dll
In the Device window, select a device for assignment of the Object file.
Click Select Device.
CODESYS displays the created device file assignment in the editor on the Compiled Components tab.
Save the library project.
For more information see: C Implemented Library