Analyzing and Presenting Data with LabVIEW

LabVIEW is an abbreviation for Laboratory Virtual Instrument Engineering Workbench and allows scientists and engineers to develop and implement an inter-active program. LabVIEW has been specially developed to take measurements, analyze data, and present the results to the user. You determine what the device looks like, rather than the manufacturer of the device. LabVIEW has a very large library of functions and subprograms (subVIs) that can help you during your programming and use without occupying memory. Hidden programming problems that you may encounter in traditional programming languages are less common in LabVIEW. LabVIEW also includes different applications such as serial device control, data analysis, data presentation, data storage and communication over the internet. Analysis library; It includes versatile and useful functions such as signal generation, signal processing filters, Windows statistics and regressions, linear algebra and array arithmetic. Due to the graphical nature of LabVIEW, it is an innate data presentation package. You can view the data in any form you want. Chart, graph and user-defined graph are among the output options that can be used. As a scientist or an engineer, you frequently measure physical changes such as temperature, pressure, time, mass, electric current, light intensity, radioactivity etc. You generally need to analyze and present the data. When you have large amounts of data, you need to use software to analyze and present the data. LabVIEW makes these actions easy for you. Because LabVIEW includes hundreds of built-in and add-on functions you need that make it easy to create a user-friendly interface. In this chapter, we focus on data analysis and presentation.


Introduction
Almost all LabVIEW applications include 3 steps: (1) acquiring data, (2) analyzing and processing the data, and (3) presenting the data in a report or on a chart/ graph (Figure 1). Acquire: NI (National Instruments) is a global leader in computer-based data acquisition. More than millions of data acquisition devices have been sold by NI. LabVIEW developed by NI is a user friendly programming interface and easily communicates to NI devices. Therefore, most of the scientists and engineers choose LabVIEW for programming and NI devices for measurements.
Analyze: LabVIEW software has more than 600 built-in functions for signal synthesis, frequency analysis, probability, statistics, math, curve fitting, For analysis, you will frequently use Mathematics palette and Signal Processing palette (Figure 2).
Statistics and Histogram Express VIs are located in Probability & Statistics subpalette of Mathematics palette (Figure 3).
In the following example, VI simulates a DC signal with noise (Figure 4). VI also generates a histogram and result of basic statistical analysis.
Mathematics palette also contains Fitting subpalette ( Figure 5). This palette contains the following fitting VIs.   You can use curve fitting for several reasons. For example, to reduce noise, to find mathematical relationships among variables, to estimate the variable value between data samples or out of data sample range.
The following simple VI plots data and Exponential fit (Figure 6). You can use the other fitting VIs with the same manner.
You can use the Signal Processing VIs for spectrum analysis, signal generation, digital filtering, and data windowing (Figure 7). It is located in Functions palette.
In Signal Processing palette, Waveform Measurements palette contains Tone Measurements and Spectral Measurements Express VIs (Figure 8).
The following example in Figure 9, Tone Measurements Express VI finds amplitude, frequency and phase of a signal which is generated by Simulate Signal Express VI. In this example, Spectral Measurements Express VI generates the power spectrum of the signal.
LabVIEW has two ways to display data in 2D. These are Chart and Graph (Figure 11).
A Waveform Chart remembers and displays a certain number of points by storing them in a buffer. Waveform Chart displays received data in addition to already existing data.
A Waveform Graph accepts arrays of data in various forms, e.g. array, waveform, or dynamic data. It plots all the received points at once.
You can visualize more than one data source on a chart or graph. In the following example DAQ Assistant take data from two channels. You can see data from all channels on a chart as shown in Figure 12.
A multi-plot chart can be displayed as overlaid plot or stacked plot (Figure 13). To select Stack Plots or Overlay Plots right-click on the chart. Overlay Plots mode overlays all plots on the same y-axis. Stack Plots mode gives the each plot its own y-axis.
To plot y values in a chart/graph you should wire only the y array data (y values) to the Waveform Chart or Waveform Graph. LabVIEW assumes that you sample y values at regular intervals, and thus creates x values at regular intervals. If you want to specify x and y values for a plot, you can use XY Graph. In the following example we plot multiple circles in a XY Graph (Figure 14).
If you want to display both analog and digital signals together in a graph, use a Mixed Signal Graph located in the Graph palette. A Mixed Signal Graph is made by bundling multiple graphable data types. You can add plot area from the pop-up menu of an existing plot area by selecting Add Plot Area. You can also remove a plot area by selecting Remove Plot Area. In the following example, you can see both analog and digital signals together in a Mixed Signal Graph with two plot area (Figure 15).
LabVIEW allows you to use 3D graphs to plot data in three dimensions. 3D graphs are located in Controls> > Modern> > Graph> > 3D Graph. LabVIEW allows you eleven types of 3D graphs: The Scatter, Bar, Pie, Stem, Ribbon, Contour, Quiver, Comet, Surface, Mesh, and Waterfall graphs. You can see some of them in Figure 16. However, to study with 3D graphs you must have learned basics of vector and matrix.
Plot Helper.vi is automatically created in the block diagram when you drop any of the 3D graph. Plot Helper.vi is a polymorphic VI and thus it can accept Matrix or Vector inputs according to your selection (Figure 17).
You can find the two examples of 3D graphs, below.
In the following example we created a cylinder combining 5 circles whose z axis points are different from each other. Note that i (iteration number) generates z matrix (Figure 18).
The following VI generates a sphere and visualizes it in 3D Parametric Graph (Figure 19). Here radius of sphere is 5 and sphere is generated by 20 circles. A sphere is a collection of circles. You can see from XY Graph that each circles are individual size.

