LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

output array to spreadsheet or text file

Hi,

 

I am fairly new to using LabView and I am having trouble understanding how to output an array into an excel or text file.

Basically, what I am trying to do is to have the data output into the file in real time.

The spreadsheet should look something like this:

 

Frequency      rms    

40                  ###    

45                  ###     

etc.

 

or

 

Frequency      peak-to-peak

40                  ###

45                  ###

etc.

 

or

 

Frequency     rms     peak-to-peak

40                 ###     ###

45                 ###     ###

etc.

 

where ### is the data I am trying to collect from a NI usb 6218 card. I'm using this card to send a voltage and also to receive another voltage.

RIght now, the output files only have 1 data point at the end of the program.

Obviously, I would like to have all the data points in 1 spreadsheet.

 

Any help would be appreciated. Thanks!

 

0 Kudos
Message 1 of 5
(2,859 Views)

Your code will never work.  You have the file writes outside of any loop.  When the code is run, the files will be written with whatever data happens to be in those local variables at the start of the program.  Then the files will never be written to again.  This part of the code is only executed one time.  You need to learn about data dependency and execution flow.  Look for free tutorials on NI's website.

 

To solve you problem, you need to get rid of those local variables and put the file write inside the loop that gathers the data, which would be the bottom loop.  You don't need two file writes.  Form an array with the data and use one file write.  You will need a local variable for Frequency since it is in a different loop.  Also put delays in your loops to stop chewing up 100% CPU time.

 

18679iFACDA8F69C670FCE

- tbob

Inventor of the WORM Global
0 Kudos
Message 2 of 5
(2,848 Views)

To create column headers, write the header array to the file before running any loops.  Notice that within the loop, the True constant is wired to the append input.  You don't want to overwrite the data and headers each loop.  Also, the data is numeric so you have to  have the correct format string, %.3f for a number with 3 decimal places.

 

18681i5D415C8A886FDFED

- tbob

Inventor of the WORM Global
0 Kudos
Message 3 of 5
(2,847 Views)

Thanks a lot!

I'll take a look at the tutorials too.

 

gchaw

0 Kudos
Message 4 of 5
(2,836 Views)

To learn more about LabVIEW, I suggest you try looking at some of these tutorials.

0 Kudos
Message 5 of 5
(2,810 Views)