Company Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI

Sharing Live Data Programmatically

LabVIEW 8.5 Help
August 2007

NI Part Number:
371361D-01

»View Product Info

You can wire a Shared Variable node into VIs and functions or use the DataSocket VI and functions to programmatically configure, read, or write live data.

Note  You can create, configure, and host shared variables only on Windows or RT targets with the LabVIEW Real Time Module. You can use the DataSocket VIs and functions to read or write shared variables from other platforms. If you have a VI with a Shared Variable node that was configured on a Windows system, you also can move that VI to another platform.

You read or write data by specifying a URL in much the same way you specify URLs in a Web browser.

Specifying a URL

URLs use communication protocols, such as psp, dstp, opc, ftp, http, and file, to transfer data. The protocol you use in a URL depends on the type of data you want to write and how you configure your network.

You can use the following protocols when you read or write data using the DataSocket VI and functions or when you enable a connection for a control:

  • (Windows or RT Module) NI Publish-Subscribe Protocol ( psp )—National Instruments technology for transmitting data between the network and your local computer. When you use this protocol, the VI communicates with the Shared Variable Engine. Use the psp protocol to connect to shared variables and server or device data items. You must provide a name for the data item, which is appended to the URL. The data connection uses that name to address a particular data item in the Shared Variable Engine. You also can use this protocol when using front panel data binding. You can use the fieldpoint protocol as an alias for NI-PSP.
Note  You can use the NI-PSP protocol to write data only from Windows NT/2000/XP and RT FieldPoint platforms. However, you can use the NI-PSP protocol to read data on all LabVIEW-supported platforms.
  • DataSocket Transport Protocol ( dstp )—When you use this protocol, the VI communicates with the DataSocket Server. You must provide a named tag for the data, which is appended to the URL. The data connection uses the named tag to address a particular data item on a DataSocket Server. To use this protocol, you must run a DataSocket Server.
  • (Windows) OLE for Process Control ( opc )—Designed specifically for sharing real-time production data, such as data generated by industrial automation operations. To use this protocol, you must run an OPC server.
  • (Windows) File Transfer Protocol ( ftp )—You can use this protocol to specify a file from which to read data from an FTP server.
Note  To read a text file from an FTP site using DataSocket functions, add [text] to the end of the URL.
  • file—You can use this protocol to provide a link to a local or network file that contains data.
  • (Windows) http—You can use this protocol to provide a link to a Web page that contains data.

The following table shows examples of each protocol URL.

URL Example

psp

For shared variables:

psp://computer/library/shared_variable

For NI-PSP data items, such as server and device data items:

psp://computer/process/data_item

fieldpoint://host/FP/module/channel

For dynamic tags:

psp://machine/system/mypoint, where mypoint is the named tag for the data

dstp

dstp://servername.com/numeric, where numeric is the named tag for the data

opc

opc:\National Instruments.OPCTest\item1

opc:\\computer\National Instruments.OPCModbus\Modbus Demo Box.4:0

opc:\\computer\National Instruments.OPCModbus\Modbus Demo Box.4:0?updaterate=100&deadband=0.7

ftp

ftp://ftp.ni.com/datasocket/ping.wav

ftp://ftp.ni.com/support/00README.txt[text]

file

file:ping.wav

file:c:\mydata\ping.wav

file:\\computer\mydata\ping.wav

http

http://ni.com

Use the psp, dstp, and opc URLs to share live data because these protocols can update remote and local controls and indicators. Use the ftp and file URLs to read data from files because these protocols cannot update remote and local controls and indicators.

Data Formats Supported by the DataSocket VI and Functions

You can pass data of any LabVIEW data type using the DataSocket VI and functions. You also can use the DataSocket VI and functions to read and write the following data:

  • Raw text—Use raw text to deliver a string to a string indicator.
  • Tabbed text—Use tabbed text, as in a spreadsheet, to write data in arrays. LabVIEW interprets tabbed text as an array of data.
  • .wav data—Use .wav data to write a sound to a VI or function.
  • Variant data—Use variant data to read data from another application, such as a National Instruments Measurement Studio ActiveX control.

Resources


 

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
Add Comments 1 2 3 4 5 submit