0% found this document useful (0 votes)
11 views2 pages

C

CODESYS does not support direct programming in C++, but it allows interaction through external C/C++ libraries, separate systems for communication, or advanced runtime customization. Users can create DLLs or shared libraries to extend functionality and communicate with CODESYS via protocols like Modbus or OPC UA. However, PLC logic must be written in supported languages such as Ladder Diagram or Structured Text.

Uploaded by

Vitor Bastos
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views2 pages

C

CODESYS does not support direct programming in C++, but it allows interaction through external C/C++ libraries, separate systems for communication, or advanced runtime customization. Users can create DLLs or shared libraries to extend functionality and communicate with CODESYS via protocols like Modbus or OPC UA. However, PLC logic must be written in supported languages such as Ladder Diagram or Structured Text.

Uploaded by

Vitor Bastos
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

🧩 Can You Use C++ in CODESYS?

Not directly. CODESYS is designed around PLC programming languages (LD, ST, FBD,
SFC, etc.), not C++.

However, you can extend or interact with CODESYS systems using C++ in a few
specific ways:

✅ Option 1: C++ for External Libraries or Modules


You can write external C/C++ libraries (DLLs or shared libraries) and call them
from CODESYS if your runtime supports this.

Use CODESYS External Library Tool to define interfaces.

This is typically done via SysLib or C-Interface APIs.

Useful when integrating custom hardware drivers, algorithms, or real-time code.

✅ Option 2: Use C++ on a Separate System and Communicate


Run your C++ code on a separate device or PC and communicate with the CODESYS
controller via:

Modbus TCP/RTU

OPC UA

MQTT

Shared memory or socket communication

This is common in hybrid systems where C++ handles high-performance computation,


and CODESYS controls I/O.

✅ Option 3: CODESYS Control Runtime Customization (Advanced)


If you're building a custom device or adapting CODESYS Runtime to embedded Linux,
you can embed C/C++ code in your runtime layer. This is very advanced and only for
system integrators or OEMs.

❌ Not Possible: Writing PLC Programs in C++


You cannot write PLC logic in C++ directly within the CODESYS IDE. The supported
logic languages are:

Ladder Diagram (LD)

Structured Text (ST)

Function Block Diagram (FBD)

Sequential Function Chart (SFC)

Continuous Function Chart (CFC)

🔁 Example: Calling a C++ DLL from Structured Text


If you expose a simple C++ function like:

cpp
Copiar
Editar
extern "C" int add(int a, int b) {
return a + b;
}
You can compile it into a shared library and import it in CODESYS using a function
prototype in a CODESYS Library.

But this requires:

Creating a CODESYS library project

Using the External Library Manager

Targeting a platform that supports C calls

You might also like