Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Lab Exercise: Writing Data to a Spreadsheet File in LabVIEW - Prof. Anthony Duva, Assignments of Mechanical Engineering

A step-by-step labview exercise to write data to a spreadsheet file. It covers opening a blank vi, using the open/create/replace file function, a while loop, write text file function, array to spreadsheet string function, and other related functions. The exercise also includes creating constants, formatting strings, building arrays, generating random numbers, and closing the file.

Typology: Assignments

Pre 2010

Uploaded on 08/18/2009

koofers-user-p7x-1
koofers-user-p7x-1 🇺🇸

10 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Exercise 2.4 – Write to Spreadsheet File
1. Open a blank new VI from the Getting Started screen.
2. Place the Open/Create/Replace File function on the block diagram. Right-click on
the block diagram to open the functions palette and select File I/O » Open/Create/
Replace File.
3. Right-click the operation terminal of the Open/Create/Replace File function and
select Create » Constant from the shortcut menu, and select open or create from
the drop down menu.
4. Place a While loop from the Structures palette on the block diagram to the right of
the Open/Create/Replace File function. Right-click on the block diagram select
Structures » While Loop.
5. Place a Write Text File function inside the While Loop. Right-click on the block
diagram select File I/O » Write To Text File.
6. Wire the refnum out terminal from the Open/Create/Replace File function to the
file (use dialog) terminal of the Write Text File function.
7. Wire the error out terminal from the Open/Create/Replace File function to the
error in terminal of the Write Text File function.
8. Place an Array to Spreadsheet String function inside the while loop and to the left
of the on Open/Create/Replace File function. Right-click on the block diagram
and select String » Array to Spreadsheet String.
9. Right-click the format string terminal of the Array to Spreadsheet function and
select Create » Constant from the shortcut menu and enter “%0.4f” in the string
constant to format the input data.
10. Place a Build Array Function on the block diagram. Right-click on the block
diagram and select Array » Build Array.
11. Place a Random Number inside the While Loop. Right-click on the block diagram
and select Numeric » Random Number (0-1).
12. Wire the error out terminal of the Write Text File function to an output tunnel
on the While Loop.
13. Place an Unbundle By Name function inside the While Loop. Right-click on the
block diagram to open the functions palette and select Cluster & Variant »
Unbundle By Name.
14. Wire the error out from the Write Text File function to the Unbundle By Name
function.
15. Place an Or function in the While Loop. Right-click on the block diagram to open
the functions palette and select Boolean » Or.
16. Switch to the front panel and place a stop button. Right-Click on the front panel to
open the Controls palette and select Boolean » Stop Button.
17. On the block diagram, wire the status element of the error cluster to the x input
of the Or function and wire the stop button to the y input.
18. Wire the output of the Or function to the conditional terminal of the While Loop.
pf2

Partial preview of the text

Download Lab Exercise: Writing Data to a Spreadsheet File in LabVIEW - Prof. Anthony Duva and more Assignments Mechanical Engineering in PDF only on Docsity!

Exercise 2.4 – Write to Spreadsheet File

1. Open a blank new VI from the Getting Started screen. 2. Place the Open/Create/Replace File function on the block diagram. Right-click on the block diagram to open the functions palette and select File I/O » Open/Create/ Replace File. 3. Right-click the operation terminal of the Open/Create/Replace File function and select Create » Constant from the shortcut menu, and select open or create from the drop down menu. 4. Place a While loop from the Structures palette on the block diagram to the right of the Open/Create/Replace File function. Right-click on the block diagram select Structures » While Loop. 5. Place a Write Text File function inside the While Loop. Right-click on the block diagram select File I/O » Write To Text File. 6. Wire the refnum out terminal from the Open/Create/Replace File function to the file (use dialog) terminal of the Write Text File function. 7. Wire the error out terminal from the Open/Create/Replace File function to the error in terminal of the Write Text File function. 8. Place an Array to Spreadsheet String function inside the while loop and to the left of the on Open/Create/Replace File function. Right-click on the block diagram and select String » Array to Spreadsheet String. 9. Right-click the format string terminal of the Array to Spreadsheet function and select Create » Constant from the shortcut menu and enter “%0.4f” in the string constant to format the input data. 10. Place a Build Array Function on the block diagram. Right-click on the block diagram and select Array » Build Array. 11. Place a Random Number inside the While Loop. Right-click on the block diagram and select Numeric » Random Number (0-1). 12. Wire the error out terminal of the Write Text File function to an output tunnel on the While Loop. 13. Place an Unbundle By Name function inside the While Loop. Right-click on the block diagram to open the functions palette and select Cluster & Variant » Unbundle By Name. 14. Wire the error out from the Write Text File function to the Unbundle By Name function. 15. Place an Or function in the While Loop. Right-click on the block diagram to open the functions palette and select Boolean » Or. 16. Switch to the front panel and place a stop button. Right-Click on the front panel to open the Controls palette and select Boolean » Stop Button. 17. On the block diagram, wire the status element of the error cluster to the x input of the Or function and wire the stop button to the y input. 18. Wire the output of the Or function to the conditional terminal of the While Loop.

  1. Place a Close File function to the right of the While Loop. Right-click on the block diagram to open the functions palette and select File I/O » Close File.
  2. Wire the refnum output tunnel to the refnum input terminal of the Close File function.
  3. Wire the error output tunnel to the error in terminal of the Close File function.
  4. Return to the front panel and run the VI. You will be prompted to “Choose or enter path of file to open”, enter: “spreadsheet.xls”.
  5. Click on the stop button to stop the execution of the VI.
  6. Open the file named: “spreadsheet.xls”.
  7. Save and the close the VI. (End of Exercise)