LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I clear DAQmx Read Buffer?

I know that if I put a -1 to the number of samples to read in the DAQmx Read, it reads all data from the buffer.  Does it also clear the buffer after the read?

How can I be sure that when I do DAQmx Read next time, I only read new data?

Thanks.
0 Kudos
Message 1 of 6
(12,049 Views)
It doesn't clear the buffer after the read, but will update the read position.  If you are doing a finite aquistion, a buffer will be created exactly the size of the number of samples requested set in the timing function.  If you do multiple reads in finite mode and set number of samples to read to -1, the read function will wait for the task to acquire all the new samples.  For a continous acquistion, the read call with a -1 will read all current data in the buffer from the position of the last read.  DAQmx uses a circular buffer so after each read, the read position is updated so that the next read will start at the end of the previous.  If you don't read fast enough, you will get an error saying old data has been written over.  You can use the read property node to monitor (or control) where in the buffer the read operation takes place.  So by default, DAQmx makes sure that you read only new data.
 
regards,
drew
0 Kudos
Message 2 of 6
(12,042 Views)

It is not clear to me how your answer applies to my problem. I want to execute a perpetual loop. At the beginning of every cycle through the loop I want to output one analog sample and read the next 200 analog input samples captured AFTER the analog output event. Then after I read these data, I will consume some more time in the loop doing computations,

during which time the ADC buffer is refilling with samples that I can't use.

 

It seems to me that I want to flush the buffer after the DAC update and wait while the ADC captures the next 200 samples. Can you say precisely how to do this?

 

Regards,
**bleep**

0 Kudos
Message 3 of 6
(11,253 Views)

Good morning,

Thanks for the question.  From your description of the issue, it sounds like incorporating a producer/consumer structure to your program would help.  Here is an example with a small description.  Please let us know if you have more questions.




Additionally, I wanted to make sure that you were replying to the correct thread, since the original post was started over 4 years ago by another user.  Please let me know if that document helps!

Regards,

Lisa

Applications Engineer
National Instruments
0 Kudos
Message 4 of 6
(11,215 Views)

@Lisa This link is broken. Do you have an updated link?

0 Kudos
Message 5 of 6
(923 Views)
0 Kudos
Message 6 of 6
(914 Views)