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.



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.


Call MATLAB Scripts

Call MATLAB scripts you have developed in The MathWorks, Inc. MATLAB® software, which includes common programming approaches for numeric analysis, signal processing, and advanced mathematics. By combining them in a VI with G using the MATLAB Script Node, you can integrate your test and measurement system with MATLAB analysis capabilities.

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.

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

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


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.

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

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

Additional Resources