Application #2: CODESYS OPC UA Publish/Subscribe¶
The following section is applicable to:

The OPC UA Publish/Subscribe Example makes use of the CODESYS Software PLC 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.
- Prerequisites
EC Protocol Bridge - Make sure that the EC Protocol Bridge is installed. For more information, refer to Install Edge Control Protocol Bridge.
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
Note: If the CODESYS IDE has not yet been installed on a Windows system, follow the section Install CODESYS IDE to install the CODESYS IDE. For more information on CODESYS, refer to CODESYS Software PLC
Attention
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.

Deploying CODESYS Application
The following section is applicable to:

Use the Intel edgesoftware utility to download the ECI release archive, if not done already.
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 theEdge-Controls-for-Industrial
directory as follows:└── Edge-Controls-for-Industrial ├── Codesys_Example_Applications.zip ├── Dockerfiles.tar.gz └── eci-release.tar.gz
Extract the CODESYS_Example_Applications.zip archive. Navigate to the OPCUA directory. Double-click ec-protocol-bridge_Linux_3.5.x.x.project to open the project with CODESYS.
When the project is first loaded, a message on failing to load library references might be displayed. Click OK. You will install these dependencies later.
A dialog listing newer library versions will be displayed. If you prefer, you may update to the suggested versions. Performing the update will not break the project.
When prompted to upgrade the storage format, click Yes. It is recommended to use the format suggested by CODESYS.
When the project opens, you may see a (?) mark next to Device (CODESYS Control for Linus SL) in the Devices pane. If this occurs, right-click Device (CODESYS Control for Linus SL) and select Download missing device description from the pop-up menu.
Follow the prompts to install the missing device.
At this point, compile to assess the missing libraries. Follow the menu path Build > Build.
After a build, the Messages tab (typically located at the bottom of the IDE) will display an error count. If there are any errors, it might be because of missing libraries. Double-click Library Manager from the Devices pane. A Library Manager tab will open in the right pane. You might need to expand the IDE window to see the buttons available in this tab. Click Download Missing Libraries.
A dialog will list the missing libraries. Make sure that all missing libraries are checked and click Download.
At this point, there might still be missing libraries (due to installation order dependency). Click Download Missing Libraries, if the button is still available.
A dialog will list the missing libraries. Make sure that all missing libraries are checked and click Download.
If Download Missing Libraries disappears, you are ready to rebuild the project. Follow the menu path Build > Build.
If all dependencies are installed, the build should complete without errors. Make sure that Messages tab shows zero errors. Close the Library Manager tab.
Double-click Ethernet from the Devices pane. You should see “eno1” listed as Interface, 192.168.255.12 listed as the IP address, and 255.255.255.0 listed as Subnet mask. The CODESYS Linux runtime residing on the target system (with ECI installed) will use this IP address.
Attention
If your system uses an Interface other than eno1, make sure to update the Interface used by the Ethernet device in the CODESYS project.
Connect the Windows PC and the target system together via an Ethernet network. Use the Ethernet port that corresponds to the Interface used in the previous step.
Modify the IP address assigned by Windows for the relevant Ethernet interface. Use the IP address “192.168.255.10” and subnet mask “255.255.255.0”.
You might also need to modify the Windows firewall to allow traffic to CODESYS from private networks. Open the Allowed apps and features firewall dialog and make sure that CODESYS and CODESYScontrol Service are selected. If the Windows PC and target system are connected correctly, you should be able to ping each system from the other.
The following steps are applicable to:
On the target system, restart 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 Intel CPUs and CODESYS have been observed. See Limitation #6 - Cannot start CODESYS Linux runtime for potential mitigation actions.
The following steps are applicable to:
In the CODESYS IDE, double-click Device (CODESYS Control for Linux SL) from the Devices pane. Click Scan Network… to probe for active CODESYS servers.
The Select Device dialog should list the a device named intel-rt-corei7-64…. Select this device and click OK.
When connecting to a device for the first time, you might be prompted to activate user management on the device. Click Yes to continue.
Add a device user which will be used to access the device. Remember the name and password, as this will be used again in later steps.
CODESYS will attempt to authenticate with the new device. At this time, do not try to authenticate. Click Cancel when prompted.
If a connection was established to the device, a green circle will appear next to it. At this point, click the Device drop-down menu and click Change Communication Policy….
In the Device User Logon dialog, enter the user name and password registered earlier.
By default, CODESYS does not allow anonymous OPC UA clients to connect to the OPC UA server. Modify the setting to allow anonymous login, so that the EC-Protocol Bridge can connect to the CODESYS OPC UA server. Select Allow anonymous login, then click OK.
Follow the menu path Online > Login.
If there is a warning related to version mismatch, ignore the warning and click OK.
When you are logging into the CODESYS Linux runtime for the first time, a message will appear indicating that no application exists on the target device. Click Yes to download the application.
After the application has completed uploading to the CODESYS Linux runtime, follow the menu path Debug > Start.
If everything is correct, green indicators will appear next to various components as shown in the following figure.
The following steps are applicable to:
On the target system, run the Edge Control Protocol Bridge to bridge OPC UA client/server protocol to OPC UA publish/subscribe protocol.
$ /opt/ec-protocol-bridge/plg-opcua-rt/examples/codesys/startDemo.sh
The script will ask you to connect the PC to a network. This was done in an earlier step, so press Enter.
The script will then prompt you to select an interface. Enter the number that corresponds to the Interface configured in the earlier steps (this example uses Interface “eno1”).
The script will ask if you would like to use the default IP address “192.168.255.12”, enter y. If you are using a different IP address, enter n and input your address when prompted.
The following steps are applicable to:
Open a web browser on the Windows PC and navigate to: http://192.168.255.12:8080. You should see the Visualization hosted by the CODESYS Linux runtime. You may rotate the dial to vary the value sent to the OPC UA client.
Note: 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.
If the CODESYS Linux runtime stops running due to the two-hour time limit, restart the runtime:
$ systemctl restart codesyscontrol
To run the CODESYS Linux runtime beyond two hours, you must purchase a license from the CODESYS Webstore. Refer to CODESYS Linux Runtime for various licensing options for CODESYS.