Company Events Academic Community Support Solutions Products & Services Contact NI MyNI

Choosing a Method of Reading and Writing Shared Variables

LabVIEW 2013 Help

Edition Date: June 2013

Part Number: 371361K-01

»View Product Info

When choosing a method of reading and writing shared variables, you must consider several factors, including the following:

  • Update speed
  • Programming complexity
  • Scalability

The following table describes the use cases, advantages, and disadvantages of the methods you can use to read and write shared variables over a network.

Note  After you program your applications to read and write shared variables with one or more of the following features, you must deploy the shared variables to make them available on the network.
Method of Reading and Writing Shared Variables Recommended Uses Advantages Disadvantages
Programmatically with the Shared Variable functions Reading and writing large numbers of shared variables. For example, if you need to read 50 shared variables of the double data type in a specific project library, reading those shared variables programmatically is the most efficient method.
  • A single Shared Variable function can access multiple shared variables. Other methods can read and write only one shared variable at a time.
  • Scalable. If you add 50 shared variables to a project, you do not have to update your block diagram to read and write each of those variables.
  • Offers access to I/O variables.
Requires more programming than other methods because you must program your application to read and write shared variables that meet specific criteria.
With Shared Variable nodes
  • Reading and writing small numbers of shared variables. For example, if you need to update the values of 10 shared variables, you can use Shared Variable nodes.
  • Reading and writing data at a fast rate in a human-machine interface (HMI) application. For example, if you need to display the latest value from a temperature sensor once per second, use a Shared Variable node.
  • Offers access to I/O variables.
  • Ease of programming. To add a Shared Variable node to your application, drag a shared variable from the Project Explorer window to the block diagram of your application.
  • LabVIEW labels each Shared Variable node with the name of the corresponding shared variable.
  • Each Shared Variable node can access only a single shared variable.
  • Not scalable. You must add a Shared Variable node to the block diagram every time you want to read or write an additional shared variable.
With controls and indicators Reading and writing data at a slow rate in an HMI application. For example, if you need to display the latest value from a temperature sensor once every few seconds, read shared variables with an indicator. Ease of programming. To read or write a shared variable with a control or indicator, drag a shared variable from the Project Explorer window to the front panel of your application.
  • Does not enforce data flow. Therefore, the operations you can perform with the data you read and write are limited.
  • Does not indicate which controls and indicators access what shared variables.
  • Slower processing speed than using Shared Variable nodes.
  • Does not offer access to I/O variables.
With existing data sources Leveraging shared variable features for a data source that does not support those features. For example, real-time targets do not support DSC Module logging and alarming properties. Therefore, if you need to set DSC Module logging and alarming properties for a shared variable on a real-time target, you could create a new shared variable on your development computer, write that shared variable with the shared variable on the CompactRIO target, and configure the shared variable on the development computer for logging and alarming.
  • Offers access to I/O variables.
  • Adds configuration options to shared variables.
If you do not need to leverage shared variable features for a data source or if the data source already supports the features you need, this method is inefficient because you can read and write the data source directly.
With the DataSocket functions Reading and writing shared variables from Mac and Linux computers. The DataSocket functions are the only programming tools you can use to read and write shared variables from Mac and Linux computers.
  • Slower processing speed than the other methods of reading and writing shared variables.
  • Does not offer access to I/O variables.
With the variable Web service Reading and writing shared variables from Web-enabled platforms that support HTTP.
  • The variable Web service is the only programming tool you can use to read and write shared variables from many Web-enabled platforms that support HTTP.
  • Offers access to I/O variables.
If you do not need to leverage shared variable features for Web-enabled platforms that support HTTP, this method is inefficient and requires more programming than other methods.

 

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