Which programming languages can be used with CoDeSys?

Which programming languages can be used with CODESYS?

Express the control logic in a form that suits the job

In CODESYS, the main choices are Ladder Diagram (LD), Function Block Diagram (FBD) and Structured Text (ST). Sequential Function Chart (SFC) structures sequential operations. Legacy projects may also use Instruction List (IL), and a Continuous Function Chart (CFC) editor is available. Their positions within IEC 61131-3 and their current usage status are different.

Editor’s note: “CODESYS supports five languages” does not fully describe the current situation. IEC 61131-3:2025 specifies ST, LD and FBD as its language suite, with additional SFC elements for structuring programs and function blocks. CODESYS describes IL as obsolete and no longer maintained, although it can be enabled when needed. CFC is not a separate language defined by the standard.

LD: Makes contact-and-coil logic visible

Ladder Diagram uses contacts and coils resembling a relay circuit to represent operating permissives, interlocks and on/off conditions. For example, a motor command can depend on a run request, a ready signal and the absence of a fault. LD is useful when electrical maintenance staff need to follow the logic.

An LD contact does not have to represent a physical contact; it tests the TRUE or FALSE state of a BOOL variable. A negated software contact does not prove that the field device uses a physical NC contact. Online monitoring helps identify which condition is preventing the result. Use small, meaningful networks instead of unnecessarily long ones.

ST: Describes calculations and complex conditions in text

Structured Text is a textual language using IF, CASE, FOR and other structured constructs. It suits analog scaling, array processing, recipe calculations and the evaluation of numerous conditions. When programming ST in CODESYS, use clear variable names, consistent indentation and short program units.

For example, if xRequest, xReady, xFault and xMotorCommand are declared as BOOL variables, the following expression sets the command to TRUE when the request and ready signal are TRUE and no fault is present. It does not create a latch or memory; the result changes with the conditions.

xMotorCommand := xRequest AND xReady AND NOT xFault;

Using ST does not automatically make a program faster or more reliable. An endless loop, unsuitable data type or excessively large calculation can disrupt task timing. Check loop bounds and valid data ranges.

FBD: Connects functions and blocks through signal flow

Function Block Diagram represents operations as graphical blocks and connections. It makes relationships between timers, comparators, mathematical operations and control blocks easier to follow. For example, blocks can scale an analog measurement, compare it with a threshold and generate a delayed alarm.

Not every box in FBD represents the same kind of object. A function differs from a stateful function block. Use the correct instance, especially for timers and counters. Sharing one instance between independent operations can cause errors. Keep data flow and execution order understandable in larger diagrams.

SFC: Shows the current stage of a sequential process

Sequential Function Chart structures a process using steps, transition conditions and actions. In a “wait, fill, mix, drain” sequence, it shows the active step and the condition required to advance. Action details can be implemented in ST, LD or FBD.

SFC and task scheduling serve different purposes. SFC organizes process stages; Task Configuration determines when the program is called. Design transitions and fault behaviour for a missing sensor signal, timeout or cancellation. Drawing only the normal operating sequence is insufficient.

IL: Useful for understanding legacy projects

Instruction List is an older textual approach using short instruction lines with an assembly-like style. The current CODESYS product description states that IL is no longer maintained, although it can be enabled when required. Do not make IL the default choice for a new project. When maintaining a legacy program, inspect instruction order, intermediate results and behaviour after conversion carefully.

CFC: Offers a more flexible graphical arrangement of blocks

Continuous Function Chart is one of the graphical programming options provided by CODESYS. It allows block connections to be arranged in a more flexible layout. CFC is not a separate standard language in IEC 61131-3:2025. It is an additional editor offered by the development environment. Check connections and execution order in larger charts; an understandable layout matters for maintenance.

Can different languages be used in the same project?

Yes, different POUs can be implemented in different languages. For example, SFC can organize the main sequence, ST can implement calculations, and LD can present permissive logic for the service team. Select the implementation language when creating a POU. Programs, functions and function blocks work together through defined interfaces. This does not mean switching languages freely on every line of code.

Choose according to the task, the maintenance team’s knowledge and code readability. Check device drivers, manufacturer libraries and target controller capabilities too. Expressing an algorithm in different languages does not guarantee that an entire project transfers unchanged between PLC brands. A useful choice remains understandable months later and allows its behaviour to be verified.

Related topics

Ladder Diagram | Structured Text | FBD | SFC | Instruction List | IEC standards for PLCs | Function blocks | Training resources