LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I write more than two sets of data to a spreadsheet file.

I have a very simple data acquisition system. There are going to be at least two channels of data and I'd like to write all the data points to a spreadsheet file. Currently, I can connect two of the ouputs to a "build array" function, connect that to a "write to spreadsheet.vi", and taking that outside the while loop, connect it to a "Write characters to file.vi". The only problem is that when I try to connect a third input it will not work. I am successful getting two columns of data, but how would I incorporate three or more? Thanks.
0 Kudos
Message 1 of 8
(3,731 Views)
I think you can achieve it by put all your data in a 2-D array, then just use" write to spreadsheet file vi" once.

or you can also use "write to spreadsheet file vi" more times, each time you choose the boolean control" append to this file " on this vi to be true (except the first time you use this vi.

you will achieve this goal.
0 Kudos
Message 2 of 8
(3,731 Views)
Two things. First, when you say it doesn't wok with three inputs, what exactly happens?

Second, if you could post your code in V6.0 format I'd be gladd to look at it for you.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 3 of 8
(3,731 Views)
In regards to the first suggestion - how would I build a 2-d array? I am only familiar with using the "build array" function, and when I add more than two inputs to that, the "write to spreadsheet file.vi" doesn't work.
I tried you second suggestion. It seems to record data to a file, but I will not stop prompting for a new file, so instead of getting one file with all my data, I get multiple files with one line of my data. Any thoughts?
0 Kudos
Message 4 of 8
(3,731 Views)
When I put three inputs, the wiring just goes bad. It says it's not a proper input into "write to spreadsheet.vi"
I have attached a zip file containing 8 vi's. In the "forcelocator.vi" I have a random number generator hooked up for the time being. I would like an output of all 8 1's and 0's to write to a spreadsheet file as long as the system is running.
In the "twochannels.vi" I am going to be adding another graph and I would like to have the output of this graph write to a spreadsheet file along with the other two current outputs.
By the way, would you also know how to attach some sort of boolean control which displays output on one of the graphs such that when you press the button, it quickly graphs a 1 (this is meant to be an event marker) and
write that to a file as well. Thank you for the help.
0 Kudos
Message 5 of 8
(3,731 Views)
You're either somehow creating a 3D array and trying to connect it to the 2D array input of Write to Spreadsheet, you've got a 2D array connected to the 1D array input, or you've got a 1D array connected to the 2D input. Your VI should look something like the attached picture with three separate 1D arrays going into the build array function and the output of that connected to the 2D array input of Write to Spreadsheet. If you wire a true to the Append to File input of Write to Spreadsheet, then you not need to create a new file every time.
0 Kudos
Message 6 of 8
(3,731 Views)
See the following Knowledge Base for an example of writing to a spreadsheet file from LabVIEW.

http://digital.ni.com/public.nsf/websearch/1678E94CB6FC508C86256C2200771468?OpenDocument

A quick fix for you using the second suggestion is to use a shift register to store you file name through each interation of the while loop so that it does not prompt you each time. Then, as long as the boolean for append to file is true, you should get all data into one file. If you would like the original run to prompt for a file name then you can add a file dialog VI to initialize the shift register instead of a string constant or control.



This is not the most efficient way because it opens and closes the file each loop interation. For better performanc
e, examine the block diagram of the Write to Spreadsheet File VI and modify it so that the open, close, etc occur only once while the read occurs during each interation of the while loop. This method is called streaming to disk and there are some shipping examples available under the Fundamentals section. You can get to the shipping examples from the help menu in LabVIEW.
0 Kudos
Message 7 of 8
(3,731 Views)
I have your code tweaked, but for some reason I can't post it back to the discussion group. If you contact me directly I can send it right to you.

Mike...
mlportersr@webtv.net

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 8 of 8
(3,731 Views)