02/25/2026
How-To | PLC | OPC UA

Calling PLC Methods via OPC UA on ctrlX CORE

Introduction

This How-To explains how to expose PLC methods as OPC UA methods on ctrlX CORE and how to call them using the OPC UA Server App together with the UA.TestClient.

Prerequisites

Used Hardware

  • ctrlX CORE X*-Serie or ctrlX COREvirtual

Used Versions and Required Software

Procedure

Create a PLC Method

  1. Open ctrlX PLC Engineering. To add a Function Block select the Application and there navigate to "Add object" and select "POU...". In the properties of the Function Block set the Name to "FB_Calc" and select the Type "Function Block".

    Fig. 1.: Adding a POU
Fig. 2.: Select Name and Type of POU
  1. Inside the Function Block create a new method. To do this select the Function Block right click and navigate to "Add Object" and select "Method...". In the Method properties, set the Name to "AddTwoNumbers", the "Return Type" to "INT" and the "Implementation Language" to "ST".

Fig. 3.: Adding an Method to the Function Block
Fig. 4.: Select Configuration of Method
  1. In the method editor, add the declaration for two INT variables, "a" and "b" and add the implementation of the function "AddTwoNumbers" which returns the sum.

    Fig. 5.: Declaration and implementation of FB

    //Declaration:
    METHOD AddTwoNumbers : INT
    VAR_INPUT  
      a : INT;   
      b : INT;
    END_VAR
    //Implementation:
    AddTwoNumbers := a + b;
    
  2. In "PLC_PRG", add the declaration of "FB_Calc". In the implementation, add the call of your Function Block. After this, build the Project.

    Fig. 6.: Declaration and implementation of PLC_PRG
    //Declaration:
    PROGRAM PLC_PRG
    VAR  
       fbCalc : FB_Calc;
    END_VAR
    //Implementation:
    fbCalc(); 

Enable Symbol Configuration

  1. In PLC Engineering, open the symbol configuration.

Fig. 7.: Open the symbol configuration
  1. In the "Symbol Configuration" window, expand the "PLC_PRG" symbols and then select "fbCalc". After that, select the "..." to define the "Members".

    Fig. 8.: Symbol Configuration of "fbCalc"
  2. Select the method "AddTwoNumbers()". If possible, choose it directly, if it is marked with an asterik "*", you do not have to select it . In the Access Rights section, of the method set it to executable, which corresponds to the flash icon. Afterwards, select "OK".

    Fig. 9.: Define Access Rights to AddTwoNumbers()
  3. Rebuild the project, log in to the ctrlX Core, and then start the application.

    Fig. 10.: Steps to start the application

Call the Method with UA.TestClient

  1. Open the UA.TestClient tool. Then select "Connect" to establish a connection to the local OPC UA server.

Fig. 11.: Establish a connection with the OPC UA Server
  1. Insert the URL of your ctrlX Core in the format opc.tcp://<HostAddress>:4840 and provide the corresponding User credentials . Then press "Find" to display all available connections.

Fig. 12.: Find the Server Endpoints Configuration

Default Settings

IP-Address:

  • Virtual Core: opc.tcp://127.0.0.1:4840

  • Core: opc.tcp://192.168.1.1:4840

User:

  • Username: boschrexroth

  • Password: boschrexroth

  1. In the Connections dialog, select "Basic256Sha256" and confirm with "OK". If an certificate appears, choose "Trust" to continue.

Fig. 13.: Selection of the Server Endpoint that are available
  1. To complete the setup, you also need to trust the certificate on the ctrlX OS side. To do this, navigate to "Settings → Certificates & Keys" and select "OPC UA Server". In this view, locate the "UA.TestClient" certificate, open the "…" menu next to it, and select "Trust".

    Fig. 14.: Trust UA.TestClient certificate on ctrlX OS side
  1. Once the connection is established, navigate through the path /Objects/Datalayer/plc/app/Application/sym/PLC_PRG/fbCalc/ and locate the method "AddTwoNumbers". Select "AddTwoNumbers" and then choose "Call" to execute the method.

Fig. 15.: Calling of the method AddTwoNumbers
  1. Enter input arguments in the Value column, then select "Call" to execute the method.

    Fig. 16.: Entering values for the method AddTwoNumbers
  2. The result of the "AddTwoNumbers" method is shown in the Output Arguments under "Value" immediately after the call.

Fig. 17.: Result of the method call

Related links

How-to_Calling_PLC_Methods_via_OPC_UA.zip
267.69KB
Types
How-to
Products
PLC
IOT
Markets
Manufacturing
Assembly Lines
Building Automation
Logistic
Packaging
Printing
Production Machines
Robotics
Semicon & Electronics
Sonstiges

Latest published/updated articles