Attention

You are viewing an older version of the documentation. The latest version is v3.3.

CODESYS Software PLC

CODESYS* is the leading manufacturer-independent IEC 61131-3 automation software for engineering control systems. It is used in Intel® Edge Controls for Industrial (Intel® ECI or ECI) to provide a software programmable logic controller (PLC) for executing real-time control applications. The CODESYS* Runtime is capable of performing complex tasks and communicating with industrial communication protocols such as PLCopen OPC UA Transport Layer, Profinet, and EtherCAT. For more details, refer to the CODESYS global website.

CODESYS Linux Runtime

The following section is applicable to:

../_images/target_generic.png

CODESYS* provides a Linux* runtime that allows control applications to execute on Linux*-based systems. The CODESYS* Linux* runtime is free to use without a license, however it will automatically stop execution after two hours. Additionally, OPC UA client functionality is limited to only thirty minutes, after which the OPC UA client will not function. If you want to use CODESYS* Linux* runtime beyond these time limit, you will need to purchase a license. For information on licensing CODESYS*, refer to License CODESYS Linux Runtime.

Install CODESYS Linux Runtime

You can install this component from the ECI repository. Setup the ECI repository, then perform either of the following commands to install this component:

logo_debian logo_ubuntu

Install from meta-package
$ sudo apt install eci-softplc-codesys
Install from individual Deb packages
$ sudo apt install codesyscontrol codemeter

Attention

ECI provides CODESYS* Control for Linux SL version 4.5.0.0.

../_images/021.png

License CODESYS Linux Runtime

See also

For information on licensing CODESYS*, refer to Licensing.

There are two primary licensing methods for the CODESYS* Linux* runtime:

License Method

USB Dongle

Application-Based Licenses

You can purchase a license for the CODESYS* Linux* runtime from the either of the following links, based on your location:

Restart CODESYS Linux Runtime

The CODESYS* Linux* runtime will continue to run without a license for up to two hours. Additionally, OPC UA client functionality is limited to only thirty minutes, after which the OPC UA client will not function. You may restore functionality after the time limits by restarting the CODESYS* Linux* runtime:

$ sudo systemctl restart codesyscontrol

Verify that the CODESYS* Linux* runtime is active (running):

$ sudo systemctl status codesyscontrol

The output should report active (running):

● codesyscontrol.service - LSB: Prepares and starts codesyscontrol
     Loaded: loaded (/etc/init.d/codesyscontrol; generated)
    Drop-In: /usr/lib/systemd/system/service.d
             └─10-override-protect-proc.conf
     Active: active (running) since Thu 2022-09-01 01:50:45 UTC; 2s ago

If the output does not report active (running), then repeat the process of restarting and checking the runtime.

Tip

Isolated incidences of compatibility issues with +12th generation CPUs and CODESYS* have been observed. See Limitation #5 - Cannot start CODESYS Linux runtime for potential mitigation actions.

CODESYS IDE

The following section is applicable to:

../_images/windows.png

CODESYS* provides an integrated development environment (IDE) for Microsoft Windows*. Using the CODESYS* IDE, control applications can be developed, tested, and compiled for the CODESYS* Linux* runtime. The following figure shows a typical IDE project environment.

../_images/29.jpg

For instructions on installing the CODESYS* IDE to a Microsoft Windows* PC, refer to Install CODESYS IDE.

