Using the LabVIEW Shared Variable and OPC With NI-DAQmx
Table of Contents
The National Instruments Getting Started with NI-DAQmx Series is aimed at helping you learn NI-DAQmx programming fundamentals. Through video and text tutorials, this series will take you from verifying your device's operation in Measurement & Automation Explorer (MAX) to programming data acquisition applications using LabVIEW. It is intended for both the beginner who wants to learn how to use the DAQ Assistant, as well as the experienced user who wishes to take advantage of advanced NI-DAQmx functionality.
Overview
National Instruments LabVIEW 8 simplifies the creation of distributed data acquistion and control applications. All NI-DAQmx devices are available for use with the LabVIEW 8 shared variable engine through NI-DAQmx 8. In addition to compatability with LabVIEW 8, NI-DAQmx 8 also supports the connection of NI data acquisition (DAQ) devices to enterprise industrial systems using OPC (OLE for process control).
What is the shared variable engine?
The shared variable is a simplified programming interface for sharing data and is new technology introduced by and only available with LabVIEW 8. Using the shared variable, you easily can pass data within a system and also between systems -- even real-time systems -- without impacting performance.
Once a shared variable has been created using the appropriate scope, all data written to the variable is available to all systems, loops, applications, etc. within that scope. Examples of scope include single-process (one system) and network-published (multiple systems) No more communication loops. No more RT FIFOs. No more struggling with low-level TCP functions. You simply configure shared variables through simple dialogs to pass data among systems or bind them to different sources. You also can add data services, such as logging, alarming, and events, through dialogs using the LabVIEW 8 Datalogging and Supervisory Control Module.
The shared variable engine manages the use, connectivity, and performance of all shared variables on your many data acquisition and control systems. The engine is what makes it so easy to quickly and intelligently share data between many systems and sub-systems using LabVIEW 8 but does not limit you to connectivity only within LabVIEW 8 systems. The shared variable engine shows its open design by allowing plug-ins for standards, including OPC, to be created and integrated into the shared variable engine extending the connectivity beyond NI hardware and software solutions.
The shared variable is one of 4 key elements in the Distributed Intelligence available using LabVIEW 8. To learn more about Distributed Intelligence, visit ni.com/labview.
How do I bind a shared variable to a NI-DAQmx Virtual Channel?
The shared variable can be bound to both local (project) and global (MAX) NI-DAQmx Virtual Channels.
Create a Project Virtual Channel
- In the Project Explorer Window, right-click My Computer.
- Select New»NI-DAQmx Channel to open the wizard.
Create a Project Variable
- In the Project Explorer Window, right-click My Computer.
- Select New»Variable.
- Bind the Project Variable to the Project Channel
- Select ProjectTemperatureChannel under Project Name >> My Computer
Create a Global Virtual Channel
- Open MAX from Programs >> National Instruments
- Right-click Data Neighborhood and select Create New
- Select NI-DAQmx Global Virtual Channel to open the wizard
Create a Project Variable from a MAX Channel
- In the Project Explorer Window, right-click My Computer
- Select New >> Variable
- Click Browse
- Selecting Network Published Source >> Network Items
Using the shared variables in a LabVIEW VI
Simply drag the variables from the Project Explorer windows into the block diagram. In the example below, the shared variables will be read with each iteration of the loop. When you are using a Network Shared Variable, you also have the option to create a shared variable for the Server Polling Rate. The Server Polling Rate determines how often the shared variable gets new data from its network Global Channel.
What is OPC?
OLE for Process Control (OPC) is the original name for a standard developed in 1996 by an industrial automation industry task force. The standard specified the communication of real-time plant data between control devices from different manufacturers. The standard is now maintained by the OPC Foundation and has been renamed the OPC Data Accessstandard. The current version of the OPC Data Access specification is OPC Data Access 3.0.
OPC was designed to bridge Windows based applications and process control hardware and software applications. It is an open standard that permits a consistent method of accessing field data from plant floor devices. This method remains the same regardless of the type and source of data. Traditionally, any time a software package needed access data from a device, a custom interface, or driver, had to be written. The purpose of OPC is to define a common interface that is written once and then reused by company, SCADA, HMI, or custom software packages.

Figure 2. OPC is designed to improve enterprise system connectivity
Once an OPC server is written for a particular device, it can be reused by any application that is able to act as an OPC client. OPC servers use Microsoft’s OLE technology (also known as the Component Object Model, or COM) to communicate with clients.
Learn more about OPC from Wikipedia, the OPC Foundation, and from ni.com/opc.
What is the role of NI-DAQmx 8 in providing OPC connectivity?
When National Instruments developed the shared variable engine it also developed an OPC Server so data available through the engine would be available to enterprise wide applications. In addition to device driver calls using the application programming interface, NI-DAQmx 8 also makes all devices available through the shared variable engine. By default, NI-DAQmx 8 installs all components necessary to connect to NI data acquistion devices supported by NI-DAQmx.

Figure 3. NI-DAQmx 8 makes all NI-DAQmx devices available for OPC connectivity
NI-DAQmx 8 enumerates all NI-DAQmx global virtual channels configured in the Measurement & Automation Explorer (MAX) utility, including analog input and output, digital input and output, and counter input and output virtual channels, making them available in LabVIEW and other system nodes through the shared variable engine. You must have at least one global virtual channel defined either in the project or in Measurement & Automation Explorer (MAX) to use this feature. Global virtual channels of any I/O type can be bound to shared variables, but tasks cannot.
Is LabVIEW 8 required for OPC connectivity using NI-DAQmx 8?
Because LabVIEW 8 installs the shared variable engine and an OPC server for the engine, any LabVIEW 8 application can provide data to an OPC client through these tools. However, LabVIEW 8 is not required in order to connect to a National Instruments data acquisition devices using NI-DAQmx 8. NI-DAQmx 8 also installs the shared variable engine and an OPC server for the engine so enterprise application software can request data from NI-DAQmx 8 supported devices through an OPC client without LabVIEW 8.
LabVIEW 8 can control NI-DAQmx 8 devices using either the NI-DAQmx API or using the shared variable engine.
Related Links:
Learn more about LabVIEW
Learn more about NI-DAQmx
Reader Comments | Submit a comment »
too little info
I'd rather prefer more info concerning the detail
of the architecture
- davide.palandella@ni.com - Nov 1, 2006
Legal
This tutorial (this "tutorial") was developed by National Instruments ("NI"). Although technical support of this tutorial may be made available by National Instruments, the content in this tutorial may not be completely tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this content with each new revision of related products and drivers. THIS TUTORIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/).


