Attention

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

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.

Prerequisites

  • A Windows system (x64 bit) to host the CODESYS IDE

  • A target system with the CODESYS Linux Runtime installed (See Install CODESYS Linux Runtime)

  • Ability to modify IP address of both the Windows PC and target system

  • Ability to connect both the Windows PC and target system via Ethernet network

The following steps are applicable to:

../../_images/windows4.png

This CODESYS example project was created and validated using CODESYS V3.5 SP17 Patch 2 + (64-bit). Project compatibility differences may occur when changing CODESYS version.

../../_images/codesys_version1.png

See also

This section assumes you are already familiar with CODESYS and how to deploy a workload to the CODESYS Linux runtime. For a detailed tutorial, see section: Application #2: CODESYS OPC UA Publish/Subscribe

  1. Use the Intel edgesoftware utility to download the ECI release archive, if not done already.

  2. Copy the CODESYS_Example_Applications.zip archive from the ECI release archive (release-eci_#.#.zip) to the Windows system. This archive is located in the ECI release archive within the Edge-Controls-for-Industrial directory as follows:

    └── Edge-Controls-for-Industrial
        ├── Codesys_Example_Applications.zip
        ├── Dockerfiles.tar.gz
        └── eci-release.tar.gz
    
  3. Extract the CODESYS_Example_Applications.zip archive. Navigate to the Benchmark directory. Double-click Benchmark_Linux_3.5.x.x.project to open the project with CODESYS.

  4. The benchmark application was created assuming the CODESYS Linux runtime has an IP address of 10.11.12.50 on interface eno1. However, you can change these if required. You need to change two IP addresses to accomplish this:

    IP Address #1:

    IP address in the CODESYS application (change via the CODESYS IDE) - Double-click “Ethernet” from the Devices pane. The IP address settings are displayed on the left pane.

    ../../_images/012.jpg

    IP Address #2:

    IP address of the Windows PC running CODESYS IDE. Windows is configured with 10.11.12.55 to be on the same subnet as the CODESYS Linux runtime.

    ../../_images/022.jpg

    The following steps are applicable to:

    ../../_images/target_generic3.png
  5. 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
    
  6. Modify the IP address of target system to match the CODESYS project. Run the following commands on the target system to change the IP address of the device interface to 10.11.12.50/24. Replace <interface_name> with the name of your interface (Example: eno1):

    $ ip a flush dev <interface_name>
    $ ip a add 10.11.12.50/24 dev <interface_name>
    
  7. Navigate to /opt/benchmarking/codesys. This directory contains a number of useful scripts for improving the real-time performance of the CODESYS Linux runtime.

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

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

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

      Note

      The start_codesys_container.sh script assumes you have completed the CODESYS Containerization section of this guide: Microservice: CODESYS Linux Runtime and CODESYS Edge Gateway

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

    The scripts also perform the following runtime optimizations:

    • Uses CAT to allocate exclusive access of half the last-level cache to core 3

    • Assigns benchmark thread affinity to core 3

    • Assigns non-benchmark thread affinity to core 0

    • Changes the priority of benchmark thread to 90 (using: chrt -f 90)

    • Disables kernel machine check interrupt

    • Increases the thread runtime utilization to infinity

  8. Run the start_codesys_native.sh script available at /opt/benchmarking/codesys to reload the CODESYS Linux runtime in preparation of the benchmark:

    $ cd /opt/benchmarking/codesys
    $ ./start_codesys_native.sh
    
  9. Build, download, and run the CODESYS Benchmark as outlined in OPC UA Publish/Subscribe Example. The CODESYS Benchmark is configured to host a web visualization at http://10.11.12.50:8080. If the benchmark is working correctly, the web visualization should be similar to following image:

    ../../_images/032.jpg
  10. Run the taskset_codesys.sh script at /opt/benchmarking/codesys to move all CODESYS tasks to CPU 3 and change the priority of all CODESYS tasks to RT:

    $ ./taskset_codesys.sh
    

    Use the RESET buttons in the web visualization to reset the statistics after running the taskset_codesys.sh script. This CODESYS benchmark demonstrates that real-time performance can be achieved with proper kernel and runtime configurations.

  11. Use the slider and arrow buttons to increase or decrease the number of workload iterations per cycle.

  12. The colored LEDs are connected to variables mapped to an OPC UA server. Connect an OPC UA client to the CODESYS OPC UA server to read/write the values. You can download a popular free OPC UA client called UaExpert from: https://www.unified-automation.com/products/development-tools/uaexpert.html.