Better Together: Python and the LabVIEW+ Suite

Overview

The LabVIEW+ Suite and Python work together for building test systems. You can call Python code in the LabVIEW+ Suite or use Python to automate processes. Go with a “best of both” approach and build your test system faster.

Contents

How the LabVIEW+ Suite and Python Work Together

When it comes to test, you have options for software. You can spend time coding and building what you need—or you can use off-the-shelf options, which reduce development time. You want to be efficient by using the best tool for the job. What if you had more than one tool in your tool belt?

Python is a general-purpose programming language that is popular for its gradual learning curve, no cost of use, and strength in data analysis. And the LabVIEW+ Suite is a collection of NI’s most popular software for test, which includes purpose-built tools for instrument automation, test sequencing, data analysis, and more.

However, you don’t only need to choose one. The LabVIEW+ Suite and Python work together for a better test system. You can integrate Python code into the LabVIEW+ Suite in two ways:

  • Leveraging existing, or other code—You can reuse what you have and take advantage of native strengths and pre-built functionality in LabVIEW, TestStand, and G Web.
  • Using Python to automate processes from the LabVIEW+ Suite—With this, you can save development time by using existing programs and functions and go further in efficiency with automation.

 

Fig 1: Diagrams showing Python integration with the LabVIEW+ Suite. Left image shows the components of a test application in LabVIEW with a function call to Python for data analysis. The right image shows the data analysis process in DIAdem; each step is completed in DIAdem and entire process can be automated with Python.

 

Leverage Existing Python Code

Adopting the LabVIEW+ Suite doesn’t mean you need to start from scratch; time spent redeveloping code in Python would be wasted. You want to use what each tool is best at. You can reuse existing programs and integrate them into LabVIEW and TestStand or build a web interface for a Python program in G Web Development Software.

Call Python Functions in LabVIEW

LabVIEW is a graphical programming environment engineers use to develop automated test systems. When you need to take a measurement, automate devices, or perform analysis, LabVIEW can help. It excels at automating instruments and monitoring test with built-in user interfaces. The native ability to drag and drop pre-built visualization tools for a UI continue to make it the engineer’s tool of choice for more than 30 years. 

Fig. 2: Monitor with LabVIEW calling a Python script.

In LabVIEW 2018, NI introduced the Python Node, which allows users to call a Python file in the execution of a LabVIEW application. For example, you want to leverage an existing data analysis library written in Python from another colleague, while taking advantage of LabVIEW’s instrument connectivity. You could just use Python for the whole process, but you would probably experience challenges when connecting to your hardware—or spend more time than you want developing a UI. This approach offers an efficient way to interoperate between languages and use the best of both.

Perform Test Sequencing with Python in TestStand

TestStand is a test executive software engineers use to develop automated test sequences, for scaling test in the validation lab or across the production floor. TestStand is an interactive development environment for creating a sequence of tests. It has all the functionality of a test executive: unit tracking, reporting, parallel test execution, and more. 

With the TestStand Python Adapter, you can call Python code modules as part of your test sequences. In Python, you could likely easily sequence a few measurements, but would encounter challenges as you increase in scale and complexity. To develop functionality for unit tracking, parallel test execution, reporting, operator interfaces, and more, you would have to spend countless hours and days. TestStand already has it. By leveraging the strengths of both, you can call your Python measurement code in TestStand and scale efficiently.

“TestStand provided an out-of-the-box solution that reduced development time by supplying a number of key features, while LabVIEW contained the native functionality for controlling the necessary test system hardware.”

Dillon Glissmann, DISTek Integration, Inc.

Access Python Test Program Remotely with G Web Development Software

G Web Development Software is a graphical programming environment optimized for developing web-based user interfaces for test. While many engineers are skilled programmers, those skills do not always align with the needs for web development in HTML or JavaScript. In these cases, leveraging G Web can be more efficient, as it is an interactive environment with prebuilt objects for data display and user control. For existing test applications written in Python, G Web includes prepackaged APIs that simplify data transfer and communication, so you can make your Python test system web ready without advanced web development knowledge.

Fig. 3: Monitor with G Web Development Software and smartphone displaying a web application.

Control NI Software with Python

FlexLogger and DIAdem are NI tools for data acquisition and analysis, respectively. In FlexLogger, you can create a measurement in minutes; in DIAdem, you can view and analyze your data just as quickly. Skip development. These tools are built for engineers and simplify the test process. When the need arises, move to Python to automate the process for the future.

Automate Data Acquisition in FlexLogger

FlexLogger is no-code application software for performing data acquisition with NI hardware. This application reduces time to first measurement with an intuitive way to set up your test and store data. While NI provides Python APIs for performing test with our hardware, FlexLogger helps you to be more agile and modify tests in a few clicks. 

By leveraging the simplified setup in FlexLogger, you can focus on efficiency through automation using FlexLogger Python APIs. FlexLogger allows you to control task execution and programmatically change configuration in your Python code.

Automate Data Analysis and Reporting in DIAdem

DIAdem is a measurement data analytics tool for viewing, analyzing, and reporting on data. DIAdem contains advanced tools for indexing your directory to find data, built-in functions for analysis, and charts and graphs for viewing data. Rather than writing your own program to create complex visualizations and perform advanced calculations, DIAdem contains these features natively.

In Python, you can automate the entire process from import to report. DIAdem includes functionality for the entire data post-processing workflow in one tool. Rather than building an analysis library or developing reports in disparate programs, go with DIAdem and automate in Python.

“We have reduced our reporting and analysis time by 95 percent and achieved our goal of replacing the current multistep process with a one-button DIAdem solution.”

Jim Knuff, Raytheon Missile Systems.

 

Fig. 4: Monitor showing a Python script for automating DIAdem analysis.