LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Read buffer after acquisition

Hello,
I have a buffered continuous acquisition running at 1000 Hz, but, in the real-time loop, I read only one scan each 10 msec (100 Hz). When the user stop the acquisition (or on some condition), I would read all the buffer.
Two questions :
Which parameters (read search position and offset) must I use with AI Read.vi to read all the buffer, even I have already read the last acquisition ?
Can I stop the acquisition before to read the buffer (I tried to pause the acquisition but I have an error -10608 on the following AI Read) ?

Thanks for your input
Hubert Robitaille
0 Kudos
Message 1 of 6
(3,325 Views)
Hello;

Once you made one previous read from the buffer, that data is not in the buffer anymore, and new data will be put on those memory position.

I'm not sure what you want to know from your posting, but the parameter you should input to read the whole buffer at each AI Read, is the buffer size in the "number of points to retrieve from the buffer" input parameter.

If you stop the acquisition before reading the buffer, you will need to call AI Clear to clean up all parameters, and then restart from AI Config. Otherwise, you will get an error.

Hope this helps.
Filipe A.
Applications Engineer
National Instruments
0 Kudos
Message 2 of 6
(3,325 Views)
Hello,

My request is to read all the scan point which have been acquired just before the user stops the acquisition. And I would not read all these points during the main loop to avoid system loading.

For me, when I do a read from the buffer, the data is still in the buffer. The read has just updated the "pointer" on the read position. For this reason, I suppose that I should read again using the "read position" and "offset". I have do some test but I am not sure what I read when I set the position to "end of data", the offset to 0 and the number of scan to read to the buffer size.

I would too stop the acquisition to avoid to overwritte the buffer with new acquisition. If I call AI Clear, I clean up all parameters as you specified, including th
e buffer !

Regards
Hubert Robitaille
0 Kudos
Message 3 of 6
(3,325 Views)
I have done exactly what you are trying to do, Hubert. You are correct that the pointer updates when you do a read. If you specify "end of data" to your AI Read VI, you can set your offset to a negative number (hopefully equal to the size of scans (X) you want to read!). This will return the last X scans that were in the buffer.

Mark
0 Kudos
Message 4 of 6
(3,325 Views)
Many thanks for this information.
Did you stop your acquisition before to re-read the buffer and, if yes, how ?

Regards
Hubert
0 Kudos
Message 5 of 6
(3,325 Views)
Hubert,

There is no reason to stop the acquisition. During a continuous acquisition, if you just want to display the most recent data taken without reading the entire buffer, use "end of buffer" for AI Read VI and an offset of -1, and read 1 scan. If the user presses a button, then just change the offset and number of scans to read to, say, -1000 and 1000 respectively, and save it in a file. Then resume with reading only 1 scan.

You can read this data from the buffer and still have the acquisition writing to the buffer.

Mark
0 Kudos
Message 6 of 6
(3,325 Views)