ReferenceDevice DriversOpc UaRead Task

OPC UA Read Task

Read data from OPC UA servers with read tasks.

Read tasks are the primary method for acquiring data from an OPC UA server and storing it in Synnax.

Prerequisites

Before configuring the task, you’ll need to have connected to an OPC UA server.

A Short Primer on Tasks

Tasks are the primary method for communicating with devices in Synnax. Tasks can be used for both control and data acquisition purposes. In the context of OPC UA, a read task defines a background process that reads data from your server at a specified sampling rate.

An OPC UA read task can be started, stopped, and re-configured at any time. We permanently store the configuration of the task in Synnax, so it’s easy to set up multiple tasks for different purposes.

Important Rules for Read Tasks

Sample Rates and Timing

All channels in a read task are sampled at the same rate. If you’d like to sample different channels at different rates, create a separate task to do so.

Synnax uses software timing to read from your OPC UA server, and typically delivers precision on the order of 100 microseconds. Under heavy load, this timing precision may degrade.

For low rate (<200 Hz) tasks where timing is not critical, we recommend letting Synnax automatically determine the timestamps for index channels.

For high-precision tasks, we recommend reading timestamps from the OPC UA server.

For high rate tasks (>500 Hz), we recommend sampling in array mode, where Synnax will read samples in bulk from the OPC UA server. Array mode requires more work to configure, but is far more efficient.

One Running Task per Channel

Synnax can only accept live data from a channel from one source at a time. If you have a task running that reads from a pressure channel, you cannot create another task that also reads from pressure.

Open the Task Configuration Dialog

To configure a read task, open the Synnax 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 “Create a New Read Task”. Select this option to open the read task configuration dialog.

You can also open the dialog by clicking in the top-right corner of the window and selecting the add icon, or opening the context menu on an OPC UA server from the resources toolbar.

Task Configuration Parameters

FieldDescription
NameA name for your read task.
OPC UA ServerWhich OPC UA server the task will read from.
Data SavingData saving defines whether acquired data will be permanently stored in Synnax. When enabled, Synnax will both stream and store data. When disabled, Synnax will only stream data for real-time visualization. Historical data will not be available for review.
Sample RateHow often, in Hz, Synnax polls data from the OPC UA server.
Array SamplingWhether to use array sampling mode for this task.
Stream RateHow often, in Hz, Synnax streams data to the Synnax database. This option is only available when array sampling is off.
Array SizeThe number of samples to read in bulk from the OPC UA server. This option is only available when array sampling is on.

Sample Rate vs. Stream Rate

There are two parameters to control the timing of the task: the sample rate and the stream rate. The sample rate defines how often Synnax will poll the OPC UA server for new data, while the stream rate defines how often the task will stream data into Synnax.

For example, if you set the sample rate to 10 Hz and the stream rate to 1 Hz, Synnax will poll the OPC UA server every 100 ms, collect 10 samples, and then forward these samples to the server.

For very low rate tasks (<50 Hz), we recommend setting the stream rate to the same value as the sample rate. For higher rate tasks, lowering the stream rate can significantly improve performance. It’s best to keep the stream rate below 50 Hz unless you need to quickly process incoming data in real-time.

Default Sampling vs. Array Sampling

The default sampling mode reads a single sample from the server for each channel in the task at the specified sampling rate. This is the simplest mode to configure, and is ideal for most applications that don’t require high data rates. We recommend setting the sampling rate to the same sampling rate as the OPC UA server.

Array sampling is a more advanced method of reading data from an OPC UA server, and is typically only necessary for very high rate tasks (>500 Hz). Instead of reading single samples from the server, Synnax will read many samples in bulk. Array sampling requires a little bit of tuning to set up.

When experimenting with array based sampling, we recommend running a separate Synnax database with a memory-backed data store. This will allow you to quickly test different configurations without writing a large amount of experimental data to your production database.

Running a task with array sampling enabled can result in both oversampling and undersampling. Oversampling occurs when the OPC UA server doesn’t completely replace all values in the array before Synnax reads it. Undersampling can occur when the OPC UA server is rewriting the array faster than Synnax can read it.

We recommend setting the sampling rate to the same sampling rate as the OPC UA server and setting the array size to be an integer factor of the sampling rate. For very high data rates, undersampling and oversampling by a few samples in the array can occur under normal operating conditions. This typically is not a problem.

Reading Timestamps from the OPC UA Server

If the time channels for your corresponding data channels are not in the task, Synnax will automatically generate timestamps when reading data from the server. This is fine when you are not concerned with the exact timing of the data.

If you would like to pull exact timestamps from the OPC UA server, simply add the time channel to the task.

Adding Channels to a Task

To add a channel to a task, simple find the desired channel in the browser and drag it over to the channels window. From here, you can change the name of the channel. If you would like to stop a channel from being read, you can click the disable/enable button to the right of the channel.

To configure the task, just click the “Configure” button. This will save the task configuration, and you will be able to pause and resume the tasks whenever you want.

Stopping and Starting Tasks

To stop and start a task, you can open up the task toolbar on the right-hand side and click play and pause. You can also click the play/pause icon in the bottom of the task configuration window.