Install CODESYS IDE

  1. Setup a PC with a 64-bit version of Microsoft Windows* [ 7 (Service Pack 1 or higher) / 8 / 10 / 11] installed.

  2. On the Microsoft Windows* PC, open a web browser and download the 64 bit version of CODESYS* from the following website:

    Note: You need to create a free account for the download to be available.

    Attention

    ECI was validated against CODESYS* version: V3.5 SP17 Patch 2 + (64-bit).

    ../_images/014.png
  3. Download the CODESYS Control for Linux / MC package (CODESYS Control for Linux SL x.x.x.x.package) from the following website:

    Note: CODESYS Control for Linux / MC package is free to download and evaluate. Without a License Key, the CODESYS* Linux* runtime will operate for up to 2 hours before requiring a restart. For information on licensing CODESYS*, refer to License CODESYS Linux Runtime.

    Attention

    ECI was validated against CODESYS* Control for Linux SL version 4.5.0.0.

    ../_images/021.png
  4. Download the CODESYS Edge Gateway for Linux (CODESYS Edge Gateway for Linux x.x.x.x.package) from the following website:

  5. Run the installer, downloaded earlier (name format should be: CODESYS 64 #.#.#.#.exe), to install CODESYS*.

  6. Make sure that CODESYS Control for Linux SL x.x.x.x.package and CODESYS Edge Gateway for Linux x.x.x.x.package are in the same directory. Double-click CODESYS Control for Linux SL #.#.#.#.package. This will initiate the CODESYS* package manager.

    ../_images/041.png
  7. The prompt should show both CODESYS Control for Linux SL and CODESYS Edge Gateway for Linux packages queued for installation. Follow the installation prompts to install these packages.

    ../_images/051.png
  8. Open the CODESYS* Package Manager (available in the Start Menu under the CODESYS* group), and verify whether both CODESYS Control for Linux SL and CODESYS Edge Gateway for Linux packages are successfully installed.

    ../_images/061.png

CODESYS Linux Runtime Optimizations

The following section is applicable to:

../_images/target_generic.png

ECI provides a number of useful scripts for improving the real-time performance of the CODESYS* Linux* runtime. Do the following to start using these scripts:

  1. On the target system, install the codesys-benchmark-scripts Deb package from the ECI APT repository. Setup the ECI APT repository, then perform the following command to install this component:

    $ sudo apt install codesys-benchmark-scripts
    
  2. Navigate to /opt/benchmarking/codesys/utility to find the applicable scripts.

    The scripts available at /opt/benchmarking/codesys/utility include:

    • start_codesys_native.sh: Optimizes the system (see the list below), stops non-essential services, and restarts the CODESYS* Linux* runtime

    • start_codesys_container.sh: Optimizes the system (see the list below) and starts the containerized CODESYS* Linux* runtime with RT priority

    • taskset_codesys.sh: Optimizes the system (see the list below)

    Note: The start_codesys_container.sh script assumes that you have completed the CODESYS* containerization section: Microservice: CODESYS Linux Runtime and CODESYS Edge Gateway

    The provided scripts also perform the following runtime optimizations:

    • Uses Cache Allocation Technology (CAT) to isolate CPU cache for CPU 1 & 3

    • Assigns CODESYS* task affinity to cores 1,3

    • Assigns non-CODESYS* task affinity to core 0

    • Disables kernel machine check interrupt

    • Increases thread runtime utilization to infinity

    When executing the scripts, not all task affinity can be changed. This is expected behavior. An example output is shown below:

    $ sudo /opt/benchmarking/codesys/utility/start_codesys_native.sh
    Stopping unecessary services
    Failed to stop ofono.service: Unit ofono.service not loaded.
    Failed to stop wpa_supplicant.service: Unit wpa_supplicant.service not loaded.
    Failed to stop bluetooth.service: Unit bluetooth.service not loaded.
    Stopping Docker Daemon
    Warning: Stopping docker.service, but it can still be activated by:
      docker.socket
    Stopping Codesys Runtime
    Disabling Machine Check
    Disabling RT runtime limit
    New COS default: 0xff0
    Changing CPU affinity of existing interrupts
    setting 1 to affine for core 0
    setting 4 to affine for core 0
    setting 8 to affine for core 0
    setting 9 to affine for core 0
    setting 12 to affine for core 0
    setting 14 to affine for core 0
    setting 16 to affine for core 0
    setting 18 to affine for core 0
    setting 27 to affine for core 0
    setting 29 to affine for core 0
    setting 120 to affine for core 0
    setting 121 to affine for core 0
    setting 123 to affine for core 0
    setting 124 to affine for core 0
    setting 125 to affine for core 0
    setting 126 to affine for core 0
    taskset: failed to set pid 3's affinity: Invalid argument
    taskset: failed to set pid 4's affinity: Invalid argument
    taskset: failed to set pid 16's affinity: Invalid argument
    taskset: failed to set pid 23's affinity: Invalid argument
    Starting Codesys Runtime
    Changing affinity of Codesys Runtime tasks
    Codesys preparation complete.
    

CODESYS Example Applications

ECI is bundled with CODESYS* example applications:


OPC UA Publish/Subscribe Example

The OPC UA Publish/Subscribe Example makes use of CODESYS* and the ECI Edge Control Protocol Bridge to showcase bridging OPC UA Client/Server Model to OPC UA Publish/Subscribe Model. In this example topology, the EC Protocol Bridge establishes a connection as an OPC UA client to the CODESYS* Linux* Runtime OPC UA server. Data on this OPC UA client/server protocol is bridged to an OPC UA publish/subscribe protocol, which the EC Protocol Bridge makes available.

../_images/30.jpg

CODESYS Benchmarking Applications

ECI is bundled with CODESYS* benchmarking applications:


CODESYS Benchmark

The CODESYS benchmark is an example application that allows deterministic control and test of the CODESYS* SoftPLC. The application is defined such that a main task occurs every 250us. Within the main task is a configurable workload which iterates a number of user defined times. The specific workload is configurable to either: “floating point”, “arithmetic”, or “boolean” operations. Cycle execution times are measured from which minimum, maximum, and jitter measurements are derived. These measurements allow performance characterization of the CODESYS* SoftPLC on the target system.

../_images/web.png

CODESYS OPC UA Client Benchmark

The CODESYS OPC UA client benchmark utilizes the CODESYS* SoftPLC to instantiate an OPC UA Client. Many parameters of the application are modifiable such as workload type, workload iterations, noise generation, OPC UA publish interval, and OPC UA monitored item selection. Cyclic task execution times are measured from which minimum, maximum, and jitter measurements are derived. These measurements allow performance characterization of the CODESYS* SoftPLC OPC UA Client implementation.

../_images/015.png

Explore more tutorials to learn more with CODESYS*:

Section

Description

Tutorial demonstrating how to setup, configure, and control a PROFINET device using CODESYS*.