Saturday, September 25, 2010

Spreadsheet Example VI

Summary: In this exercise, the objective is to save a 2D array in a text file so a spreadsheet application can access the file and to display numeric data in a table. Complete the following steps to examine a VI that saves numeric arrays to a file in a format you can access with a spreadsheet.



EXERCISE 1

1.A) Front Panel

  1. Open the Spreadsheet Example VI located in the C:\Exercises\LabVIEW Basics I directory. The front panel in Figure 1 is already built.
    Figure 1
    Figure 1 (spreadex.png)

1.B) Run the VI

  1. Run the VI. The VI generates a 2D array of 128rows×3columns. The first column contains data for a sine waveform, the second column contains data for a noise waveform, and the third column contains data for a cosine waveform. The VI plots each column in a graph and displays the data in a table.
  2. When the Choose file to write dialog box appears, save the file as wave.txt in the C:\Exercises\LabVIEW Basics I directory and click the OK button. Later, you will examine this file.

1.C) Block Diagram

  1. Display and examine the block diagram for this VI.
    Figure 2
    Figure 2 (spreadexbd.png)
    • sinepaticon.png The Sine Pattern VI located on the Functions>>All Functions>>Analyze>>Signal Processing>>Signal Generation palette returns a numeric array of 128 elements containing a sine pattern. The constant 90.0, in the second instance of the Sine Pattern VI, specifies the phase of the sine pattern or cosine pattern.
    • uniform.png The Uniform White Noise VI located on the Functions>>All Functions>>Analyze>>Signal Processing>>Signal Generation palette returns a numeric array of 128 elements containing a noise pattern.
    • BuildArrayicon.png The Build Array function located on the Functions>>All Functions>>Array palette builds the 2D array from the sine array, noise array, and cosine array, as shown in Figure 3.
      Figure 3
      Figure 3 (BuildArray.png)
    • trans2daryicon.png The Transpose 2D Array function located on the Functions>>All Functions>>Array palette rearranges the elements of the 2D array so element {i,j}becomes element {j,i}, as in Figure 4.
      Figure 4
      Figure 4 (transarry.png)
    • wrtspreadfileicon.png The Write To Spreadsheet File VI located on the Functions>>All Functions>>File I/O palette formats the 2D array into a spreadsheet string and writes the string to a file. The string has the format shown in Figure 5, where an arrow indicates a tab, and a paragraph symbol (¶) indicates an end of line character.
      Figure 5
      Figure 5 (writespread.png)
    • num2fracstrgicon.png The Number To Fractional String function located on the Functions>>All Functions>>String>>String/Number Conversion palette converts an array of numeric values to an array of strings that the table displays.
  2. Close the VI. Do not save changes.

    NOTE: 

    This example stores only three arrays in the file. To include more arrays, increase the number of inputs to the Build Array function.

1.D) Optional

Open the wave.txt file using a word processor or spreadsheet application and view its contents.
  1. Open a word processor or spreadsheet application, such as (Windows) Notepad or WordPad, (Mac OS) SimpleText, or (UNIX) Text Editor.
  2. Open wave.txt. The sine waveform data appear in the first column, the random waveform data appear in the second column, and the cosine waveform data appear in the third column.
  3. Exit the word processor or spreadsheet application and return to LabVIEW.

Content actions

GIVE FEEDBACK:

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...

Popular Projects

My Blog List

Give support

Give support
Encourage Me through Comments & Followers

Followers