Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

how to save and read data from a buffer

I have a while loop and I need to save data acquired in a sequence of the loop and use them in the next sequence. Data are continuously acquired, so I need to save and read from a buffer. Before to acquire the new data, I need to read the buffer and then to save the new data.
0 Kudos
Message 1 of 2
(2,751 Views)
nicusor,

I don't completly understand your question, but I will try to guess your problem.

The answer to your previous question (9/18/02) pointed you in the direction of using the VI, Continuous Acquisition & Graph Using Software Analog Triggering and External Scan Clock (or a similar example).

These VI's have the AI Read contained within a While Loop. Each time the While loop runs the buffer is sent to the waveform graph and the screen display. In essence the human mind is where the data is being saved, except for the last read which remains on screen. (This is what most of the "Continuous Acquire" VI's do.)

You want a permanent record of all the data read. If you wire the output of the AI Read out of the While Loop and use a Write to Spreadsheet VI to record the data, you only get the last buffer read not the entire aquisition. This is because you must leave the indexing disabled (this option is available by right-clicking the tunnel out of the while loop), to wire the AI Read directly to the Write to Spreadsheet VI. With indexing disabled,the Write to Spreadsheet VI only receives data from the While Loop after it is completely finished, and without indexing the only data collected by the loop is the last AI Read from the buffer. Exactly the same as the waveform graph on screen!

If you enable the indexing, the While Loop builds a 3D array of the series of buffer reads for as long as the While Loop runs. The Write to Spreadsheet VI only takes 1D or 2D input, so enabling the indexing causes the wiring to fail between the loop and the Write to Spreadsheet VI.

This is is what I think you are doing: trying to take the unindexed, 2D array from the last buffer read in the while loop, and write it to a spreadsheet. But you want all the buffer eads not just the last one.

Now I will try and describe a solution. First of all you don't want a "Continous Acquisition." "Continuous" implies an open-ended operation that would create an array in memory and fill it...forever, if no body stops it. You really need to perform a finite acquisition. This way the VI allocates the correct amount of memory prior to the acquisition.

Can you define a limited aquisition? For example, acquire form Channel 1 for 10 minutes, triggered by an external scan clock pulse that runs at roughly 100Hz. (I noticed you were interested in external clocking previously.) This limits the array size to 100samples/second x 60 second/minute x 10 minutes = 60,000 readings.

Actually, this amount of data could be aquired in one scan of the buffer. No need for a While Loop at all.

A shipping example VI of this would be:

"Acquire N Scans Using an External Channel Clock (from the shipping examples)

Acquires a specified number of values from one or more analog input channels-based on a channel clock external to your DAQ device."

==========

I am not going to go on, in case I have completely misunderstood your problem. Think about whether you can limit the acquisition, it is not really practical to "continously" send data to a file. You can bring you computer to its knees this way.

If I am correct and you want to persue this approach look at the Multiple Point Buffered Acquisition VI's. They should help.

Also, the better you can describe the exact nature of the INFORMATION you want to gather the better we can help you find a way to acquire it. Notice I said "information". By that I mean: What are you trying to learn? Not, what signal are you trying to measure? If you are clocking externally (with a time varying pulse train), you are trying to learn something different from a timed acquisition. In the first case you want a correspondence between some events of interest. In the latter case you want to look a frequency or other time based occurances. These are important distinctions for designing the VI.

Good luck,

Mike Ross
mross@smpcorp.com
Message 2 of 2
(2,751 Views)