Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Attempted to read samples that are no longer available, how do I resolve my buffering issues?

THe attached vi is set up for a single channel and one grpah. Normally I have three running simultanesouly and just triple up on everything. I am sampling at 10Hz and grpahing at 1/10 that so that to the user the data looks once per second. The grpah x axis is setup to display 4 minutes of data (240 seconds) and then begin to scroll forward always keeping 240 seconds of data on display. After runnign for a bout 20min I begin to get the buffer error if I hit stop and it says samples are unable to read from the system or seomthing to that effect. Why is this happening and what should I change to prevent this. before anyoen suggests it, I CANNOT use a chart because I have to have cursors appear on the graph as markers. SO the data will always be forever accumulating in the waveform graph. I tried to st an array size but then that prevents me from having the x axis scroll forward and the graph does more of a 240 second sweep.

 

Any ideas on how to prevent the buffer issue?

0 Kudos
Message 1 of 7
(4,631 Views)

Constantly building an array does get really expensive (and really slow).  You really should limit the size of your data.  After 20 minutes, we are talking about 12k data points.  That is ~100kB that have to be allocated for each read.  Yes, that will slow down your system and cause you to not read the DAQ quick enough to keep the buffer from filling up.

 

So use Initialize Array to set your data to something like 1024 data points (that is the default for a chart) and use Rotate 1D Array and Replace Arrray Subset to update the data in your graph.  This will create a circular buffer and prevent the massive memory reallocations.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 7
(4,625 Views)

@crossrulz wrote:

Constantly building an array does get really expensive (and really slow).  You really should limit the size of your data.  After 20 minutes, we are talking about 12k data points.  That is ~100kB that have to be allocated for each read.  Yes, that will slow down your system and cause you to not read the DAQ quick enough to keep the buffer from filling up.

 

So use Initialize Array to set your data to something like 1024 data points (that is the default for a chart) and use Rotate 1D Array and Replace Arrray Subset to update the data in your graph.  This will create a circular buffer and prevent the massive memory reallocations.


I tried doing that but it makes the waveform graph update in a sweep fashion and it does not progress forward through time. I don't care what happens to the data not being displayed currently I jsut want the x axis to tick up with each passing second. I tried it with the intialize array before and after my array is created (in and out of the while loop shift registers) and it has the same effect. I can either set a fixed array size and lose my x axis scrolling or keep the scrolling and run into buffer issues, are these my only paths?

 

if i set the input buffer to max something like 4294967295 samples using the confgire input buffer block before daq mx start will that do anything? I cant imagine I will ever need that many samples.

0 Kudos
Message 3 of 7
(4,619 Views)

as a side quesiton would i be better served if i adopted this vi method:

 

https://decibel.ni.com/content/docs/DOC-26558

 

right now I have analysis, display and queieing in one loop and data logging in another. Would things be better and I would have more efficient memory management if I separated everything like that example?

0 Kudos
Message 4 of 7
(4,606 Views)

I am a huge fan in seperating tasks into seperate loops.  But in this case, I think you have the breakup right.  Any more would add unnecessary complication, in my opinion.

 

Do you actually need the sample number for the X axis or would the time work?  Try reading the DAQ data as a waveform.  You will want to seperate out the T0 (time the sample was taken) and Y (the current data point).  Keep the data and the T0 in seperate circular buffers like I described earlier.  So with the new sample, you just create a new waveform that has the oldest T0 and all of the Y data.  Your X axis should be set to use absolute time for this to work the way I'm picturing it.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 5 of 7
(4,595 Views)

I am not understanding what you are saying, or it just isnt working. I separated the data and got its waveform attriubutes. Now I have time scrolling along my axis, but it just compresses the graph. Where do I set the array size and make it loop? Also doing this seems to change where my cursors fall when the button is pressed.

0 Kudos
Message 6 of 7
(4,570 Views)

The waveform separation method appeared to be slowing down over time (lost 1 min of tracking nearly every 60) so I tried the method from the example I posted and that seems to work. With the loop iterations being timed/driven by the daq now.

 

0 Kudos
Message 7 of 7
(4,552 Views)