LabVIEW Data Storage VIs Application Exercise

Publish Date: Aug 03, 2012 | 7 Ratings | 3.29 out of 5 |  PDF


This application exercise highlights how you can use the new easy-to-use and flexible NI LabVIEW Data Storage programs (VIs) for saving measurement data.

Table of Contents

  1. Part 1: Acquiring Data and Saving It to Disk Using the Data Storage VIs
  2. Part 2: Reading Data Back into LabVIEW Using Filter Conditions
  3. Part 3: Reading Data Back into LabVIEW Using Conditions
  4. Part 4: Acquiring Data and Saving It with Additional Properties
  5. Part 5: Adding Structure to Your Data
  6. Part 6: Capturing Events Using the Storage VIs and Properly Documenting Test Data
  7. Part 7: Using DIAdem to Further Inspect, Analyze, and Report the Results
  8. Part 8: Optional – Saving Custom Properties to a TDM File

1. Part 1: Acquiring Data and Saving It to Disk Using the Data Storage VIs

The LabVIEW data storage VIs, pictured below, offer a variety of benefits that help you:

  • Easily save descriptive information with test data, easing the burden normally associated with documenting results while making it conducive for posttest data mining.
  • Create channel groups, which introduce structure and provide intuitive measurement and analysis data grouping. For example, group one includes all temperature sensors, group two includes all pressure sensors, and group three represents all analysis results.
  • Take advantage of an easy-to-use API that abstracts the low-level file I/O normally associated with saving data.

The Storage VIs are located in the functions palette, as shown below.

Figure 1.

In this section, you create a simple data acquisition application using DAQ Assistant and save the data to disk using the Data Storage VIs. The following section steps you through building the VI shown below.

Figure 2.

1. Open a blank VI in LabVIEW.
2. Place DAQ Assistant on the block diagram.
3. Configure DAQ Assistant to read 16 voltage channels and use all the wizard defaults.
4. Place the Open Storage VI on the block diagram. The Open Storage VI specifies the path and file name where data is written. You can change either, and you also can wire in a path constant as an input to the Open Storage VI.

Figure 3.

5. Place the Write Data VI on the block diagram. Note that the Write Data configuration dialog has several parameters to choose from; this example uses all the defaults. Also note – at the top of the configuration dialog, this example uses the Channel object type. Later, you can use this VI to create a channel group.
6. Place the Close Storage VI on the block diagram.
7. Wire the VIs together as shown above.
8 Run the VI.
9. Open the LabVIEW example finder.
10. Click the Search tab, enter the key word (storage), and double-click the word storage.
11. Select Data from the list of returned example programs.
12. Run the TDM Data Viewer example program and select the data file you just saved. Unless you changed the default path and file name in the Open Storage VI, you can find the file at C:\Documents and Settings\your user name\My Documents\LabVIEW Data\Untitled.TDM.
13. Click a channel in the file contents view and click through the object, waveform values, and waveform graph tabs to show the data values and other information.
See Also:
Download the example VIs and DIAdem REPORT template used in this exercise

Back to Top

2. Part 2: Reading Data Back into LabVIEW Using Filter Conditions

In this section, you can read the data you wrote in part 1 back into LabVIEW. The following section steps you through building the VI shown below.

Figure 4.

14. Open a blank VI in LabVIEW.
15. Place the Open Storage VI on the block diagram.
16. Place the Read Data VI on the block diagram.
17. Wire together as shown above, right-click on the Signals terminal, and choose Create > Waveform Graph from the context menu.
18. Run the VI to open the file created in part 1 and display it on a waveform graph, as shown below.
19. Expand the plot legend to show that all 16 channels were read and displayed on the graph.

Figure 5.

20. In the next section, you can query the channels based on maximum value. Looking at the enlarged graph below, you can see that searching on all channels that have a maximum value greater than one yields a subset of these channels. Zoom into your data to determine what maximum value yields a subset of data channels.

Figure 6.

Back to Top

3. Part 3: Reading Data Back into LabVIEW Using Conditions

In this section, you modify the VI you created in part 2 to read data back conditionally. The following section steps you through building the VI shown below.

Figure 7.

21. Using the VI created in part 2, double-click the Read block to bring up the configuration dialog shown below.
22. In the Query Property to compare list box, select Maximum and click the OK button.

Figure 8.

23. Right-click and create constants at the Maximum and Comparison inputs on the read block.
24. Set the maximum constant to 1 (or whatever works best with your data).
25. Set the comparison sign to >, (or whatever works best with your data).
26. Run the VI and switch to the front panel to show how, using the graph legend, only a subset of signals display. Note that only eight of the 16 voltages are shown below.

Figure 9.

Back to Top

4. Part 4: Acquiring Data and Saving It with Additional Properties

In parts 1, 2, and 3, you found that the storage VIs can save data in a very similar fashion to traditional file I/O where you open, write, and close the file. In this section, you add descriptive information to the data, showing the power and flexibility that the storage VIs have over traditional file I/O. The following section steps you through building the VI shown below.

