Applying National Instruments LabVIEW and LabWindows/CVI Interoperability
Overview
This article introduces LabVIEW and LabWindows/CVI and discusses several methods available today to share code and functionality between the two environments. Thourgh these methods, you can take advantage of an integrated software framework to decrease the complexities of integrating multiple measurement devices into a single system and provide a seamless integration path for multiple software applications.
NI Software Framework
Like most system developers, you most likely face challenges of incorporating measurement systems. This creates the need for an integrated software framework to decrease the complexities of integrating multiple measurement devices into a single system and provide a seamless integration path for multiple software applications. It is through this framework that you can deliver products to market faster, achieve greater product quality, and lower development and production costs.An integrated measurement and automation software framework delivers a modular, yet integrated, structure for building high-performance, automated measurement and control systems. For maximum performance, ease of development, and system level coordination, the components of the framework must be independent, yet tightly integrated. This structure empowers developers to rapidly build measurement systems and modify them easily as the system requirements change.

This software structure empowers developers to rapidly build measurement systems and modify them easily as the system requirements change.
Need for Interoperability
NI offers two application development environments (ADEs) specifically designed for measurement and automation -- National Instruments LabVIEW and LabWindows/CVI.
Both LabVIEW and LabWindows/CVI integrate tightly with the software framework to incorporate a wide variety of I/O and other software applications.
This section will discus examples of interoperating between LabVIEW and LabWindows/CVI.
Sharing Instrument Drivers
If you connect to traditional box instruments, the value of instrument drivers is extensive. National Instruments instrument driver network contains over 2,200 instrument drivers from over 150 different vendors -- free to download. As an important component of test systems today, instrument drivers control and communicate with instrument hardware in your systems. Instrument drivers provide a high-level, easy-to-use programming model that gives you complete access to the complex measurement capabilities of instruments through an intuitive application programming interface. LabVIEW and LabWindows/CVI instrument drivers deliver modular, off-the-shelf components that are immediately ready to use in your test programs. With this immense library resource you can dramatically reduce the development time.
However, many times the searches for instrument drivers are only done on the language of choice: LabVIEW or LabWindows/CVI. Instead, you should take advantage of the interoperability of the open NI software platform and simply search on the instrument you are searching for.
See DLL method below for details on implementing a shared instrument driver.
Incorporate Legacy ANSI C Code
You may have existing, legacy ANSI C code that you would like to incorporate in your current applications without having to rewrite all of the code in LabVIEW. This would include legacy applications that may need periodic maintenance to update hardware drivers, additional modules, or you might want to incorporate new functionality. For this level of flexibility, you should use the LabWindows/CVI development environment to maintain the legacy applications, as well as the LabVIEW graphical development environment to integrate the ANSI C code into an existing LabVIEW application.
Leverage Functionality
Historically, National Instruments incorporates many new features into LabVIEW before other NI software packages. Because LabWindows/CVI relies on stability, it does not always need to incorporate the latest technologies as quickly. However, if you use LabWindows/CVI, there are times when you might need to add functionality only found in LabVIEW. In this case, you can use LabVIEW as a gateway into other platforms. LabVIEW Real-Time is a good example. If you need to develop real-time applications and you have existing ANSI C code, or if you simply prefer to develop in C, you can develop the application in CVI and then use LabVIEW as your deployment and runtime execution system.
Methods of Interoperability
This section covers several methods available today to share code and functionality between the two environments.
DataSocket
National Instruments DataSocket is a high-level programming tool designed specifically for sharing and publishing live data in measurement and automation applications. With DataSocket, you can simplify live data exchange between different applications on one computer or between computers connected through a network.
If you use LabVIEW and LabWindows/CVI, you can use DataSocket capabilities to easily and quickly share data between applications.
Sharing LabVIEW and LabWindows/CVI data through DataSocket
Both LabVIEW and LabWindows/CVI have the ability to be both a DataSocket ‘reader’ and a DataSocket 'writer.' This example demonstrates how to create a LabVIEW project that writes data and a CVI project that reads the data.
The best way to demonstrate this simple exchange of measurement data is by leveraging the shipping examples.
- Launch LabVIEW and search for the DataSocket Writer example, DS Writer.vi.
- Launch LabWindows/CVI and open the Reader.prj project in the DataSocket samples folder.
- Run the LabVIEW DS Writer.vi. This particular example automatically launches and runs the DataSocket server, which you need to transmit the DataSocket data. By running this VI, you can begin sending the simulated data to a DataSocket address on your local machine: dstp://localhost/wave.
- Run (F5) the LabWindows/CVI Reader.prj.
- Press ‘Connect’ (Auto Update) on the LabWindows/CVI user interface. This program will now begin reading and updating the user interface from the data being sent locally on your machine at: dstp://localhost/wave.
- You have now successfully transmitted live measurement data between the two National Instruments ADEs.
LabWindows/CVI DataSocket Application Notes and Tutorials
LabVIEW DataSocket Example Programs
LabWindows/CVI DataSocket Example Programs
ActiveX Automation
ActiveX automation capabilities are another vehicle for interoperability. ActiveX is the general name for a set of Microsoft technologies that allows you to re-use code and link individual programs to suit your computing needs. Based on Component Object Model (COM) technologies, ActiveX is an extension of a previous technology called Object Linking and Embedding (OLE).
ActiveX automation refers to the process of controlling one program from another via ActiveX. Much like networking, one program acts as the client and the other as the server. LabVIEW and LabWindows/CVI support automation both as the client and the server. Both the client and server exist independent of each other, but they can share information between one other. The automation client performs this sharing of information by communicating with the ActiveX objects that the automation server exposes. You can access the objects that have properties and methods with the automation client.
Accessing LabVIEW and LabWindows/CVI data through ActiveX Automation
To easily demonstrate the interaction between the two ADEs through ActiveX, look in the shipping examples included with both products. To begin, you can launch and control LabVIEW from LabWindows/CVI
- Launch LabWindows/CVI
- Open the lvdemo.prj from the Samples >> ActiveX >> LabVIEW folder of the LabWindows/CVI directory
- Run the project
- Here, you can interactively launch and control LabVIEW from LabWindows/CVI through ActiveX automation
Additional Resources:
LabVIEW ActiveX Application Notes and Examples
LabWindows/CVI ActiveX Application Notes and Examples
Dynamic Link Libraries (DLLs)
DLLs provide a way for you to access external code. DLLs are sections of code linked to the main program at run time. This has several advantages. The first is space. If many applications share a certain algorithm, you can compile it once as a DLL, and then use the same code in all the applications. DLLs also provide a way for you to distribute code and easily allow higher-level programs to access the code.
With LabVIEW, you can access functions contained in DLLs via the Call Library Function Node. You configure the Call Library Function Node VI by entering the path to the desired library, the name of the function, and the calling conventions.
To use a DLL in LabWindows/CVI, you add the import library file to the Project, so LabWindows/CVI knows the function entry points and parameter prototypes for the DLL. After you load the DLL in LabWindows/CVI, you can make calls directly to the functions in the DLL from your LabWindows/CVI source code.
How-to Resources:
Calling a DLL in LabVIEW via a Call Library Function Node
Using LabWindows/CVI to call LabVIEW DLLs that Pass Clusters
An Overview of Accessing DLLs or Shared Libraries from LabVIEW
Presentation: Creating and Using DLLs in LabVIEW
Dynamic Data Exchange (DDE)
Using DDE, you can pass commands and data between different applications under Microsoft Windows. With LabWindows/CVI, you can develop programs that communicate to other applications with DDE as a client or a server. A client application can send commands to a server application and ask for data from a server application. A server application must be able to respond to commands sent from client applications and pass data to a client application when requested.
Other methods of interoperability
There are also many other ways to share data between the open LabVIEW and LabWindows/CVI environments. Some include Code Interface Node (CIN), using system functions to launch external programs, and using file I/O to share data. You can find information on all of these topics and more at the Developer Zone online resource.
Related Links:
An Overview of Accessing DLLs or Shared Libraries from LabVIEW
Using LabWindows/CVI to call LabVIEW DLLs that Pass Numeric Data Types
Reader Comments | Submit a comment »
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/).
