Edge Controls for Industrial CODESYS Tutorial

Target System: Edge Controls for Industrial (ECS) image

Developer Machine: Windows*

Time to Complete: 20 minutes

Software Used: CODESYS

codesys

CODESYS OPC UA Publish/Subscribe

The OPC UA Publish/Subscribe Example makes use of CODESYS and the Edge-Control Protocol Bridge to showcase bringing OPC UA Client/Server Model to OPC UA Publish/Subscribe Model. In this example topology, the Edge-Control 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 Edge-Control Protocol Bridge makes available.

Prerequisites

  • A Windows* system (x64 bit) with CODESYS IDE
  • An Edge Control System image with the CODESYS Software PLC feature option enabled. (See Building Edge Controls for Industrial Targets)
  • A target system with the Edge Controls for Industrial image (with CODESYS Software PLC) installed (See Installing Edge Controls for Industrial Images)
  • 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 CODESYS IDE Installation to install the CODESYS IDE. For more information on CODESYS, see the following section: CODESYS Software PLC

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

codesys install screen

Deploying CODESYS Application

The following section is applicable to Windows.

windows image

Step 1. Extract

  1. Extract the CODESYS_Example_Applications.zip archive provided with the Edge Controls for Industrial bundle.
  2. Navigate to the OPCUA directory.
  3. Double-click on ec-protocol-bridge_Linux_3.5.15.40.project to open the project with CODESYS.

Step 2. Failure to load libraries

When the project is first loaded, CODESYS may present a message about failing to load library references. This is OK for now, as we will be installing these dependencies in the upcoming steps.

Library references did not load message

Click OK.

Step 3. Newer library version

CODESYS may present a dialog prompting about newer library versions. If you prefer, you may update all the suggestions. Performing the update will not break the project.

llibrary

Step 4. Storage

CODESYS may present a dialog asking about storage format. It is recommended to use the format suggested by CODESYS.

storage

Click Yes.

Step 5. Control for Linux SL

When the project opens, you may see a (?) mark next to Device (CODESYS Control for Linux SL) in the Devices pane.

If this occurs, right click on Device (CODESYS Control for Linux SL) and select Download missing device description from the context menu. Follow the prompts to install the missing device.

Device selection

device download

Step 6. Build and Download Missing Libraries

A compilation attempt needs to be performed to assess which libraries are missing. If there are missing libraries, follow the instructions in the Download Missing Libraries section.

Open the Build menu, select Build.

build selection under ... build

After a build, the Messages tab (typically located at the bottom of the IDE) will display an error count. If you have errors, chances are likely libraries are missing. See the Troubleshooting section for more information about downloading missing libraries.

If all dependencies are installed, the build should complete without errors.

  1. Check the Messages tab for errors.
  2. If there are 0 errors, close the Library Manager tab

tcp/ip v4

Download Missing Libraries

  1. Double-click the Library Manager from the Devices pane. A tab will open. You may need to expand the IDE window to see all the available buttons in the tab.

  2. Click the Download Missing Libraries button.
  3. A dialog will appear showing missing libraries.
  4. Ensure all missing libraries are checked
  5. Click the Download button.

download missing librariea

download missing libraries download button

At this point, there may still be missing libraries (due to installation order dependency). If the Download Missing Libraries button is still available, click it again.

download libraries button

A dialog will display with the missing libraries.

  • Ensure all missing libraries are checked.
  • Click the Download button.

download libraries buttonIf the Download Missing Libraries button disappears, you are ready to build the project again.

Open the Build menu and select Build.

Step 7. Allow Traffic

You may also need to modify the Windows firewall to allow traffic to CODESYS from private networks.

  1. Open the Allowed apps firewall dialog
  2. Ensure CODESYS and CODESYScontrol Service is checked.

If the Windows PC and target system are connected correctly, you should be able to ping each system from each other.

firewall settings

The following steps are applicable to the target system.

yocto image

On the target system, restart the CODESYS Linux runtime with the following command:

systemctl restart codesyscontrol

The following steps are applicable to the Windows PC.

  1. In the CODESYS IDE, double-click on Device (CODESYS Control for Linux SL) in the Devices pane.
  2. Click the Scan Network… button to probe for active CODESYS servers. ​
  3. A dialog will display with a device named intel-rt-corei7-64…listed.

device communication settings

4. Select this device.

5. Click OK.​

select device

Step 8. Login

  1. ​Open the Online menu.
  2. Select Login. ​

login screen

A warning message may display about a version mismatch.

3. You may safely ignore the warning by clicking OK.

warning message

If this is the first time logging into the CODESYS Linux runtime, a message will display indicating that no application exists on the target device. Click Yes to download the application.first use

After the application has completed uploading to the CODESYS Linux runtime, open the Debug menu and select Start.

download manager

If everything is correct, green indicators will display next to various components in the devices list.

indicators

The following steps are applicable to the target system.

yocto

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 example will begin printing messages to the terminal.

  1. The script will prompt you to connect the PC to a network. This was done in an earlier step. Press Enter.
  2. 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).
  3. 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 the Windows PC.

windows

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.

gif

Note: The CODESYS Linux runtime will continue to run without a license for up to two hours.

If the CODESYS Linux runtime stops running due to the two hour time limit, you may restart it using the following command:

systemctl restart codesyscontrol

If you desire to run the CODESYS Linux runtime beyond two hours, you must purchase a license from the CODESYS Webstore. See section CODESYS Linux Runtime for various licensing options for CODESYS.

Product and Performance Information

1

Intel's compilers may or may not optimize to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors. These optimizations include SSE2, SSE3, and SSSE3 instruction sets and other optimizations. Intel does not guarantee the availability, functionality, or effectiveness of any optimization on microprocessors not manufactured by Intel. Microprocessor-dependent optimizations in this product are intended for use with Intel microprocessors. Certain optimizations not specific to Intel microarchitecture are reserved for Intel microprocessors. Please refer to the applicable product User and Reference Guides for more information regarding the specific instruction sets covered by this notice.

Notice revision #20110804