Publishing information to the web
LabVIEW can publish any application to the Web with Remote Panels. Therefore, you can easily make your VI reachable as a Web page. Thus, clients can control   the VI or view generated data by using their web browsers. Clients must use a version of the LabVIEW Run-Time Engine compatible with the version of LabVIEW. NI recommends that customers use the supported browser (Internet Explorer). Google Chrome version 42 and later, Mozilla Firefox 52 and later, Safari 12.1 in macOS Mojave 10.14, and Microsoft Edge are not supported browsers. Before view and control a front panel remotely, the Web Server must be enabled on  the server computer where the VI or application wanted to view and control is located. Follow the steps below to learn how you can do it.
1. Create a VI. We created a VI named Remote Panel Example.vi (Figure 20).

Open block diagram and click to Tools»Options»Web Server
3. Under the Remote Panel Server section, check Enable Remote Panel Server (Figure 21).

5.
Under the Browse Access section, enter the network name of the computer and press the Add button. Allow viewing and controlling option must be selected (Figure 22).  (Figure 23).

Click OK and exit out of the
9. Fill Document title, Header and Footer sections and click Next (Figure 24).
10. Under the Save the New Web Page section, select where to save the HTML file and choose the file name and press Save to Disk button (Figure 25).  11.Click Connect button in Document URL window (Figure 26). Ensure that default browser is Internet Explorer. If not, copy URL address and paste it to Internet Explorer.
You will see the following Internet Explorer page (Figure 27). In this page, clients must click Run button to control the VI from their computer.

Report generation
LabVIEW includes Report Generation toolkit to present your data in a Microsoft Office Word and/or Excel file. To use LabVIEW Report Generation Toolkit, it must be installed. Then corresponding functions will be located in Functions> > Report Generation palette (Figure 28).

Microsoft office word and excel reports
Report Generation palette contains many functions. Therefore, it is not easy to understand their properties. We recommend that you examine first the report generation example VIs in LabVIEW (Help>> Find Examples>> Search). You can modify them according to your purpose. These VIs generally generate reports based on templates. Using a template, allows you to generate standard reports for each execution of a VI. In the following example we generate a report for Microsoft Office Word (Figure 29). The example draws a circle and paste the circle to a Ms. Office Word document (Figure 30). You can determine color, size, graph type, marker style etc. by using the functions in Word Specific palette (Figure 31). Similarly, you can use Excel Specific palette to generate programmatically an Excel report (Figure 31).
When you execute the VI you see the following picture in an automatically created Word document.

HTML report
LabVIEW has the ability to programmatically create html reports. Html files can be read by web browsers. We highly recommend you to present your data as a html  file. Because reading an html file is not effected by version of web browsers. On the contrary, current version of Microsoft Office Word or Excel in your computer may not be compatible with LabVIEW Report Generation toolkit you installed.
The following VI generates an html report (Figure 32). Here, Random Number function generates Y array. X Array is generated by absolute time values.
When you execute the VI above the following report will be generated (Figure 33).
Report Generation toolkit also contains Report Express VI and MS Office Report Express VI (Figure 34). These Express VIs allow you to present data in form of html, MS Office Word or Excel.  In the following example, we use Report Express VI to present data in html format (Figures 35 and 36). You can also send data to printer or present data in MS Office Word or Excel format with the same VI. To do this double click Report Express VI and select the corresponding line from Destination tab in Configuration Report window.
When you execute the VI above you will see the following report.

