Examples
  • 11 Nov 2024
  • 3 Minutes to read
  • PDF

Examples

  • PDF

Article summary

Connecting to N3uron's OPC UA Server from UA Expert Client

This is a detailed step-by-step guide to connecting to N3uron's OPC UA Server using the UA Expert Client, which can be downloaded from https://www.unified-automation.com/

  • Step 1: Create an instance of the module: (Config => Modules => button to the left of Modules => New module)

Figure - New module(1)


  • Step 2: Provide a name for the module, in this case, OpcUaServer, set the module type to OpcUaServer, and configure the new module instance as shown below.

Figure 7- Configure the module


  • Step 3: Set the API and Logger configuration as default. Next, it's time to configure the module to establish which networks will be able to establish communication.

  • Step 4: Configure the main parameters of your OPC UA Server instance according to your needs. 

Figure - OPC UA Server Config


  • Step 5: As we don't want to allow Anonymous users to access the server, we need to add a role with the corresponding permissions for it. In this case, we have added the Administrator role with all the permissions enabled and no restrictions regarding tag access. 

Figure - Example OPC UA Server Access

Figure - New Role 2


At this point, the server is fully configured. Now, let's configure the connection in UA Expert. 

  • Step 6: Inside UA Expert, click on Servers and select Add to add a new server.

Figure 11 - Add Server


  • Step 7: Click on Custom Discovery and introduce the discovery URL of the server previously configured.

Figure 12 - Select server

  • Step 8: Select the target endpoint with the desired security policy. In this case, Basic256Sha256.

Figure 13 - Select Basic256Sha256


  • Step 9: Now, connect with the N3uron OPC UA Server.

Figure 14 - Connecting


  • Step 10: After connecting, enter the credentials of a user with administrator permissions. In this case:
    • Username: admin.
    • Password: n3uron.

Figure 15 - Introducing the credentials


  • Step 11: Once the credentials are introduced, Trust the Server certificate.

Figure 16 - Trusting the certificate


  • Step 12: Navigate to N3uron and trust the certificate issued by UA Expert to enable the connection.

Figure - Trust(1)


  • Step 13: Once trusted, UA Expert will allow browsing of the server. 

Figure - Root

How to Access Historical Data (HA)



N3uron supports Historical Data Access (HA), which allows the client to fully access historical data from the server (using the Historian module). In this example, we're going to retrieve historical data corresponding to 3 sinusoidal signals that are 120º out of phase with each other.

  • Step 1: Once the OPC UA Server module is created and configured and the connection is successfully established, go to UA Expert and in Document, click on Add.

Figure - Sinus 3


  • Step 2: Now, select History Trend View and click on Add.

Figure - Sinus 4


  • Step 3: Inside the Address Space select the tags you want to visualize and drag them to the Configuration section within History Trend View.

Figure - Sinus 5


Figure - Sinus 6


  • Step 4: Enter the Start and the End time according to the period you want to visualize and click on Get Start Time.

Figure - Sinus 7


  • Step 5: Now, click on Update to visualize the History Data diagram. 

Figure - Sinus 8

Figure - Example OPC UA Server HDA


Creating and Configuring a Method


Using methods, N3uron enables additional complex functions to be launched (provided by the Scripting module) by using an OPC UA method. In this example, we're going to show how to create a method for adding two values.

  • Step 1: Create a New Task in the Scripting module.

Figure - Scripting 1


  •  Step 2: Then, create a New Action. We've called it Methods. This action must be an External action type.

Figure - Scripting 2


  • Step 3: Once created, generate a new script named Sum by clicking on New Script. When the OPC UA Server module calls an external script, the input arguments can be used in the script by using $.event.ARGUMENT_NAME. Additionally, if the script needs to return one or more values to the OPC UA Server, this must be done by returning an object whose keys are the output arguments.

Figure - Scripting 3


Figure - Scripting

Figure - Script


  • Step 4: To configure the Method, go to Methods inside OPC UA Server and click on New Method.

Figure - Scripting 4


  • Step 5: Once created, enable it and select the corresponding Scripting instance and the name of the script. In this case, we select the Sum script previously created and insert a description of the method.

Figure - Configuring a Method


  • Step 6: Now, let's create the corresponding arguments. First, we will create the Input arguments.

Figure - Scripting 5


Figure - Input arguments


  • Step 7: Then, create the Output arguments and the method is ready to use.

Figure - Scripting 6


Figure - Output arguments


  • Step 8: Now, if we go to UA Expert, we can invoke the Sum method as shown in the image below.

Figure - Methods



Was this article helpful?

What's Next