Figure 10.

27. Switch to the VI you created in part 1.
28. Double-click the Write Data block to bring up the configuration dialog.
29. Select Name, Unit, and Description from the available properties list, using the > button to move each over to the selected list.
30. Click the OK button.
31. On the block diagram, right-click and create constants at the Name, Unit, and Description inputs as shown above. Type whatever you wish into the constant blocks.
32. Run the VI.
33. Using the data viewer example program, open the file and ensure that the name, unit, and description just added to the block diagram are saved as expected with the data. You have just extended this dataset’s usefulness by documenting it further. Notice that you did not have to do any additional programming in this dataset to extend the information available. The API for the Storage VIs abstracts the low-level programming normally associated with adding information to a file.

Back to Top

5. Part 5: Adding Structure to Your Data

In this section, you add structure by introducing an analysis group. Adding structure in the form of channel groups helps you logically separate different types of data, therefore making the data easier to understand. In this example, you build on the VI created you created in part 3 to do signal analysis on a subset of channels that are read using the conditional read block. Then, you write those channels back into a new group after performing spectral measurements on the signals, as shown below.

Figure 11.

34. Starting with VI created in part 3, delete the green refnum wire that connects the read data and close storage blocks, and move the close storage block to the right.
35. From the Express Analysis palette, select the Spectral Measurements VI and wire the read block output to the Spectral Measurements VI signal input.
36. From the Data Storage VI palette, select Write Data VI.
37. From the Settings Object type pull down menu, select Channel group as shown below. Note that the write data block serves two purposes – to write data as in previous examples, or to introduce new groups in your data set (shown in this example).
38. Wire the read data block storage refnum (file) output to the refnum input on the write data block you just configured.

Figure 12.

39. From the Data Storage VI palette, select another Write Data VI.
40. This step is very important – wire the storage refnum (channel group) on the write data (channel group) block to the storage refnum (channel), as shown in VI above. This associates channels written by the write data block to the group you just created.
41. Wire the Spectral Measurements VI FFT (RMS) output to the signal input on the Write Data [Channel] VI.
42. Run the VI.
43. Run the Data Viewer VI and notice that you now have a new group called FFT, as shown below.
44. Quit the Data Viewer after looking at the file.

Figure 13.

Back to Top

6. Part 6: Capturing Events Using the Storage VIs and Properly Documenting Test Data

In this section, you run a VI created to show how benefits of TDM files scales from LabVIEW to DIAdem. You use the Write Event Data VI shown below. Another key point illustrated in this example is that it is very easy to capture key information in the form of comments and save it with the data.

Figure 14.

45. Open Write Event file that comes with this exercise and examine the block diagram.
46. Observe the following:
  1. The outer for loop is running one hundred times, and in the process generating data that is being continuously saved to disk in an append mode.
  2. During the acquisition process, a random event is fired from the Random Event Generator VI, which triggers the case structure true condition.
  3. The first time the case structure true condition is executed, a new group called events is created, and the time and event messages are written to new channels in this group. In addition, the simulated signal is passed into signal analysis block to calculate the FFT which is also saved to disk within the new group.
  4. Double-click the write event times write data block and note that the check box at the top labeled “Always create new channel group/channel” is NOT checked. This means that, each time the event times are written, they append to the data channel that was created the first time the loop executed.
  5. Contrast this against how the data is handled by the write data block labeled “write event analyzed data’” by double-clicking on this block. Note the “Always create new channel group / channel” is checked, meaning that, each time this case is executed, you get a new data channel written into the file.
47. The other half of the Write Event is shown below. Not only does this example save data while logging events, but it includes important descriptive information.
48. It is important to recognize that as programmers we are required to document code as part of doing good work, and the same holds true for documenting data – the more additional descriptive information you save with the test, the easier it is to understand later. The LabVIEW Data Storage VIs abstract the low-level file I/O required to add extra information to further qualify your test data. Properly documenting your test results prevents confusion and promotes efficient information exchange.

Figure 15.

See Also:
Download FREE Evaluation Copy of DIAdem


Back to Top

7. Part 7: Using DIAdem to Further Inspect, Analyze, and Report the Results

In this section, you investigate how all the information captured in the previous exercise is available in DIAdem, and how you can use DIAdem to further analyze and report your test data.

49. Start DIAdem. If you do not have a copy, you can download a free 7-day evaluation version at
50. Switch to the Data NAVIGATOR, and clear the data portal, as shown below.

Figure 16.

51. Expand the My Documents folder and the LabVIEW Data folder and click and hold your left mouse button on Untitled.TDM while dragging it into the data portal as shown below.

Figure 17.

52. Note the data structure – there are two groups.
53. Click the Events group and note that the name and description display the same information that you specified in the LabVIEW VI from part 6.
54. Switch to DIAdem VIEW as shown below.
55. Click and drag the Untitled group to both the upper graph and lower table.

