LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Write 2 chanel waveform data to text file

I ever posted similar question. Based on helpful answers form that post, I narrowed down my purpose and now post again in order to get more focused discussions on it.

In following VI, data from 2 channels are acquired, which need to be displayed and also written to a text file.



Since the 'write measurement file'  express VI open and close in each loops run,  I plan to get rid of it due to low efficiency.

I tried 'write to spreadsheet file' VI, failed. Also, looks like the 'write to spreadsheet file' VI also open and close file in each loop run, so it is  not true 'low-level' VI.

So, I am looking forward to any hint on using low-level file I/O Vis to realize same function as provided by 'write measurement file' express VI.

Thanks a lot in advance.

Sincerely,
-Dejun

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

Download All
0 Kudos
Message 1 of 6
(3,191 Views)

First, make sure you wire up your error wires. Smiley Wink

Second, I don't think you need a conver 1DWaveform to Dynamic Data, then a Dynamic Data to Array to feed into the chart.  The chart will take the waveform directly.

Right click on your Express VI and Open Front Panel.  Say yes to convert.  (You may want to save a backup of your current VI since this is a one way operation, and you have something to fall back to incase  this fails.

Drill down into the subVI and see how it is written.  I usually start something with an Express VI to get something started quickly, but do this to see how it works and learn something.  But when I did this for the Write Measurement file express VI, it was a bit scary.

However, all of the file function VI's you need are in the file I/O pallette.  Remember to open a file before a loop, do your writes in the the loop, close the file after the loop.  Wire the file reference wire and the error wires through.  Use shift registers with them.  Look at the Help menu/Find examples and look at the various File I/O examples. 

0 Kudos
Message 2 of 6
(3,178 Views)
Thanks Ravens for your reply.

"I don't think you need a conver 1DWaveform to Dynamic Data, then a Dynamic Data to Array to feed into the chart.  The chart will take the waveform directly."
I know the chart takes waveform directly, but the way it displays the plot is not what I need. I got this coding from convert DAD Assistant (Indeed, this is the way you recommended to me in one of my previous posts)

I ever tried to convert write measurement file express VI, that's too scaring.....


Message Edited by Dejun on 08-28-2007 09:00 AM

0 Kudos
Message 3 of 6
(3,163 Views)


@Dejun wrote:
I know the chart takes waveform directly, but the way it displays the plot is not what I need. I got this coding from convert DAD Assistant (Indeed, this is the way you recommended to me in one of my previous posts)


That's fine, if it works the way you want, go with it.  It just jumped out at me that it is doing two conversions in a row.    One other possibility is that there is a Get Waveform Components function in the Waveform Pallette that takes a waveform in, and puts out an Array on the Y component of the cluster.

Those express VI's are pretty powerful and have to have a lot of flexibility to work in different situations, so they may not always generate the simplest, most efficient code.  Like I said, I like using them to get something to work quickly, especially if I don't know how to begin from scratch.  Smiley Happy

0 Kudos
Message 4 of 6
(3,152 Views)
Yes, express VIs are very easy to use, especially for beginners, but I see from this forum that some people complain write measurement file VI in loop structure open and close file too frequent so that the system resource is used up......This is why I try to use low-level VIs to replace express VI.

Do you think I should convert the waveform array to array and write to text file using low-level VIs? Since my DAQ is continuous, I am concerning whether the size of the array will be too large causing memory overflow....

0 Kudos
Message 5 of 6
(3,140 Views)
I don't think you would have a problem with the array size getting too large.  On each iteration, there is an N column, by N sample array getting generated (or essentially in the waveform),  and that is inherently getting overwritten on each iteration.  So I don't think you have a case of the array growing without bounds.
 
I do think it is a good idea to use the lower level file I/O so that you only open and close the file once before and after the loop.  In theory, you shouldn't have memory overflow on the file open and close operations within the loop since each file reference opened is also getting closed.  So go ahead and try some longer term operation of the program acquiring some sample data and recording it.  See how it behaves.  If it runs for as long as you need it to without problem, and you get all of the data points without missing any, there is no reason not to use it.
 
In principle, who isn't a good programming practice to repeatedly open and close the same file over and over because it could hurt performance, but that doesn't necessarily mean it will hurt performance depending on you particular application.  So if you do have performance problems, or you want to learn how to use the lower level File I/O, go ahead and try using it.
 
 
0 Kudos
Message 6 of 6
(3,135 Views)