07-12-2010 01:39 PM
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!
07-12-2010 02:31 PM
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.
07-12-2010 02:37 PM
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.
07-12-2010 03:06 PM
Thanks a lot!
I'll take a look at the tutorials too.
gchaw
07-13-2010 06:57 AM
To learn more about LabVIEW, I suggest you try looking at some of these tutorials.