Figure 18.

56. Add another page to your VIEW layout. Click the predefined screen partition as shown below, select the fifth choice, and once again drag the Untitled group to both the upper and lower graphs.

Figure 19.

57. Next, investigate how DIAdem can help you interactively inspect signals.
58. Click the band cursors as shown below in step 1.
59. Click in the upper graph and, using the mouse, separate the vertical graph cursors to the approximate distance shown below.
60. Click the scroll icon in the lower graph as shown in step 3.
61. Click and hold the left mouse button down between the two vertical graph cursors in the upper graph and move the mouse left and right, as noted in step 4.
62. Notice the signal is noisy – use the DIAdem analysis functions to clean up this signal.

Figure 20.

63. Before performing the analysis, set the Untitled group to the default group to ensure any calculations are saved into this group.
64. In the data portal, right-click on the Untitled group and select ‘Set default group’ from the menu, as shown below. The Untitled group should now be bolded.

Figure 21.

65. Switch to DIAdem ANALYSIS as shown below in step 1.
66. Click curve fitting functions (shown in step 2), and select the smoothing function (in step 3) as shown below.

Figure 22.

67. Drag and drop the Sine with MLS Sequence channel from the data portal onto the channel input on the smoothing dialog as shown below.
68. Click the execute button.

Figure 23.

69. Switch to DIAdem VIEW as shown below.
70. In the data portal, select the Time channel, hold down the control key on your keyboard, and select the Y_smooth channel (step 1).
71. Drag and drop both channels onto the lower graph (step 2).
72. Resize the zoom area as defined by the upper graph’s vertical cursors (step 3) and note the difference in the original noisy and smoothed signals.

Figure 24.

73. Switch to DIAdem REPORT as shown below (step 1).
74. Select Time and Y_Smooth from the data portal and drag them on to the XY graph as shown below.
75. Select the Event time and Event type channels from the data portal and drag them onto the table as shown in step 3.

Figure 25.

76. Click the XY graph and use the graph handles to make the graph approximately half the size it is now, as shown below.

Figure 26.

77. Insert a new 3D graph as shown below.

Figure 27.

Figure 28.

78. Before inserting the 3D graph data, make one quick change in how the data is organized in the data portal.
79. Click and drag the Event time channel so it is below the Frequency channel as shown below.

Figure 29. & Figure 30.

80. Click the Frequency channel, hold the shift key down, and select the last channel in the data portal to highlight all the channels as shown below.
81. Drag all the highlighted channels onto the 3D graph as shown below.

Figure 32.

82. Enhance the 3D graph display as shown below.

Figure 32.

83. Double-click the 3D graph to bring up the following configuration dialog.
84. Switch the color selection to Glob palette 1.. as shown below (step 1).
85. Click the Curve parameters button (step 2).

Figure 33.

86. Select Filed display (step 1) and Additional grid lines (step 2), and choose black (step 3) as the grid color as shown below.
87. Click the OK button on both dialogs to return to the report.

Figure 34.

88. From file menu in DIAdem REPORT, select Save.
89. Note, when you save a DIAdem REPORT, you are just saving a definition of the graph objects, and not the physical data that is currently displayed on the report. DIAdem REPORT outputs are not dedicated to a specific dataset, making them reusable and shareable with coworkers.
90. To demonstrate the report template concept, from the DIAdem REPORT file menu, select Open.
91. Select the report file StorageVIs.TDR (included with this application exercise).
92. Notice that there are three pages to the report – in the General info default page, the lower graph shows the original test data overlaid with the different events and the corresponding times at which they occurred. The upper graph shows the results of the FFT calculations.

Figure 35.

93. The second page, 3D Spectrum, displays an FFT results 3D graph at each event time, and a table that shows when a particular event happened and what type it was.

Figure 36.

94. Note that the cover sheet contains the comments that were captured at the time of the acquisition.

Figure 37.

Back to Top

8. Part 8: Optional – Saving Custom Properties to a TDM File

This section illustrates how to save custom, user-defined properties to a TDM file. Custom properties are very useful in documenting test data using terms that are specific to a particular test. This also illustrates the LabVIEW Data Storage VI flexibility in tailoring them to your specific storage needs.

Figure 38.

95. Load the TDM DemoScript
96. Observe how ‘’ is wired between the Write Data [Channel group] and Write Data [Channel]’ VIs.
97. You find the custom property VI at C:\Program Files\National Instruments\LabVIEW 7.1\vi.lib\platform\storage in the Storage.llb. The VI name is ‘’
98. Run the example, switch to DIAdem, and observe how UUT is now a property at the group level, as shown below.

Figure 39.

Related Links:
Download - Example VIs and DIAdem REPORT Template for these exercises
Download FREE Evaluation copy of DIAdem

Back to Top

Bookmark & Share


Rate this document

Answered Your Question?
Yes No