Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

Repeatedly starting/stopping task causes Onboard device memory overflow

Solved!
Go to solution
I have a c++ program that communicates with a NI USB-6009 OEM board via NI-DAQmx. The first time it starts a task, reads and then closes the task, everything works. Then randomly after 2-5 more times, I will get an error "Onboard device memory overflow. Because of system and/or bus-bandwidth limitations, the driver could not read data from the device fast enough to keep up with the device throughput. Reduce the sample rate, or reduce the number of programs your computer is executing concurrently." When I try to read using the DAQmxReadAnalogF64 function.  The program uses a separate thread which constantly reads using the DAQmxReadAnalogF64 function after I start the task. The scan rate is 22,000 and the buffer is set to 100,000. The thread that reads is set to read up to 10,000 points and normally when running only 10-20 are read from the channel each time DAQmxReadAnalogF64 is called. Any ideas on why this error occurs? Is there a way to recover or reset the device after this error? I have tried slowing down the scan rate, but the problem still appears. ThanksSheldon
0 Kudos
Message 1 of 15
(10,661 Views)

Hi Sheldon,

 

First, please reference this article and see if this provides any insight to this issue.  Also, did you have an error code with the message that you are seeing?  Is the error code the same as in the article?  

 

Here is another article over memory overflows and how to work around them.  One of the two should have the information you are looking for.

 

Kyle A.
National Instruments
Senior Applications Engineer
0 Kudos
Message 2 of 15
(10,645 Views)

 

Hi Kyle,

 

The error after calling the DAQmxReadAnalogF64 is -200361. However I don't understand how it could be a Buffer Overflow Error. I have a dedicated thread that reads the data from the channel using DAQmxReadAnalogF64. It does nothing else. The first few times (Starting and Stoping the task) the program works with no errors.If I change the sample rate to 100 and the buffer size to 10000, then I don’t see how the buffer could overflow as I am consistently reading the channel.

 

I only have this problem if I start and stop the channel a few times.

 

Does NI have a C++ example that use a separate thread that calls the DAQmxReadAnalogF64 Function to read the samples?

 

Sheldon

0 Kudos
Message 3 of 15
(10,611 Views)

Hi Sheldon,

 

This error is associated more with the communication from the USB-6009 to the PC.  Typically, USB communication has a high amount of latency which inhibits the data transfer from the USB to the OS.  Also, Windows is non-deterministic, which means the time between transfers vary depending on the tasks running within the OS and the priority of those operations.

 

The USB-6009 has a relatively small FIFO, which means if you are acquiring data at a fast rate, you can easily overflow the FIFO if the CPU is being used extensively while an acquisition is happening.  It could be possible that when starting/stopping a task several times could cause the CPU to ramp up and slow down communication enough to prevent the data transfer speeds from being where they need to be.

 

What operating system are you using on your PC?  What is your sampling mode?  You can try and use finite sampling mode, which will allow you to control when you need to stop and how many samples to read off at a time.  If you go to Start » All Programs » National Instruments » NI-DAQ » Text-Based Code Support » Visual C++ Examples, you should be able to find the complete list of text-based examples for DAQmx. 

Kyle A.
National Instruments
Senior Applications Engineer
0 Kudos
Message 4 of 15
(10,577 Views)

I am seeing the same memory overflow problem wiith a USB-6009 using SignalExpress running at its default setting of 1K Hz.  If I drop the analog input step and start/stop a few times this error occurs.  The operating system is Windows 7 64 bit.

 

I found by running Windows XP as a virtual machine within the same environment the problem does not exist.  SignalExpress and USB-6009 running of the XP virtual machine OK.  Is it a Windows 7 driver issue? 

0 Kudos
Message 5 of 15
(9,868 Views)

Sure it is possible. What version of DAQmx and Signal Express are you using?

--Michelle

National Instruments
0 Kudos
Message 6 of 15
(9,844 Views)

I'm running Labview SignalExpress 2010 4.0.0 and NI--DAQmx 8.9.5.  Thanks for quick reply.

0 Kudos
Message 7 of 15
(9,834 Views)

 

The operating system we are using is Windows Embedded Standard SP3, but I have the problem on Windows 7 also.

 

The sampling mode is DAQmx_Val_ContSamps as I need to always read the data.

 

It seems that if I load the program, capture data, then exit. Then load the program and repeat the problem does not occur. If I start/stop the task in code randomly the error occurs.

 

Sheldon

0 Kudos
Message 8 of 15
(9,827 Views)

Try to make sure you have other applications minimized or closed during acquisition. This should help - you can also monitor your CPU usage and see how the CPU is performing during the multiple start and stops. Depending on how your are starting and stopping the task you can be adding unnecessary overhead by creating a task everytime, instead of creating it once and running a continous acquisition. I think Kyle made some good points how starting and stopping the task could ramp up your CPU usage.

 

All-in-all it looks more to be product of:

 

  1. The USB-6008/6009 has a relatively small onboard FIFO.
  2. Communication with the device is message based over USB which is inherently slower than equivalent communication over PCI.

If you need more throughput I would switch to PCI.

 

USB-6008/6009 Error -200361: Buffer Overflow Error

http://digital.ni.com/public.nsf/allkb/611475F9BE62881E86256FDC0062B1BB?OpenDocument

--Michelle

National Instruments
0 Kudos
Message 9 of 15
(9,804 Views)

 

Normally the program does not start/stop a task. It starts the task once, but if I even try to stop (task using one channel) and then create a task with two channels I run into problems with the Buffer Overflow Error. No other programs are running and the CPU usage is showing 0%-5%.

 

My only guess is that something is happens when the NI dll's are unloaded or the time it takes to exit the program and start up again that it doesn't get the Buffer Overflow Error when repeatedly loading/closing the program.

 

I can load the program, start a task, stop the task, exit the program and repeat and I have no problems.

 

If I load the program, start a task, stop the task, create a new task then I got the Buffer Overflow Error.

 

I guess I just have to test different ways to see if I can find some method that will allow me to start/stop a task without getting a Buffer Overflow Error.

 

Sheldon

 

0 Kudos
Message 10 of 15
(9,797 Views)