Reduce Development Time by Reusing Existing Code With LabVIEW

Publish Date: May 19, 2017 | 1 Ratings | 4.00 out of 5 | Print


With LabVIEW, you can combine multiple programming approaches alongside graphical data flow (G) in a single application. You can take advantage of this flexibility to select your tool of choice for creating algorithms and solving an infinite variety of engineering problems. LabVIEW integrates multiple languages, like .m, C, Python, IEC 61131-3, 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. Integrate Existing Source Code and Shared Libraries Into LabVIEW
  2. Interoperability for Team Collaboration
  3. Simulating and Modeling Physical Systems
  4. Conclusion
  5. Additional Resources

1. Integrate Existing Source Code and Shared Libraries Into LabVIEW

LabVIEW includes numerous options to reuse your existing code base, so you don’t have to reinvest in creating new code.

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.

Learn more about how to add textual math to your desktop and deterministic real-time LabVIEW applications.

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


Integrate C Code

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 2: Use the Call Library Function Node to reuse existing C or C++ shared libraries in-line with G programming. 

Integrate Python, ActiveX, and .NET Code

LabVIEW can also call into other applications running in the system. 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. Interfacing with the command-line is also possible with the System, which provides OS-specific interfaces for calling executables and other build libraries. LabVIEW can also call external code exposed through ActiveX or .NET interfaces.

Learn more about using Python in your LabVIEW-based test and measurement system

Integrate Packages From the Linux Community

The NI platform itself is built on many standard technologies, so LabVIEW users can expand the amount of reuse their team has with access to other technology ecosystems, including the use of Linux-based libraries in and alongside their LabVIEW Real-Time applications. These methods use existing code so development teams can reuse as much code as possible and integrate it into their test, measurement and control systems.

Learn more about the part Linux plays in the NI platform and how LabVIEW users can benefit.

Integrate VHDL Code

You can use the LabVIEW FPGA Module to write code that runs on an FPGA using G. However, as with the previous programming approaches, you might want to reuse existing code or have the flexibility to choose the means of implementation. Most FPGAs are programmed using VHDL, a text-based dataflow description language. Instead of rewriting existing intellectual property (IP) from VHDL in G, you can import the VHDL into your VI using the Component-Level IP (CLIP) Node.

Learn more about importing external IP into LabVIEW FPGA

Back to Top

2. Interoperability for Team Collaboration

Efficiently design your system in a collaborative environment with LabVIEW by embracing your team’s software language competencies to complete the task with the right tool. LabVIEW provides interfaces for different team members working in different environments to productively collaborate.

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 numerous 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. LabVIEW FPGA 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. Learn more about industrial protocol hardware products that you can seamlessly connect to with LabVIEW.

Developing C/C++ Applications

Many teams have existing, familiar development environments and toolchains that can coexist and interoperate with LabVIEW-built systems. For example, for the NI Linux Real-Time targets, developers can develop, debug, and deploy applications to the embedded processor written entirely in C or C++ using Eclipse or another preferred integrated development environment (IDE) and interface with LabVIEW applications.

Learn more about C/C++ real-time application codevelopment options alongside LabVIEW


Figure 3: Program the embedded processor with LabVIEW or any Linux-compatible tools and use the NI reconfigurable I/O (RIO) driver to communicate with LabVIEW FPGA. 

Interface With the IEC 61131-3 Industrial Automation Standard

IEC 61131-3 is an international standard that defines software architectures and programming languages for programmable logic controllers (PLCs) such as Ladder Logic and Structured Text. The LabVIEW 2017 FPGA IEC 61131-3 Interface Utility allows industrial automation code defined by this standard to interface with the FPGA fabric on NI Linux Real-Time devices through the 3S CODESYS IDE. This enables collaboration between design and maintenance teams through a standard, familiar interface that facilitates code reuse and debugging tasks.

Learn more about interfacing with the IEC 61131-3 industrial automation standard

Figure 4: The IEC 61131-3 Interface Utility allows interfacing NI FPGAs through the CODESYS IDE. 

Interface FPGAs With Python

Python is a high-level, interpreted scripting language mainly used in scientific computing that provides a vast collection of libraries for text processing, web frameworks, network communications, and more. The FPGA Interface Python API allows you to use Python to interface with LabVIEW FPGA code on NI hardware targets. The FPGA Interface Python API is compatible with both Windows and Linux development systems as well as NI Linux Real-Time deployment targets.

Learn more about interfacing FPGAs with Python

Figure 5: The FPGA Interface Python API allows interfacing NI FPGAs through Python. 


Back to Top

3. Simulating and Modeling Physical Systems

Modeling and physical system simulation are often used in the design of embedded systems. You can test your monitoring or control code written in LabVIEW in conjunction with a physical system simulation. Or, you can compare your test and measurement results with a model running in LabVIEW. With the graphical signal flow capabilities of the LabVIEW Control Design and Simulation Module, you can create and analyze models to learn about dynamic system characteristics and also create a control system that achieves wanted  behavior. As shown in Figure 4, you can combine a model-based programming approach with other methods, including G and the MathScript Node.

You can also use the Simulation Model Converter to help convert your models developed in The MathWorks, Inc. Simulink® software to work with LabVIEW. These dynamic systems can be deployed to real-time hardware targets without any intermediate steps thanks to the LabVIEW Real-Time Module, which is well-suited for rapid-control prototyping and hardware-in-the-loop applications. If you want to keep your model development in the Simulink environment or a variety of other simulation environments, you can use the LabVIEW Model Interface Toolkit to interface with LabVIEW and LabVIEW Real-Time.

Learn more about how to reuse your dynamic simulation competency with the LabVIEW Control Design and Simulation Module

Figure 6: Import control algorithms and system models from LabVIEW and third-party modeling environments. 

Back to Top

4. Conclusion

Many users use LabVIEW as the glue of an overall system because it provides the flexibility to incorporate different subsystems as teams collaborate, reuse of existing code and software competencies, and extensibility for the future. To augment your productivity, over the last 30 years NI has assembled an ecosystem of LabVIEW code, tools, and partners to help you successfully build your test, measurement, and control systems faster.

Back to Top

5. Additional Resources

The registered trademark Linux® is used pursuant to a sublicense from LMI, the exclusive licensee of Linus Torvalds, owner of the mark on a worldwide basis.

MATLAB® and Simulink® are registered trademarks of The MathWorks, Inc. The registered trademark Linux® is used pursuant to a sublicense from LMI, the exclusive licensee of Linus Torvalds, owner of the mark on a worldwide basis.

CODESYS® is a trademark of 3S-Smart Software Solutions GmbH

Back to Top

Bookmark & Share


Rate this document

Answered Your Question?
Yes No