Connect to an OPC UA Server
Learn how to connect to a server using the Synnax OPC UA driver.
The first step to acquiring data from your PLC is to connect to to an OPC UA server running on the device.
Prerequisites
Before you can connect to an OPC UA server, you’ll need to have the following configured:
- A Synnax deployment running on your network.
- The Synnax Console installed on your machine.
- An OPC UA compliant server running on your device. This server should be reachable from the Synnax database deployment.
Step 1 Open the Connection Dialog
We’ll use the Console’s configuration workflow to connect to your server. To kick things off,
open the Console and click on the Quick Search & Command Palette at the top. You can also
open this palette with Ctrl+Shift+P
on Windows/Linux or Cmd+Shift+P
on macOS.
In command mode (enabled when the first character in the input is ”>”), type “OPC UA”. You’ll see an option called “Connect a New Server”. Select this open to open the server configuration dialog.
Step 2 Configure the Connection
The dialog will prompt you to enter the connection parameters to your server. Here’s a reference for each of the fields you’ll need to fill:
Field | Description |
---|---|
Name | A human-readable name for your server. We’ll use this to identify and manage the server in the Console. |
Endpoint | The endpoint URL for your server. This should be it’s reachable address on the network, and typically begins with opc.tcp:// . |
Username | The username to use when connecting to the server. This is optional and can be left blank. |
Password | The password to use when connecting to the server. This is optional and can be left blank. |
Step 2.1 Test the Connection
Before moving on to the next step, make sure to use the “Test Connection” button to verify that the Console can connect to the server. Here’s a quick video to show you how to do this:
After you’ve successfully connected the server, hit “Next” to continue to the next step in the workflow.
Step 3 Create Synnax Channels
The next step in the workflow is to create the channels in the Synnax database that correspond to the nodes on your server. Synnax will automatically scan your server for nodes and present them as a list along with their data types, paths, and browseable names.
Step 3.1 Identify Sampling Groups
Channels in the configuration dialog are organized into sampling groups. Each group has a special Index channel that is used to store the timestamps for the samples recorded by each channel in the group. Indexes are identified by a green Index badge underneath their data type.
The important rule to remember is that all channels in a group must be sampled together.
For example, if you have a temperature
and a pressure
channel in the same group, both
channels must be sample at the same rate. It’s not possible to sample temperature
at
1KHz and pressure
at 10Hz in the same group.
It is possible, however, to disable sampling for a channel when configuring a task.
For example, you could read from the temperature
channel without reading from the pressure
channel.
As long as you don’t write to two different channels with the same index at the same time,
Synnax is happy.
We’ve automatically placed all detected channels into a single group. To create additional
sampling groups, click the +
button in the groups section of the dialog. You can then drag
and drop channels between groups to organize them as needed.
By default, we place all of the channels into a single sample sampling group. You
can create additional groups by using the +
button in the groups section of the
configuration dialog. Then, drag and drop channels between groups to organize them as
needed.
When in doubt, separate channels into different groups. Although it incurs a performance and storage overhead to store the timestamps for each group, it provides a higher degree of flexibility in the future.
Step 3.2 Remove Undesired Channels
If you have channels that you don’t want to create in Synnax, simply select them (using
standard Shift
and Ctrl
/Cmd
modifiers), right click, and select “Remove”. This will
remove the channel from the list and prevent it from being created in the database.
Step 3.3 Edit Channel Properties
To edit the properties of a channel, simply select it and it’s properties will appear in the bottom panel. Feel free to adjust the name, data type, and corresponding node as needed.
Be careful when changing the data type of the channel. Some data types will not have the sufficient precision to store the data from your node. If you’re ok with the loss of precision, Synnax will automatically convert the data to the new type when it reads from the OPC UA server.
Step 3.4 Correctly Configure Indexes
By default, we add a generically named Time
index to each group (we recommend renaming
this to something more specific such as my_opc_server_g1_time
). By default, this index
will have its timestamps generated by the Synnax driver instead of reading them from
the OPC UA server. This works for low-timing precision applications.
For high data rates and precise applications, we recommend reading timing information from the server, delete this channel, find the correct node you’d like to read timestamps from, and toggle the switch in its properties to mark it as an index.
Synnax stores timestamps as 64-bit precision integers in nanoseconds from the unix epoch in UTC.
We recommend using OPC UA’s DateTime
data type for timestamps. We’ll automatically convert
these values to the correct format when we read them from the server. It’s also possible to use
Int64
or UInt64
data types, but you’ll need to ensure that the server records the timestamps
in the correct format.
Considerations for High Data Rates
For most use cases, Synnax is configured to read data from your server in single sample batches. Depending on the PLC, OPC UA Server, and network configuration, this configuration works well for applications up to 250Hz.
For higher data rates, we recommend configuring your server to expose data in arrays. Synnax can then read these arrays in as ‘chunks’, reading many samples with a single request. We’ve successfully tested this configuration up to 10KHz. Correctly setting up your PLC to record data in an array based configuration is more complicated. Here’s how to do it.
Step 3.5 Configure Channels for Array Nodes
In your PLC software, configure your OPC UA server to expose arrays of samples as nodes as opposed to single samples. We recommend the length of these arrays to be a multiple between 20 and 30 times smaller than your desired sampling rates. For example, if you want to sample at 1KHz, we recommend setting the array length to 33 samples (1000/30). This means that Synnax will read 33 samples in a batch, streaming them at a rate of 33Hz for visualization and real-time analysis.
For array based sampling to work correctly, all nodes in the sampling group must be array nodes, and all nodes in the group must have the same length.
Step 3.6 Timing Considerations
When using array based sampling, we highly recommend reading the timestamps from the OPC UA server. Synnax cannot determine the correct timestamps for each sample in the array, and will interpolate based on the time of the request and the data rate.
We recommend setting up a node containing an array of DateTime
values, and marking
that as your index for the sampling group. Here’s an example configuration for high
sampling from two data channels and a timestamp channel:
Step 4 Confirm
After you’ve defined your sampling groups, hit “Next” to move to the configuration dialog. Once you’re ready to proceed, hit “Configure” and Synnax will create the channels in the database. Once that process completes, press “Done” to close the dialog.
Next Steps
Now that you’ve connected to your server and created channels, it’s time to set up data acquisition tasks. We recommend starting with the Read Task to read data from your server.