Save data
You can create folder, file or path, write and read data by using the File I/O VIs and functions (Figure 37). LabVIEW allows you to save data with different data formats.
Write Delimited Spreadsheet.vi converts a 2D or 1D array to a text string and writes the string to a new byte stream file or appends the string to an existing file. Both 2D and 1D arrays can be strings, signed integers, or double-precision numbers.
You should put Write Delimited Spreadsheet.vi out of the loop (Figure 38). Putting the VI inside the loop is not the good way of using it. Because LabVIEW at every iteration would open-write-close the file if it is inside the loop. This is not good in terms of VI efficiency.
You can also write date/time information for each data point. In the following example (Figure 39), data consist of time and random number.
Read Delimited Spreadsheet.vi reads a specified number of lines or rows from a numeric text file beginning at a specified character offset and converts the data to a 2D, double-precision array of numbers, strings, or integers. In the following  example VI writes and reads data by using Write Delimited Spreadsheet.vi and Read Delimited Spreadsheet.vi (Figure 40). Note that we formatted time and random number by using Format Into String.
Another way to write and read data is to use Write To Measurement File and Read From Measurement File (Figure 41). It can only accept numeric or waveform data although Write To Spreadsheet File can accept array of strings, signed integers, or double-precision numbers. We recommend that you use Write To Measurement File to write data on disk. Because this Express VI allows you to save data as text (LVM), binary (TDMS), binary with XML header (TDM) and Microsoft Excel (.xlsx) formats.
Write To Measurement File is an Express VI. When you double-click to the Express VI Configure Write To Measurement File window opens (Figure 42). Here, you can configure writing.
As you see in Figure 42 Configure Write To Measurement File window allows you to change settings. It may be difficult to understand how you can configure this Express VI for the first time. To understand the function of each setting, we suggest that you individually experience with each setting.
In the following example we add time values (x) to the signal (random numbers, y) by using Write To Measurement File (Figure 43). Time data must be connected to Comment terminal of Write To Measurement File.
You can also save string data using Write to Text File. In the following example, VI saves date with time information (Figure 44). Similar to examples above you can write and read data by using Write Binary File and Read Binary File (Figure 45). Binary files use less data storage. Therefore, it is useful when you have large data. However, Write To Measurement File save data as binary format, too. You may not need to use Write Binary File and Read Binary File.   (Figure 46).
The following VI generates two waveform sinus signals and write-read them (Figure 47).
NI has created a technical data management (TDM) solution. TDM Streaming is located in File I/O palette (Figure 48).
NI recommends costumers to use TDMS file format because it combines the advantages of several data storage options in one file format ( Table 1). You can also work with TDM and TDMS files in Excel by utilizing the free TDM Excel Add-in for Microsoft Excel (supported Excel version: from 2007 to Excel 2016). You can take additional information from the following link [3].  https://www.ni.com/en-tr/support/documentation/supplemental/06/the-ni-td ms-file-format.html.

National instruments DIAdem
DIAdem is a software to manage large amounts of data for measurement data aggregation, inspection, analysis, and reporting (Figure 49). With DIAdem, extraction of information from data can be efficiently performed. DIAdem is well adapted to LabVIEW. You can transfer your data from your LabVIEW application to DIAdem. With DIAdem, DataPlugins can be used to read, inspect and search different kinds of custom file formats. NI supplies free downloadable DataPlugins for hundreds of the most commonly used data file formats.

