LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Please help me with modifying this code

I am using the attached code to acauire and save data to a text file, using 'write measurement file' express VI.

WHat I want to do is to replace 'write to measurement VI' with low-level file I/O VIs. I tried to convert the express VI, but the obtained code is too complicated.

Anyone can give me hints for using file I/O Vis to implement same function without using the express VI? Thanks a lot.




Message Edited by Dejun on 08-27-2007 11:26 AM

Download All
0 Kudos
Message 1 of 9
(2,996 Views)
And exactly what format do you want the data saved as? What exactly about the express VI format do you not like?
0 Kudos
Message 2 of 9
(2,988 Views)
Above code is in a case of an event structure, i.e., each time I click a buttom, such as 'RUN', data acquisition begins and write data into a file.

What I want is, each time this event case is executed, a file is open, write data to it, and finally close this file. The next time when I run this case, maybe another file is open for writting data.

The problem of using 'write measure file' express VI is: if a file is open in one execution of the case, it will continuously be in 'open' after this case execution is finished, i.e., there is no explicit close file function with the express VI, which in some cases may be a problem. What I need is closing the file at the end of each execution of a event case. With low-level file I/O VIs, maybe I can directly put a close file VI there.

The data file should be in text format so that data analysis software, such as MS-powerpoint, can directly reads it.

Message Edited by Dejun on 08-27-2007 01:55 PM

Message Edited by Dejun on 08-27-2007 01:56 PM

0 Kudos
Message 3 of 9
(2,972 Views)
I have to admit I've never heard of Microsoft PowerPoint being described as "data analysis software", except maybe by managers who love to make all those purty pie charts.

Actually, the Express VI does close the file each time. Thus, the file is opened, data is written to it, and the file is closed each time your data acquisition loop runs. You need to provide a different file name each time otherwise the Express VI uses the file it has configured for it, which you have set to "C:\Documents and Settings\Dejun\Desktop\try.lvm". This means you need to wire a value to the Express VI's "File Name" input. A good way to do this is to append a timestamp to the filename. Note that if you keep the Express VI inside the loop, then you want to create the filename outside the loop, otherwise you'll get a new file (due to a new timestamp), each time the loop runs.

Note: based on what you're doing it seems to me that you can just use the "Write to Spreadsheet File" function.

Message Edited by smercurio_fc on 08-27-2007 02:12 PM

Message 4 of 9
(2,955 Views)
This is a vi I use for acquiring data and sending it to a .txt file. I think the original vi is from a temperature logger example I had from Labview 6.1. 
 
Let me know if this helps.
0 Kudos
Message 5 of 9
(2,950 Views)

I don't think you are correct about the function leaving the file open. I think if you convert it to a regular VI and dig deep enough, you will find a TDMS Close. In any case, you can simply replace the Write to Measurement File with an Export Waveforms to Spreadsheet File.

MS-powerpoint is data analysis software?Smiley Very Happy

0 Kudos
Message 6 of 9
(2,954 Views)
Sorry, it's typo, MS-Excel

If I ran the case one time, and manually delete the data file, next time when I run this case structure, an error came. This means the second time the case is run, it looks for the previously opened file....

But now looks like I need to specify a file name for each execution....

Thanks all for your suggestion.


BTW, looks like the express VI does not accept a control determing open new or append a file.....

Message Edited by Dejun on 08-27-2007 02:32 PM

0 Kudos
Message 7 of 9
(2,942 Views)
You can set a checkbox in the dialog to tell the Express VI whether or not to open and close the file on each call ("Lock file for faster access").

If you are looking for a lean and mean solution, check out this example: .\examples\file\plat-tdms.llb\Cont Acq&Graph Voltage - Write Data to File (TDMS).vi.

The TDMS file format can be loaded into Excel with an AddIn that you can download from ni.com for free. Excel objects can easily be embedded in Powerpoint. Loop closed.

Herbert
0 Kudos
Message 8 of 9
(2,936 Views)
So within a case, each time the loop is excuted, the express VI open and close one time? So for a 100 loop, this procedure will be repeated 100 times? If this is the case, I will definitely use low-level VIs.


0 Kudos
Message 9 of 9
(2,931 Views)