Skip to main content
Version: Torizon OS 7.x.y

Partner Demo Container - CODESYS

Introduction

This article shows how to run the CODESYS partner container on Toradex hardware.

Learn more about CODESYS Software PLC in our overview article.

This article complies with the Typographic Conventions for Torizon Documentation.

About the Partner Demo Container

Intended Use

This partner demo container is meant for evaluating the technology. It is not suitable for development or production.

caution

The CODESYS runtime provided in this guide is meant for demonstration purposes and has a limited time to run of 2 hours from the start of the container. See the section Licensing Information for more details.

Licensing Information

If you want to License Codesys on Toradex hardware, contact our partners CODESYS GmbH or Nexo. For licensing information, check the CODESYS licensing page.

Supported Modules

The following Computer on Modules are supported:

Supported OS

The following platform and configuration are supported:

To get full performance, CODESYS requires the Linux kernel with the PREEMPT_RT patch applied and configured to be fully preemptive. The support for PREEMPT_RT on Torizon is in its early stages. For evaluation, you can run this container using the default Torizon OS without PREEMPT_RT at your discretion. Alternatively, you can install the nightly build of Torizon OS with PREEMPT_RT from our Toradex Easy Installer CI feeds, if available at all. Note that images from the CI feeds are not supported by Toradex. Use them at your discretion.

To follow-up on the PREEMPT_RT topic, subscribe for updates on the Torizon OS Release Roadmap.

Getting Started

Target Device Download Container

  1. Enter the Codesy page and download the application package.

  2. Unzip the package.

  3. Copy the runtime files to the target device.

    1. Docker container
      CODESYS Virtual Control for Linux SL 4.13.0.0/Delivery/virtuallinuxarm64/Docker_codesyscontrol_virtuallinuxarm64_4.13.0.0_arm64.tar.gz
    2. Docker run script
      CODESYS Virtual Control for Linux SL 4.13.0.0/Delivery/virtuallinuxarm64/DockerRuntimeStart.sh
      note

      4.13.0.0 is the software version, also for 32-bits arm/v7 devices, use the files under virtuallinuxarm.

  4. Connect to the target device and Load the container.

    docker load -i Docker_codesyscontrol_virtuallinuxarm64_4.13.0.0_arm64.tar.gz
  5. Run container

    1. First, you need to configure the container network. For this demo, we are going to use --network=host
      tip

      Running a container with the flag --network=host is easy for evaluation but it is a bad practice from a security standpoint. You should figure out which ports must be exposed to replace the --network host. Read our Torizon Best Practices Guide for some help.

    2. Modify the DockerRuntimeStart.sh script to include this flag in the docker run command.
      RUNTIMEID=$(docker run \
      --rm \
      ${CONTAINERNAMECOMMAND} \
      ${HOSTNAMECOMMAND} \
      -d \
      -t \
      -v ~/dockerMount/conf/codesyscontrol/:/conf/codesyscontrol/ \
      -v ~/dockerMount/data/codesyscontrol/:/data/codesyscontrol/ \
      -v /var/run/codesysextension/:/var/run/codesysextension/ \
      -v ~/dockerMount/extension/codesyscontrol/:/var/opt/codesysextension/ \
      -p 11740:11740/tcp \
      -p 443:443/tcp \
      -p 8080:8080/tcp \
      -p 4840:4840/tcp \
      --cap-add CHOWN \
      --cap-add IPC_LOCK \
      --cap-add KILL \
      --cap-add NET_ADMIN \
      --cap-add NET_BIND_SERVICE \
      --cap-add NET_BROADCAST \
      --cap-add NET_RAW \
      --cap-add SETFCAP \
      --cap-add SETPCAP \
      --cap-add SYS_ADMIN \
      --cap-add SYS_MODULE \
      --cap-add SYS_NICE \
      --cap-add SYS_PTRACE \
      --cap-add SYS_RAWIO \
      --cap-add SYS_RESOURCE \
      --cap-add SYS_TIME \
      --network=host \
      ${RTIMAGE} \
      ${NICCOMMAND} ${LICENSESERVERCOMMAND})
    3. Run the DockerRuntimeStart.sh script
      sudo chmod +x ./DockerRuntimeStart.sh
      ./DockerRuntimeStart.sh