LabVIEW and OriginPro
National Instruments engineers have created various NI LabVIEW add-ons which contain many functions and subVIs to meet the required functionality.  Besides the add-ons developed by NI engineers, add-ons have been developed for some other applications such as Origin. Origin or OriginPro is a powerful data analysis and graphics software preferred by scientists and engineers in industry, academia and research laboratories around the world [4]. Once the data collected by LabVIEW, the end-user will need to analyze the data and generate reports for presentation. Origin provides powerful analysis and graphing tools to reanalyze and present data. The ability to communicate easily between LabVIEW and Origin is a good platform that can greatly increase its efficiency in terms of data analysis and presentation [5]. There are studies in the literature using Origin and LabVIEW for  this purpose [6]. Origin provides subVIs to make work in LabVIEW environment. These subVIs allow to data transfer from LabVIEW to Origin and the data to be analyzed and presented in the Origin environment. This subVIs can be accessed from the folder where OriginPro is installed (Samples\COM Server and Client \LabVIEW). Also, in order to quickly access these subVIs in the LabVIEW environment, the subVIs can be copied from the installed folder and then pasted into a folder named OriginPro in vi.lip\addons folder where LabVIEW is located [7]. OriginPro library can be accessed from the menu opened by right-clicking on addons in the Block Diagram window in LabVIEW as shown in Figure 50.
After adding the subVIs provided by OriginPro to LabVIEW, you can see subVIs as shown in Figure 51. There are four sections under Origin function palette. These are   • OriginApp: Basic VIs that handles the Origin OPJ files, worksheet and columns, • OriginAppClassics: Older VIs existed before Origin 8 (deprecated), • OriginWave: VIs that handles Origin matrix objects, • OriginMatrix: VIs that handles LabVIEW Waveform data.     In the following example, the measured temperature values are transferred and plotted in OriginPro. In this example, first, add OA_ConnectToOrigin.vi to the Block diagram so that LabVIEW can connect to OriginPro. Once the link between LabVIEW and OriginPro is established, add OA_NewWorksheet.vi to the Block diagram to open a new worksheet in OriginPro. This also creates the name and details of the worksheet to use the entries of VI. After that, you use OA_GetColumn.vi to select a column. Then, you send the information of this column via OA_Col-Setting.vi. You will have to pay attention to two important points while filling in the entries of this VI. The first is the Data Format. This is the part where you need to write the format of the data. The second is the column type.
Here we can determine the axis of the column to use in the chart. You can specify an axis such as X, Y, or Z, as in the example shown in Figure 52. After this process is completed, you will be able to transfer your data to the worksheet by using OA_Col-SetData.vi. You can use the Read Delimited Spreadsheet.vi in the File I/O menu to send the data to worksheet created in the Origin environment as in the example shown in Figure 52. You should pay attention for the correct format of the data. In addition, if you are working with data consisting of a single data created in  certain periods of time such as the data used in this example, and if you are going to plot these data versus time, you will need to use OA_Col-SetEvenSampling.vi. Finally, VI in Figure 52 plots the temperature data at 0.5 ms intervals as shown in Figure 53 by using OA_NEWEmptGraf.vi and OA_PlotWksCols.vi.   Similarly, another example is to use the template you created in the OriginPro. For this, you must first create a template in the OriginPro. Save this template in Docu-ments\OriginLab\2015\User Files folder in your computer. In this case, it will be easy for you to access this template from LabVIEW. For an example application, a template has been prepared in OriginPro as in Figure 54. Now add OA_ConnectToOrigin.vi to the Block Diagram for the connection between Labview and OriginPro. OA_AddOriginPath.vi creates the file path. Then, use OA_Load.vi to upload file. OA_FindWorksheet.vi is to select worksheet. After this step is completed, since you defined Voltage for the X axis and Current for the Y axis in the template, you need to send your data to OriginPro accordingly. For this, you can use OA_GetColumn.vi to select column. You can send your data to these columns with the help of OA_Col-SetData.vi. These steps are given in Figure 55. Here, the data you previously saved in the LabVIEW environment is opened again and drawn in OriginPro [8].

Conclusion
The scientist and engineers frequently need to measure physical changes, analyze them, and present data from the measurement. LabVIEW includes hundreds of  built-in and add-ons functions for analysis and presentation of data. If you do not know LabVIEW well, you should check the examples in LabVIEW and ni.com. This is the easiest way to learn how you can analyze and present your data.
LabVIEW has effective 2D (Charts and Graphs) and 3D visualization tools for data presentation. Graphs accept only array data. It plots all the received points at once. Charts attach received data to already existing points. When an array of points is wired to a chart or graph, LabVIEW assumes the points are equally spaced out. If you also want to define X axis values, you should use XY Graph.
LabVIEW allows you to present your data html, Microsoft Office Word or Excel. LabVIEW also allows you to publish any application to the Web with Remote Panels. Therefore, your VIs can be reachable as a Web page. You can control a remote device from your home. It is interesting, right?
Generally, you want to save and read your data. There are different ways to do it in LabVIEW. We recommend you to use Write To Measurement File and Read From Measurement File. These supports data as text (LVM), binary (TDMS), binary with XML header (TDM) and Microsoft Excel (.xlsx) formats.
DIAdem software is a NI product to manage data for measurement data aggregation, inspection, analysis, and reporting. Interestingly, DIAdem can use more than one thousand data file formats by utilizing DataPlugins.
More than 500,000 clients in the world use OriginPro to import, graph, explore, analyze interpret their data. If you are a user of OriginPro software, you can integrate it with LabVIEW. When you install Origin add-ons for LabVIEW you can easily communicate with OriginPro.

Thanks
We thank to Serdar Bölükbaşıoğlu, manager of Ludre Software company, for his contribution.