How Can We Help?
< All Topics
Print

Connecting to Codesys via OPC-UA Protocol


Purpose of this article

This article aims to show how to connect ADISRA SmartView to Codesys via OPC-UA Protocol. In the example that will be shown, ADISRA SmartView will be the Client and Codesys will be the Server.

1. Downloading and Installing Codesys

  1. Access the website (https://store.codesys.com/en/) and download the version (32bit or 64bit) compatible with your operating system.

    Note: After clicking the download button, you will need to create an account.
  1. Start the installation wizard and install all the requirements.
  1. After installing the requirements, CodeSys will start installing, and then select the complete installation option.
  1. Once installed, check your desktop notification tray. Two new icons will appear. One is the CODESYS Gateway icon which operates the communication between the software and the PLC. The other is the PLC icon. Right-click on plc and select the about option. The Codesys version will be shown.

    Note:
    This version will be needed when creating a new project.

2. Creating a New Project in Codesys

  1. Open CODESYS.
  1. Create a new project (File -> New Project): Select Standard Project.
  1. In the Device option, select the CODESYS COntrol Win V3 X64 (that is, the same version that appeared in the windows icon tray). In the PLC_RPG option, keep it as Structured Text.
  1. In the Device option, select the CODESYS COntrol Win V3 X64 (that is, the same version that appeared in the windows icon tray). In the PLC_RPG option, keep it as Structured Text.

2. Creating a New Project in Codesys

  1. In the navigation tree, right-click Application->Add Object->Global Variable List…
  1. Name this object “TAGS” and click OK.
  1. Right-click on the created TAGS object and click on properties.
  1. On the Build tab, check the “Always Link” option.
  1. Double-click on the TAGS object to open the code area. Then insert some tags which will be read by SmartView. Below is an example of declaring some tags.
  1. After creating the tags, right click on Application->Add Object->Symbol Configuration
  1. Click the “Build” button.
  1. Select the TAGS which will be shown in the communication and click on the “Build” button again.
  1. Keep the option to support OPCUA features checked.

3. Starting PLC communication

  1. In the icon tray, right-click on the Codesys icon and check if the PLC is in the “Started” option.
  1. After starting the plc, in the navigation tree, click on the “Device” option and then on “Scan Network”.
  1. Select the PLC available on the network and then click OK.
  1. If this is your first connection to the PLC, you will need to create a username and password.

4. OPC UA Security Settings

  1. In the navigation tree, right-click on “Device” and then on “Security Setting”. A new window will be shown. This window contains the OPC-UA protocol security settings. For the example, we will keep the settings below.

5. Generating OPC UA Server certificates

  1. Click on the “View” tab and then on “Security Screen”.
  1. Then click on the Devices option and click on each step shown below to generate a new certificate.
  1. A new certificate has been generated!

6. Download the project to the PLC

  1. After doing all the above settings, save the project and click the PLC login button and confirm the download. If after confirmation a new window appears asking for a password, enter the same user and password previously created when connecting to the PLC.
  1. Click “Yes”.

6. Connecting to SmartView

  1. Now, open ADISRA SmartView, create a new project, create a new OPC-UA connection and fill in the fields with your project information, for example, IP where the PLC is, user and password previously created and the security definitions made previously.

    After configuring, click the “…” button and a window will open. In step 7 the image below will show a “BadSecurityChecksFailed” error message. This message is shown because the certificate needs to be validated in COdesys. So go back to Codesys.
  1. Click on the “View” tab, and then click on the “Security View” option. Then, as per the steps shown below, click on the “Quarantined Certificates” folder. A new certificate will be shown. This certificate pertains to the OPC-UA communication between Codesys and ADISRA SmartView. Click and drag this new certificate into the “Trusted Certificates” folder. After that, click on the update button. Now the OPC-UA connection between Codesys and ADISRA SmartView is enabled.
  1. Run the PLC as shown below.
  1. Return to the ADISRA SmartView engineering environment, click the “…” button again to open the OPC-UA browser. Find available tags.

Leave a Reply

Your email address will not be published. Required fields are marked *

eleven − 8 =

Table of Contents