Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Task restart failing with DaqException: Onboard device memory overflow.

Hi,

I am using DAQmx 8.5 to control a NI9215 USB 4 channel analog to digital converter. 

I have written a program (using C# 2.0) that uses the Measurement Studio .NET Class Library.

I am Aynchronously reading the analog input channels at 15000 samples per second using an AnalogMultiChannelReader.  The BeginReadMultiSample / EndReadMultiSample methods are called ten times per second. I call the task Control method to set the state to Commit before I start the task by calling BeginReadMultiChannel.  To stop the task I am calling the task Stop method in the asynchronous callback method that I supply to BeginReadMultiChannel.

 

I have found that if I repetitively start and stop the task that reads the analog input channels, it eventually fails with either a DaqException (Onboard Device memory overflow) or a AccessViolationException. 

When I have configured all 4 channels to be used, I can successfully start and stop the data collection task 8 times before subsequent task starts will result in a failure. When I have configured 1 channel to be used, I can successfully start and stop the data collection task just 2 times before the subsequent task start will result in a failure. 

 

Is this a bug or am I not using the library the correct way?

Any help is appreciated,

Thanks,

Dave McDonald

0 Kudos
Message 1 of 20
(8,120 Views)
This is a continuation of my previous post.
I am pasting some source code that demonstrates the problem.
Create a C# WinForms project. Name the form MainForm. 
Add two buttons named _StartBtn and _StopBtn.  Hook up the Click event handlers for these
buttons to the corresponding methods below.
Compile and run this program. Alternately press the start button and then the stop button.
When the start button is pressed the 9th time the program will fail.
 
Note my code is different than the ContAcqVoltageSamples_IntClk sample program in the
Measurement Studio documentation in that I do not delete the Task after I
stop it and create a new one before I start it.
( I don't see why you should not be able to restart an existing Task once it has been stopped).
 
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using NationalInstruments.DAQmx;

namespace DataAcqTest
{
  public partial class MainForm : Form
  {
    private Task _AcqTask;
    private AnalogMultiChannelReader _Reader;
    private AsyncCallback _SampleBufferFilled;
    private Boolean _ContinueRunning;
    private readonly Double _SampleRate = 15000.0;
    private readonly Int32 _NumSamplesToReadAtATime = 1500;

    public MainForm()
    {
      InitializeComponent();
    }

    private void MainForm_Load(object sender, EventArgs e)
    {
      _SampleBufferFilled = new AsyncCallback(this.SampleBufferFilled);
      _AcqTask = new Task("DemoAnalogInTask");
      for (int i = 0; i < 4; i++)
      {
        _AcqTask.AIChannels.CreateVoltageChannel("NI-9215-1/ai" + i.ToString(),
                                                 "",
                                                 AITerminalConfiguration.Differential,
                                                 -10.0,
                                                 +10.0,
                                                 AIVoltageUnits.Volts);
      }
      _AcqTask.Timing.ConfigureSampleClock(String.Empty, // signal source is internal clock
                                           _SampleRate,
                                           SampleClockActiveEdge.Rising,
                                           SampleQuantityMode.ContinuousSamples,
                                           _NumSamplesToReadAtATime);
      _AcqTask.Control(TaskAction.Commit);
      _Reader = new AnalogMultiChannelReader(_AcqTask.Stream);
      _Reader.SynchronizeCallbacks = true;
      _StopBtn.Enabled = false;
    }

    private void StartBtn_Click(object sender, EventArgs e)
    {
      _ContinueRunning = true;
      _StartBtn.Enabled = false;
      _StopBtn.Enabled = true;
      _Reader.BeginReadMultiSample(_NumSamplesToReadAtATime,
                                   _SampleBufferFilled,
                                   null);
    }

    private void StopBtn_Click(object sender, EventArgs e)
    {
      _ContinueRunning = false;
      _StopBtn.Enabled = false;
    }

    private void SampleBufferFilled(IAsyncResult ar)
    {
      Double[/*channel*/, /*sample*/] channelsSamples = _Reader.EndReadMultiSample(ar);
      if (_ContinueRunning)
      {
        _Reader.BeginReadMultiSample(_NumSamplesToReadAtATime,
                                     _SampleBufferFilled,
                                     this);
      }
      else
      {
        _AcqTask.Stop(); // Goes to the committed state
        _StartBtn.Enabled = true;
      }
    }
 
  }
}

0 Kudos
Message 2 of 20
(8,122 Views)
Hello All,

Dave has contacted National Instruments for support on this issue. Once we have determined a resolution I will post the results.


Matt Anderson

Hardware Services Marketing Manager
National Instruments
0 Kudos
Message 3 of 20
(8,108 Views)
This was reported to R&D (# 4BOKKEAH) for further investigation. However, this issue has only been reproduced on the USB-9215A. A possible workaround is to use the BeginReadMultiSample() method without committing the task. This increases the setup time for the BeginReadMultiSample() method, but it works without an error. Thanks for the feedback Dave.

Matt Anderson

Hardware Services Marketing Manager
National Instruments
0 Kudos
Message 4 of 20
(8,075 Views)
I too was having AccessViolationException problems with performing synchronous and asynchronous write operations against a FiniteOutputDaqComponent<DigitalMultiChannelWriter, bool[]> object. The write operations were performed against different instances of the object on the same USB-6229 instrument from seperate managed threads. The problem was sparse enough that I just used exception handling without significant detriment to my applicaiton. In fact, this exception was only thrown at application startup. 
Thanks,
Ben
 
0 Kudos
Message 5 of 20
(7,844 Views)
Hi All,

I have the same problem when trying to start a task. Every second time I start a measurement task (e.g. using Signal Express) I get Error -200361 (device memory overflow). It is the same using the "Cont Acq&Graph Voltage-Int Clk" example. It works fine every second time I start the vi and gives an error every other time.

LabView 8.2.1
DAQmx 8.7
USB-6210

Any Idea?
LabView 2010SP1, Windows7
0 Kudos
Message 6 of 20
(7,740 Views)
Hey hejoba.

Can you give more details about your application such as sampling rate, etc? Have you tried sampling at a lower rate?

The problem could also be related to your Windows machine. See the KB below.

Error -200361 with USB-9201,USB-9221, NI 9233, USB-625x or USB-621x
http://digital.ni.com/public.nsf/allkb/ADC80B3995042EB98625704C006B5753?OpenDocument
Regards,

Chris Delvizis
National Instruments
0 Kudos
Message 7 of 20
(7,717 Views)
Dear Chris,

Thank you for your reply. I use Windows XP (always with latest Windows update) on a MacBook Pro under Parallels Desktop (latest version too).
I have tried different sample rates and numbers of samples to read, but the error is still there. The first time I start a task (after connecting the device to the USB port), DAQ works fine. The second task start gives me error -200361. The third start works fine and so on.

I have created a "dummy" task now that starts automatically every time the first task stops, ignoring the error. Then, the next real task start is an "odd" one without error. But that is just a workaround.

Regarding your link to the USB error document, the "usbehci.sys" version in my XP is 5.1.2600.2180! That is higher than the version numbers noted in the document.

I can live with my workaround, but it would be nice to have a clean solution.

Regards,

hejoba
LabView 2010SP1, Windows7
0 Kudos
Message 8 of 20
(7,697 Views)
Hejoba,

This seems like a very strange issue. I have tried testing this with a USB-621X device and am unable to reproduce the results in Signal Express or LabVIEW. I did, however, test this on a true Windows XP machine. Do you have a real Windows machine to test this on so we can rule out that Parallels as the problem?

Also, can you confirm that you have tried testing this in the simplest case. Try testing with only one thing connected to the device and try connecting to different pins. Also, make sure your VI is a simple example or you are using only an aquire step in Signal Express. I am also curious if you get similar results using the Test Panels in the Measurement and Automation Explorer.
Regards,

Chris Delvizis
National Instruments
0 Kudos
Message 9 of 20
(7,666 Views)
Dear Chris,

sorry for my late reply, but it took a while to get a chance to test the USB6210 on a "real" Windows XP PC. You are right, it works fine on the "real" PC, but I still get the -200361 error every second time I start a measurement task on my MacBook Pro with Paralles Desktop running Windows XP.

I get the error if I use the "Cont Acq&Graph Voltage-Int Clk.vi" example or if I use SignalExpress or if I use the MAX test panel or if I build my own vi. The only situation without this error is, if I use single point acquisition. If I use "continuous" or "N samples" mode, the error occurs.

The System is now updated to DAQmx 8.7.1 and MAX 4.4.1 but it is still the same. So, it looks like the USB integration in Parallels might be the problem.

However, thank you for your support and if you find a solution or if you have any suggestions, please let me know.

Best regards, hejoba
LabView 2010SP1, Windows7
0 Kudos
Message 10 of 20
(7,536 Views)