1. Start by creating an OPC UA Server. When utilizing, LabVIEW for generating the server, you can follow the
Creating an OPC UA Server and an OPC UA Client tutorial. If you are planning to use a third-party server, please refer to the specific instructions of your software or hardware, accordingly.
2. Depending on the number of tags you have on your server, divide them into different groups and distribute them equally when possible. For example, if your server contains 5000 tags, you can make five groups of 1000 tags each. At this point, you do not have to develop any code yet, just determine how you can divide your tags as this information will be useful later in the procedure.
3. Build a subVI to create and configure the OPC UA Client subscription. You can use the following pictures as a guide to design your subVI internally and its icon as well.
Note: This image is a LabVIEW snippet, which includes LabVIEW code that you can reuse in your project. To use a snippet, right-click the image, save it to your computer, and drag the file onto your LabVIEW diagram.
4. Create a Main VI and integrate your subVI with the groups of tags you defined earlier. Take a look at the following image for more information.
In the above image, the Node IDs array (the tags that you have in the server) is divided into different groups (according to what you decided in step 2) by utilizing the Array Subset function, and the resultant portions are wired to the subVI that was created earlier. In this way, an OPC UA Client subscription is generated for each group of tags. The Connect VI, will establish the connection to the OPC UA Server and pass the reference to each subVI.
To make sure the client subscription will be executed as quickly as possible and with no delay, you must modify the monitoring parameters accordingly. These parameters are composed of the elements shown in the image below.
When modifying them, you have to take into account the following considerations:
- The sampling interval defines, for each node ID, a time interval. This is the rate at which the server checks the data source for changes and it must be faster than the publishing interval (the rate at which the server returns data change notifications to the client) to avoid data loss.
- A queue is required to save the modified data while it is time to publish it to the client. This is when the queue size variable becomes important. This value has to be big enough so the queue can hold the data until the time to share it has come. In case the queue does not have the required size, LabVIEW will discard the oldest value to avoid overflow (set by the discard oldest variable).
- In general, the queue size is given by Queue Size = Publishing Interval / Sampling Interval.
- For getting more information about the trigger, deadband type, and deadband value parameters, please review the Add Monitored Data Nodes VI documentation.
5. Execute the code and verify its behavior. If you are experiencing a delay when reading the data in the OPC UA Client subscription, divide your tags into more groups with fewer data each. Repeat this process until you get the expected results.