Reusing Existing Code with LabVIEW


With rapidly changing test requirements and shortening tester project development cycles, it is even more critical that you and your team gain the most reuse possible from existing test software and measurement libraries. So why aren’t more test engineers reusing software more often? Here are the responses we hear most from test groups:
  • There is legacy software developed by someone that is no longer in the group or in the company; and it is working, so there is significant risk and expense in changing the unknown.
  • There are tool and language personal preferences or group standardization across test and validation engineering teams; therefore, it is difficult to reuse code modules because the tools or software to use for a past project don’t translate to what we are using today.
  • There is a need to maximize software reuse and build abstraction layers or frameworks, but this is expensive and time-consuming. With short-term project demands, the focus on how to enable reuse standards and best practices is continuously being deferred.

The challenges of balancing longer term standardization benefits with existing code and software skills or preference is real. To help address this difficult balance, LabVIEW as an open platform was designed to help you integrate all your test hardware and software systems together.

In LabVIEW, you can combine multiple programming approaches alongside graphical data flow (G) in a single application. Use this flexibility to select your tool of choice for creating device under tet (DUT) control, configuration, or measurement libraries. LabVIEW integrates multiple languages, like .m, C, Python, and .NET, into your application and interoperates with other software running locally or on the network to reduce your team’s time to success.


Table of Contents

  1. Calling Existing DLLs and .NET Assemblies
  2. Integrate .m Code
  3. Integrate LabVIEW Tools Network Add-Ons
  4. Integrate Python Scripts
  5. Communicate With External Systems Through Standard Industrial Protocols
  6. Additional Resources

Calling Existing DLLs and .NET Assemblies

In addition to importing source code to a LabVIEW block diagram, you can reuse existing applications and algorithms developed in other languages by calling them from a LabVIEW application. For instance, if you have an existing C/C++ shared library and need to reuse it in LabVIEW, you can call it using the Call Library Function Node. To make importing external libraries simple, LabVIEW includes the Import Shared Library Wizard, which automatically creates or updates a LabVIEW wrapper VI project library for incorporation into a LabVIEW block diagram.

Figure 1. Use the Call Library Function Node to reuse existing C or C++ shared libraries in-line with G programming.


Back to top

Integrate .m Code

Import, edit, and execute the .m files you have developed in The MathWorks, Inc. MATLAB® or GNU Octave software, which are common programming approaches for numeric analysis, signal processing, and advanced mathematics. By combining them in a VI with G, you can build these scripts into stand-alone executables that run on a desktop computer, as well as deterministic real-time hardware to rapidly gain access to real-world I/O.

Figure 2. The MathScript Node makes it easy to interface G programming and real-world I/O with .m file scripts.


Back to top

Integrate LabVIEW Tools Network Add-Ons

The LabVIEW Tools Network is the NI app store equipping engineers and scientists with certified, third-party add-ons and apps to complete their systems. Developed by industry experts, these cutting-edge technologies expand the power of NI software and modular hardware. Each third-party product is reviewed to meet specific guidelines and ensure compatibility. With hundreds of products available, the LabVIEW Tools Network helps you save development time while adding powerful functionality to your applications.  

Figure 3. The LabVIEW Tools Network accelerates developer productivity by providing access to hundreds of certified add-ons from NI and third-parties.


Back to top

Integrate Python Scripts

LabVIEW can also call into other applications running in the system. Over the past 10 years, Python has grown in popularity and expanded to offer hundreds of thousands of libraries for a wide spectrum of applications. Developing Python automation scripts for incorporation into a larger LabVIEW umbrella is an intuitive solution that merges the flexible  scripting capabilities of Python with the system design tools in LabVIEW. There are multiple ways to reuse Python code including the Python Integration Toolkit for LabVIEW by Enthought or interfacing with the command-line from within LabVIEW, which provides OS-specific interfaces for calling executables and other build libraries.

Figure 4. Reuse existing Python scripts in LabVIEW by calling them inline using the Python Integration Toolkit for LabVIEW.


Back to top

Communicate With External Systems Through Standard Industrial Protocols

LabVIEW has both general and industry-specific peripheral communications libraries for Ethernet and serial-based communications. With native support for common industrial protocols such as CAN, PROFINET, OPC UA, and EtherCAT, LabVIEW can connect to a variety of devices, equipment, and infrastructure. If you have a brownfield application that requires support for many protocols, LabVIEW can act as a gateway translating between any of the nearly 20 supported protocols, including industry-specific protocols such as DNP3 and FlexRay.

With access in LabVIEW to program an FPGA, you can even efficiently build custom communication protocols for legacy or proprietary communication needs. The LabVIEW FPGA Module includes digital bus protocol code examples as starting points such as serial, I2C, and SPI to build on top of as well as FPGA IP core for high-speed serial protocols such as Xilinx Aurora, Serial RapidIO, JESD204B, and 10 Gigabit Ethernet.

Figure 5. Communicate with DUTs and other system components using standard protocol support in LabVIEW, like the NI-XNET instrument driver.

Back to top

Additional Resources


Back to top