LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LabVIEW Buffer Overflow Error

Solved!
Go to solution

Im using LabView 2010, and everytime I go to gather data using my VI, after a few minutes of data, I get an error stating buffer overflow, and the data acquisition stops.

 

How can I get it to stop doing that?

 

Also, my VI is setup to do 10 samples per second and output an average of those 10...then I need 10 averages per minute. It doesnt seem to be doing that part correctly. Can someone advise me how to fix it?

0 Kudos
Message 1 of 11
(9,321 Views)

Attach your VI.  Give us some examples of your data rates.  Are you doing anything else in the loop such as writing to a file after acquiring data?  What DAQ card are you using?

0 Kudos
Message 2 of 11
(9,297 Views)

Well its hard to see what you are doing wrong without the code.  (You can attach an example of the code causing you the problem)

 

The error you are getting means that the DAQ device is taking samples far faster than you are reading the samples.  Eventually the DAQ onboard memory (Buffer) fills up with all that old data you never read.

 

Knowing that, the potential fixes boil down to:

  1. Read more samples each time you read.  (A "-1" wired to the Samples to read control will read all available samples)
  2. Read more often.  (Look into using a Producer- Consumer design pattern to keep all the rest of your code from slowing down the acquisition loop)
  3. Take Less Data! (If you know you are going to need 10 samples per second set the sample rate at 10 samples per second and read 10 samples every second- you'll never fill a buffer that way)
  4. some combination of 1-3.  Begining is tough!  there is a lot to learn.  It's not uncommon for more than one of those mistakes to have been made.  Look through the shipping examples for something that seems to be close to what you really want to do with your data acquisition and read the notes.

"Should be" isn't "Is" -Jay
0 Kudos
Message 3 of 11
(9,296 Views)

@RavensFan wrote:

Attach your VI.  Give us some examples of your data rates.  Are you doing anything else in the loop such as writing to a file after acquiring data?  What DAQ card are you using?


I have a sampling rate of 1000 Hz and 100 samples per channel. I have a cDAQ with all 4-20mA inputs. I am using the DAQ Explorer to setup each channel and the scaling.

 

Yes, I am writing to a file and displaying the data for each channel at the same time (I only have 5 channels setup in the code).

0 Kudos
Message 4 of 11
(9,277 Views)

Channeling my inner Altenbach:

Your code makes no sense!

 

you get "Signals" from the DAQ Assit loop and pass them to the main acq loop.  Now, that data in "Signals" can never ever change no matter how many times the main loop iterates so tossing them into a collector and taking the mean simply chews up memory to get the same result out as in.  EVERY TIME!  how many times do you need to write that value to file?


"Should be" isn't "Is" -Jay
0 Kudos
Message 5 of 11
(9,262 Views)

@JÞB wrote:

Channeling my inner Altenbach:

Your code makes no sense!

 

you get "Signals" from the DAQ Assit loop and pass them to the main acq loop.  Now, that data in "Signals" can never ever change no matter how many times the main loop iterates so tossing them into a collector and taking the mean simply chews up memory to get the same result out as in.  EVERY TIME!  how many times do you need to write that value to file?


I tossed this together between projects without really knowing what I was doing - yes I know it makes no sense. The point is it worked good enough for the first project that it was used for. But "worked" is not good enough for this next project.

 

I need to write the values to the file each time I do the average of 10 samples. I know there is a better, cleaner way of doing this code, but sadly, I just havent had any time to learn my way through doing this myself. Any help improving this and fixing that buffer problem is much appreciated.

 

 

0 Kudos
Message 6 of 11
(9,243 Views)
Solution
Accepted by topic author TEmran
Start by getting rid of all the xvis I think I showed that all of that code serves no useful purpose. don't. replace them with any functions, just toss out the blue icons. Ctrl space ctrl r. poof gone. The rest will work out fairly easy once those hogs are no longer slowing down useful processes.

"Should be" isn't "Is" -Jay
0 Kudos
Message 7 of 11
(9,220 Views)

@JÞB wrote:
Start by getting rid of all the xvis I think I showed that all of that code serves no useful purpose. don't. replace them with any functions, just toss out the blue icons. Ctrl space ctrl r. poof gone. The rest will work out fairly easy once those hogs are no longer slowing down useful processes.

Done. What about the DAQ Explorer that sets up the channels and brings in scales from the cDAQ software? How do I replace that?

0 Kudos
Message 8 of 11
(9,216 Views)

Not sure what you mean by DAQ explorer.  Are you talking about Measurement and Automation Explorer?  If so, you don't replace that.  And it doesn't exist as an item within a LabVIEW VI.  It is a separate piece of software on your PC.  Once you set up your cDAQ in that, including channels and scales if you want, you just pick your channels, or pick your task when you drop a control or constant down on your LabVIEW  block diagram.  Right click the first purple wire and create constant, now wire that in to the first DAQmx VI instead of the purple wire coming from the Express VI, which you will be eliminating anyway.

 

You might want to read the resources available here.  Getting Started with NI-DAQmx: Main Page

0 Kudos
Message 9 of 11
(9,193 Views)

Looks like its working better than before. No more buffer overflow errors, now that I got rid of those blue boxes in the loop.

 

I still would like to clean the code up a little bit to make it look nice, and add more features...but this is good enough for now. I have a customer coming in next week to witness a test and sadly, once again, just dont have the time to improve it right now.

 

Thanks all for the help.

0 Kudos
Message 10 of 11
(9,134 Views)