CODESYS Overview
CODESYS is a Germany-based provider of PLC software solutions. Rather than manufacturing PLC hardware, CODESYS offers a comprehensive software suite for PLC development. OEMs producing PLCs can license CODESYS software to develop PLC programming environments and firmware.
This note introduces the main components of CODESYS software: the host programming environment, soft PLC, and PLC runtime.
CODESYS Programming Environment
The CODESYS programming software is an IEC 61131-3-compliant host application. The precompiled version, called CODESYS Development System, is available for free download from the CODESYS website. For OEMs, CODESYS provides the CODESYS Application Platform, a customizable version of the Development System. Basic customizations, such as branding, result in functionality similar to the standard version.
Soft PLC
The soft PLC is a licensed software product available for various platforms (Windows, Linux) with options for motion control, real-time systems, and multi-core support. Real-time performance on Windows is achieved through a CODESYS-developed kernel patch, while Linux leverages the well-known Linux real-time patch (potentially included without additional cost). Due to the lack of built-in I/O support, soft PLCs have limited use cases but offer deployment flexibility, such as cloud-based applications. Licenses are typically purchased directly by end users from CODESYS, with specific rules for OEM reselling.
PLC Runtime
The PLC runtime is a development toolkit that OEMs use to create customized PLC firmware tailored to their hardware. None of the CODESYS software provides source code. The CODESYS Application Platform, built on .NET Framework 4.8, offers .NET interface files for secondary development. The PLC runtime, written in C, requires OEMs to submit hardware-specific customization requests and provide a Firmware Platform SDK. CODESYS recompiles the runtime source code using the OEM’s SDK, delivering compiled header files and binary libraries for further firmware development.
Additional Software Packages
Beyond the core components, CODESYS offers functionality through independent software packages installed as plugins in the programming environment. These plugins, communicating via a proprietary CODESYS protocol, support device scanning, program downloads, variable monitoring, and debugging. OEMs can opt to customize only the runtime and use the standard CODESYS Development System for programming, importing PLC parameters via Device Description Files (DDF), a CODESYS-specific format. Customizing only the programming environment is possible but offers limited commercial value.
CODESYS Programming Environment Architecture
The programming environment consists of several layers:
- User-Facing Layer
This includes editors for IEC 61131-3 programming languages, configuration pages for I/O, servos, drives, and network communication. The native UI is primarily developed using WinForms, with complex editors leveraging GDI+ for canvas rendering. Each language or setting has its own data model, handling save/load operations for projects. - CODESYS Language Model
The core of the design-time environment, this layer is a collection of language models supporting all IEC 61131-3 languages, with Structured Text (ST) as the primary representation. Editors translate their inputs into the CODESYS Language Model (e.g., Ladder Diagram (LD) to ST). Configuration settings generate corresponding global variable types (DUTs), global variables (GVLs), and initialization code, consolidating all necessary PLC program information. - CODESYS Compiler
The compiler scans the Language Model for errors, reporting issues to the user. If error-free, it compiles the program, including installed libraries, and generates auxiliary code for type conversions, task management, I/O synchronization, and initialization. The compiler’s input and output are both CODESYS Language Models, with the output enriched with additional constructs.
Auxiliary Modules
Additional modules include upload/download, debugging, library management, plugin installation, refactoring, and a scripting engine. The environment is supported by a custom software architecture, including project structure management (e.g., project tree explorer) and a dependency injection (DI) system. Secondary development is facilitated through DI-based service interfaces and plugin integration. Plugin development requires a paid license from CODESYS, and developers can sell plugins via the CODESYS online store, sharing revenue with CODESYS.
Additional modules include upload/download, debugging, library management, plugin installation, refactoring, and a scripting engine. The environment is supported by a custom software architecture, including project structure management (e.g., project tree explorer) and a dependency injection (DI) system. Secondary development is facilitated through DI-based service interfaces and plugin integration. Plugin development requires a paid license from CODESYS, and developers can sell plugins via the CODESYS online store, sharing revenue with CODESYS.
Example: EtherCAT Package
The EtherCAT package illustrates CODESYS’s modular architecture:
The EtherCAT package illustrates CODESYS’s modular architecture:
- A user interface for configuring EtherCAT master/slave parameters.
- A module to convert parameters into the CODESYS Language Model.
- ST-language library interfaces for controlling or monitoring EtherCAT behavior and APIs.
- A complete ST-based EtherCAT protocol stack for runtime communication, provided as protected source code. (CODESYS also supports C-language runtime libraries, compiled by users and integrated via ST interfaces, though these are less common due to platform limitations.)
CODESYS Runtime
Unlike the .NET-based programming environment, the CODESYS runtime is implemented in C. Without source code access, its key components include:
- A proprietary protocol for host communication.
- Program management (supporting multiple programs on a PLC, potentially not concurrently).
- User program execution.
- An OPC UA protocol stack.
- SQLite integration (purpose unclear).
The runtime includes a custom framework with an event system, memory management, exception handling, and task scheduling, resembling a lightweight operating system. Secondary development is supported via the PLC Handler interface (details to be explored).
Analogy to .NET
CODESYS can be likened to the .NET ecosystem:
CODESYS can be likened to the .NET ecosystem:
- ST, LD, FBD, CFC, IL
C#, VB, F#, etc.
- CODESYS Development System
Visual Studio.
- CODESYS Language Model
.NET IL.
- CODESYS Compiler
Roslyn.
- CODESYS Code Generator
.NET AOT (no JIT support).
- CODESYS Libraries
.NET System Libraries.
- CODESYS PLC Runtime
.NET Runtime.
This analogy provides a clearer perspective on CODESYS’s architecture.
Conclusion
This overview covers the core architecture of CODESYS software. Further details and context will follow in future notes.
This overview covers the core architecture of CODESYS software. Further details and context will follow in future notes.