Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Continuing Acquisition After Error

I'm currently writing a continuous acquisition program, in C# ,and every now and then I'm running into buffer overrun errors. They are sporadic and it's been difficult trying to work around them because my sample rate and samples per channel must stay at their current values for this project.

 

If a read here and there errors out on the DAQ, it's not a huge deal. We are taking hundreds to thousands of data points, and a few missed doesn't hurt us too bad. So I would like to be able to continue the acquisition uninterrupted and just log the number of reads that fail. This is proving to be difficult, however, as I am unsure of how to go about overriding the task from being stopped, or where I should restart the task at safely. So far all my attempts have not been able to actually restart the task once an error has occurred.

 

Any help would be appreciated.

0 Kudos
Message 1 of 4
(3,927 Views)

First of all, if this is a sporadic failure, an increase of the input buffer might solve the issue. You can use the method "ConfigureInputBuffer" from the stream-object in order to set it to a greater size. Default sizes are configured due to the sample rate and cover in general 100ms-10s.

 

If this does not help, you can try something like this:

myTask.Stream.ReadOverwriteMode = NationalInstruments.DAQmx.ReadOverwriteMode.OverwriteUnreadSamples;

I have not tested it, so i cannot say if it really does what you are up to.....

 

hope this helps,
Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 2 of 4
(3,921 Views)

I currently do increase the size of the buffer, and it has helped lessen the frequency of the errors. I made it 10x the number of samples per channel be acquired. 

 

The problem with setting overwrite mode is that I don't know when I'm losing data. The requirements for my project state that I need to know if any data points are erroneous or not captured. So ideally I would like to let the DAQ encounter an error and just use a counter to keep track of them, while the DAQ continues to sample without interruption.

0 Kudos
Message 3 of 4
(3,917 Views)

Good afternoon SParedes,

 

If you're absolutely sure all you would like to do is catch this exception while keeping the program running, you can implement this counter in the error handling.

 

Let's just say we're using the ContAcqVoltageSamples_IntClk example.  We want to modify the error handling in this program at

 

catch (DaqException exception)

 

Normally, the segment looks like this:

 

                catch (DaqException exception)
                {
                    // Display Errors
                    MessageBox.Show(exception.Message);
                    runningTask = null;
                    myTask.Dispose();
                    stopButton.Enabled = false;
                    startButton.Enabled = true;
                } 

 

We want to modify the code to something like this:

 

                catch (DaqException exception)
                {
                    const int IGNORECODE = 1;
                   

                    if (exception.Error != IGNORECODE)
                    {
                        // Display Errors
                        MessageBox.Show(exception.Message);
                        runningTask = null;
                        myTask.Dispose();
                        stopButton.Enabled = false;
                        startButton.Enabled = true;
                    }
                    else
                        errInstances = errInstances + 1;
                   
                }

 

Where IGNORECODE is the code number of your buffer overflow error, and errInstances will count the number of times this error code occurs.  Be sure you initialize int errInstances = 0; right after private System.ComponentModel.Container components = null;

 

Cheers,

 

Lisa

Applications Engineer
National Instruments
0 Kudos
Message 4 of 4
(3,906 Views)