Host Machine Runtime Demo Project

  1. Install CODESYS Development System.

  2. Go to the menu Tools > Device Repository:

    Device Repository

  3. On the Device Repository window, click in the Install... button and select the virtuallinux device descriptor file:

    CODESYS Virtual Control for Linux SL 4.13.0.0/Devices/AddOns/CODESYS Virtual Control for Linux SL/virtuallinuxarm64/4.13.0.0/codesyscontrol.devdesc.xml

    Install Device Descriptor

  4. Create a new Standard project, give the project a name and click ok:

    Create a new *Standard Project*

  5. Select the device previously installed. In PLC_PRG select Ladder:

    Setup device and PLC programming language

  6. Now a new project is created. You will see a menu listed on the left-hand side of the project window.

  7. Double click on Device. A new tab will open. Click on Scan network ...:

    Find your device in the network

  8. In the Select Device window make sure the device was found and then double click on it:

    Select your CODESYS device

  9. With the device connected to the development environment, we can start programming the logic. Click PLC_PRG in the project tree. In Toolbox drag and drop a Contact and a Coil to the Ladder area:

    Create a basic project logic

  10. Add the INPUT_01 variable name in the Contact text box and select as type BOOL:

    Configure the input device

  11. Add the OUTPUT_01 variable name in the Coil text box and select as type BOOL:

    Configure the output device

  12. Add a Visualization to the project. In the project tree, right click on Application > Add Object > Visualization:

    Add visualization

  13. On Add Visualization window just click Add button:

    Add visualization

  14. On the Visualization tab, which can be opened with double click on Visualization in the project tree, select Visualization Toolbox > Lamps/Switches/Bitmaps one DipSwitch and one Lamp1, drag and drop one at a time for the Visualization tab:

    Create the visualization user interface

  15. Connect the elements of the visualization to the elements of the ladder.

  16. Select DipSwitch and in Properties select Variable:

    Configure the dip switch

  17. The DipSwitch must be connected to the Contact element of the Ladder. In the window Input Assist select Application > PLC_PRG > INPUT_01 (the variable which has been added to Contact):

    Configure the dip switch

  18. Select Lamp1 and in Properties select Variable. In the window Input Assist select Application > PLC_PRG > OUTPUT_01 (the variable which has been added to Coil):

    Configure the lamp

  19. With the connections made, we expect that o toggling the input DipSwitch, the output Lamp1 also toggles. To test, download the project for the device. Click the Online menu and select Login (always choose download):

    Download the application to the device

  20. With the project downloaded and online, the following screen will be shown and the project will be in the STOP state:

    Project ready to run on the device

  21. To start the application, click on play:

    Start the application

    At this point, the application will be in the RUN state. On the Visualization the elements can already be tested. Pressing the DipSwitch should light the Lamp1 on.

    Video illustration of the application running

  22. The Visualization feature also adds to the project the WebVisualization. Click on Visualization Manager -> WebVisualization on project tree. In the WebVisualization tab you can find the settings:

    Web visualization

    You can open your browser and remotely connect to the web visualization tool using the board hostname and port 8080: http://<hostname>:8080/webvisu.htm

    Triggering the DipSwitch will act both on the WebVisualization of the browser as in development environment Visualization:

    Video illustration of the web visualization

Local WebVisualization

To complement this demo, you can also run a web browser in full screen (kiosk) mode for WebVisualization on a touch screen connected to the target device. You can use the Torizon base Weston container as the graphical backend and a container running Chromium to serve the WebVisualization locally. Then access http://<hostname>:8080/webvisu.htm.

WebVisualization on the device

Next Steps

If you want to build the CODESYS demo container for any reason, the Dockerfile and related resources are available in the CODESYS Virtual Control for Linux SL 4.13.0.0 folder.

This container is a demonstration meant solely for evaluation purposes. For more information and custom requests (for instance if you need a solution ready to deploy on the field), please contact one of our partners BE.services, CODESYS GmbH or neXo.

Display and Touchscreen Configuration

For the displays recommended by Toradex, go to Setting up Displays with Torizon page.



Send Feedback!