What Is the Difference Between Using Shared Variables and DataSocket VIs to Access OPC Tags?

Updated Nov 16, 2023

Reported In

Software

  • LabVIEW
  • LabVIEW Full
  • LabVIEW Professional

Issue Details

I have a configured and running OPC server and I would like to read and write my tags in LabVIEW. I have the DSC Module installed and I know I can make shared variables bound to my OPC tags. I can also open a DataSocket connection to my tag with the DataSocket VIs. What is the difference between these two methods?

Solution

From a performance standpoint, there is no difference between these two methods when the DataSocket is configured correctly. At run time, accessing the tags will happen at the same rate and with the exact same behavior. To configure the DataSocket connection correctly, ensure that you open and close a connection to your tag only once when reading or writing from it iteratively, as shown in the following screenshot. 
From an implementation standpoint, there is an important difference between the two methods. The shared variable method uses an OPC client that is built into the shared variable engine. This OPC client is added by the DSC module. In order to bind shared variables to OPC tags, you must have the DSC module installed. The DataSocket method uses a different OPC client built into the DataSocket implementation in LabVIEW. Because DataSockets are a standard part of LabVIEW, you do not need any special software modules to access your OPC tags with this method.