DataSocket Read Returns 0 when Reading OPC Tag

Updated Apr 7, 2023

Reported In

Software

  • LabVIEW
  • OPC Servers

Issue Details

When I use DataSockets to read a tag from my OPC Server, the DataSocket Read VI returns a value of 0 even though I know my tag has a different value. When I check the Quality output of the DataSocket Read VI, it returns a quality code 8.

Solution

This can sometimes occur if you are trying to read the OPC tag immediately after opening the DataSocket connection to the OPC server. Place a short wait after opening the DataSocket connection before trying to read. A wait of 50 ms is generally sufficient, although a longer wait may be needed if you continue getting the bad quality data.

Additional Information

A quality code of 8 corresponds to the OPC DA code: Bad - Not connected. If data is being received correctly, then the quality code should be 192.