From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
I am using an extension of the code called "Measure Buffered
Semi-Period-Continuous.vi" from the example finder. Inside the
main while loop I have added some additional calculations before I
return to DAQmx Read in the next iteration. I am getting an error
-200141 which states that "Data was overwritten before it could be read
by the system." Currently I have the "Number of Samples Per
Channel" at 2 for the DAQmx Read input, but I am not sure if what I
have done is correct for what I am trying to accomplish. What I
would like to do is pull only the first two points of the buffer each
time I come to DAQmx Read. The remainder of the buffer is not
important and could be thrown away if possible. When the next
iteration of the while loop comes to DAQmx Read I would again like to
read the first two points and so on. Also I would like to
know if there is a way that I could keep track of the size of the
backlog of the data for future reference.
Thanks,
Nick
See the producer consumer model of programming. It is best to extend this program by adding a second loop(thread) and after reading your data send it to the analysis loop for processing with a queue. The buffer overrun is due to the data not being raed from the buffer fast enough. Your processing is slowing down your DAQ loop.
You can monitor the number of samples available to read using the DAQmx
Read Property Node, under Status >> Available Samples Per
Channel. Also, here's a Tutorial on the Producer/Consumer Model.
Let us know if you are still running into problems after implementing that model.