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.

Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Error 50202 with DAQmx and .NET API

We are using .NET API of  DAQmx v9.8 and a NI PCI-6122 Card

 

Our program perform 256 data acquisitions of variable time duration.

  • 2 simultaneous channels, 500 KS/s
  • Time duration (2-3 min) per data acquisition

 

Each measurement is triggered from an external trigger signal to synchronize with other devices and it is stopped when a specific event has been reached.

 

We are creating a single task at the initialization (out of the loop), and this task is started with the trigger signal and stopped by the event.

 

We get an error 50202 after a large number of acquisitions (> 200 in most of times) and in some cases it works fine.

NI Platform Services: A system call returned an error. The operation could not be completed as specified.
Task Name: _unnamedTask<1>;
Status Code: -50202
 

 

The pseudo code is:

 

ConfigureTask(); 

for i=1 to 256

{

   ConfigureCard();
   StartCardMeasurement();

   StopCardMeasurement();

}

DisposeCardTask();

 

 

Some points that we have already tested:

  • We have tested in different computers with different motherboards (Not AMD). It is also tested with simulated AD Card (NI MAX).
  • We have tried to create different task each measurement and there is an error with the task creation (>100 task)
  • We have reviewed all the similar post available in the forum with similar problems:

http://forums.ni.com/t5/Multifunction-DAQ/Error-50202/td-p/797498

http://digital.ni.com/public.nsf/websearch/E80A8BB9D576EB058625724B0080B9B2?OpenDocument

http://digital.ni.com/public.nsf/websearch/043A509F0C3A34BA86256D27007DD444?OpenDocument

http://digital.ni.com/public.nsf/allkb/61060FCCEFD2D5EF86257337005B9ED7?OpenDocument

 

This is the code of the main functions:

 

public bool StartCardMeasurement()
            {
                try 
                {
                    if (this.runningTask != null && this.IsConfigCardDone)
                    {                      

                        //Start card acquisition
                        this.runningTask.Start();

                        return true;
                    }
                    return false;
                }
                catch (Exception ex)
                {
                    this.execInfo.InsertErrorMessage(ex);
                    this.IsConfigCardDone = false;
                    return false;
                }
            }

 

public bool StopCardMeasurement()
            {
                try
                {
                    if ((this.runningTask != null) && (this.IsConfigCardDone))
                    {
                        //Stop card acquisition
                        this.runningTask.Stop();

                        //End task
                        this.runningTask = null;

                        //Confid Card reset
                        this.IsConfigCardDone = false;                       

                        return true;
                    }
                    return false;
                }
                catch (Exception ex)
                {
                    this.execInfo.InsertErrorMessage(ex);
                    this.IsConfigCardDone = false;
                    return false;
                }
            }

 

public bool DisposeCardTask()
            {
                try
                {
                    //End task
                    this.runningTask = null;

                    //Releases all resources used by Task
                    this.mainTask.Dispose();

                    return true;
                }
                catch (Exception ex)
                {
                    this.execInfo.InsertErrorMessage(ex);
                    return false;
                }
            }

 

public bool ConfigureTask()
            {
                try
                {
                    //End other tasks
                    this.mainTask = null;
                    this.runningTask = null;                  

                    //Create a new task
                    this.mainTask = new Task();

                    //Create a virtual channel 0
                    this.mainTask.AIChannels.CreateVoltageChannel("Dev1/ai0", "", (AITerminalConfiguration)(-1),
                        this.MinSignalValue, this.MaxSignalValue, AIVoltageUnits.Volts);

                    //Create a virtual channel 1
                    this.mainTask.AIChannels.CreateVoltageChannel("Dev1/ai1", "", (AITerminalConfiguration)(-1),
                        this.MinSignalValue, this.MaxSignalValue, AIVoltageUnits.Volts);

                    //Configure the timing parameters
                    this.mainTask.Timing.ConfigureSampleClock("", Convert.ToDouble(this.SamplingRate), SampleClockActiveEdge.Rising,SampleQuantityMode.ContinuousSamples, this.SamplesPerChannel * 100);    

                    //Configure the Every N Samples Event
                    this.mainTask.EveryNSamplesReadEventInterval = this.SamplesPerChannel;
                    this.mainTask.EveryNSamplesRead += new EveryNSamplesReadEventHandler(this.mainTask_EveryNSamplesRead);

                    //Start Trigger enable?
                    if (this.IsStartTriggerEnabled)
                    {
                        // Configure Start Trigger
                        this.mainTask.Triggers.StartTrigger.ConfigureDigitalEdgeTrigger("/Dev1/PFI0", DigitalEdgeStartTriggerEdge.Rising);
                    }

                    //Configure TDMS Logging Samples per file
                    this.mainTask.Stream.LoggingSamplesPerFile = MAX_RAW_SAMPLES_PER_FILE;

                    //Change buffer size
                    if (this.ActiveMeasurementType == MeasurementType.HOL)
                    {
                        this.mainTask.Stream.ConfigureInputBuffer(this.SamplesPerChannel * 100);
                    }
                    else if (this.ActiveMeasurementType == MeasurementType.PNTCAL)
                    {
                        this.mainTask.Stream.ConfigureInputBuffer(this.SamplesPerChannel * 100);
                    }
                    else
                    {
                        this.mainTask.Stream.ConfigureInputBuffer(this.SamplesPerChannel * 10);
                    }

                    //Verify the Task
                    this.mainTask.Control(TaskAction.Verify);

                    //Create the reader object
                    this.analogInReader = new AnalogMultiChannelReader(this.mainTask.Stream);

                    return true;
                }
                catch (Exception ex)
                {
                    this.execInfo.InsertErrorMessage(ex);
                    return false;
                }
            }

 

public bool ConfigureCard()
            {
                try
                {
                    //Config Card as not done
                    this.IsConfigCardDone = false;

                    //End other tasks
                    this.runningTask = null;

                    //Config tasks
                    if (this.runningTask != null)
                    {
                        this.execInfo.InsertExecutionInfoMessage("IndraHoloCardDriver.dll", "HIGH", "typeSystemError", "ConfigureCard()", "runningTask != null");
                        return false;
                    }

                    //runningTask as mainTask
                    this.runningTask = this.mainTask;

                    //Use SynchronizeCallbacks to specify that the object marshals callbacks across threads appropriately
                    this.runningTask.SynchronizeCallbacks = true;

                    //Reset processing counter
                    this.ProcessingCounter = 0;

                    //Reset AD Card counter
                    this.adCardCounter = 0;

                    //Reset test process time
                    if (this.IsDebugDataEnabled)
                    {
                        this.testProcessTime = 0;
                    }

                    //Config card is done
                    this.IsConfigCardDone = true;

                    return true;
                }
                catch (Exception ex)
                {
                    this.execInfo.InsertErrorMessage(ex);
                    this.IsConfigCardDone = false;
                    return false;
                }
            }

 

0 Kudos
Message 1 of 1
(3,923 Views)