LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Saving Data to a file

I am communicating with several devices, as some of you might remember. They all communicate fine, but I am unsure as to how to save the data I get from them into a file. There are several report generation sub VI's but I need to get them to read several things and put tyem into a table. I need to get what device it is, what it is reading, a time stamp, and the data all into properly tabled files. I will have several of these recording at once, and there will be various wait times in between the reads. I have tried writing some of my own programs for it, and it never comes out right. The example programs don't do it properly either. It just seems a little beyond my knowledge.

Thank you,
Cole
----------------------------------------------------------------------------------------------------------------------------------------------------
I've got a sneaking suspicion that Jesus might have been made of bread. Why else did they have to put him in a warm cave and wait three days for him to rise?

Damnant quadnon intelligunt - They condemn what they do not understand.
0 Kudos
Message 1 of 6
(3,493 Views)
John,
I'm afraid your description sounds too general to me. I'd be glad to help you, but could you provide some more information? I understand you read data from several devices with varying readout rates. Could you specify a bit more detailed how the results file should look like? What format of a result file do you want? Binary or ASCII-text? Will the results file be read by another Labview program later on, or by Excel, or by Winword, or any other program? How long will the file be at the and? Will everything be in one file? Or does it make more sense to distribute the data in several files? What should happen when a readout  error occurs Should the error also be reported in the file?
Lots of questions, I know, but with the information provided so far it is difficult to help.


A simple structure for a results file could look like this:

11:23:34.21    Instrument1  Voltage/V    -2.345
11:23:34.45    Instrument2  Current/ma  17.4
11:23:35.31    Instrument1  Pressure/Pa  234
11:23:36.07    Instrument3  Power/W   256.7
.
.
.and so on

Is this what you want?

-Franz

Message 2 of 6
(3,474 Views)
I think what you are saying is basically correct, except I need to take samples from each device every, say, 30 seconds. I need the data for each instrument to append to one file for the duration of the run, which may be several hours. I need one file fot he temperature section, (on the bottom of the front panel of the attached file) one for the pressure (the left active ones) and the power (the top left three) if you can just ell me how to do one, I can probably do the rest. I basically need to know which VI's to use, and how to get it to record the right steps. Some of it is stepwise, such as the temperature from the bottom, so the logic is.... difficult for me.
----------------------------------------------------------------------------------------------------------------------------------------------------
I've got a sneaking suspicion that Jesus might have been made of bread. Why else did they have to put him in a warm cave and wait three days for him to rise?

Damnant quadnon intelligunt - They condemn what they do not understand.
0 Kudos
Message 3 of 6
(3,447 Views)

Hello,

 

I am a little unclear of what you are attempting to accomplish with your VI (you might really want to check out the LabVIEW Style Guidelines).  I gather that you are acquiring data every 30 seconds or so for several hours and want to log this information to file(s).  Did you want to write these various columns of data to separate files for each column, or did you want it organized more like a spreadsheet where they are all in one file?

 

In either case, the technique you want to use is the concept of “disk streaming” to write your data.  This means that you will want to first open each file you wish to write data to though the duration of your execution.  Then “operate” on the file as data is acquired – add the new data to the end of the file.  This will be done using the “Write File” VI where the “Pos Mode” is 1 – i.e. write to the end of the file.  Do this for each of the file(s) you wish to append data to, then close the file(s) when your program exits.  There are some good file IO examples in the NI example finder as well as through the NI Dev Zone.

 

Hopefully this will help you get started.  Let me know if you have other questions or if this response did not answer your question!

Travis M
LabVIEW R&D
National Instruments
0 Kudos
Message 4 of 6
(3,422 Views)
What feature would I use to write the data into an Excel file and save different pieces of data into different rows? I would like to get each of the temperatures listed in a different row, with a time stamp for each data point. Same with pressure and power.
----------------------------------------------------------------------------------------------------------------------------------------------------
I've got a sneaking suspicion that Jesus might have been made of bread. Why else did they have to put him in a warm cave and wait three days for him to rise?

Damnant quadnon intelligunt - They condemn what they do not understand.
0 Kudos
Message 5 of 6
(3,389 Views)
I have an example that might help. This VI generates a random number from 0-100 once every second until you stop the VI. It displays both the random number and a user defined limit on a waveform chart. If the random number goes over the limit, a front panel LED turns on. After each number is generated, the entry, date, time (including seconds), number, and a one-word message describing whether the number is "under" or "over" the preset limit are all written to file in spreadsheet format (tab-delimited). The VI uses the "stream to disk" method mentioned by Travis to maximize efficiency. The user can then open the file in any spreadsheet program that accepts tab-delimited files.
 
Kind Regards,
E. Sulzer
Applications Engineer
National Instruments
0 Kudos
Message 6 of 6
(3,370 Views)