Jump to content
  • 0

Access violation error with Analog Discovery 3 using DWF 3.20.13


Andras

Question

I started testing the new AD3, and I got access violation errors when I tried to start a data acquisition at 1000k samples per second.

I don't get this error when I do it at 500k SPS with AD3 or at 1000k with AD2.

Running AD3 at 1000k SPS:

image.thumb.png.a739c3ee24c598254b1be1ae4ae20d20.png

In my data acquisition loop I call the FDwfAnalogInStatusRecord and FDwfAnalogInStatusData methods.
The access violation happens at the FDwfAnalogInStatusData call.

Interestingly if I change the sampling rate to 500k SPS then the acquisition works fine. 
AD2 can handle 500k SPS without any problem, and although at 1000k SPS I start losing some data, it never causes access violation.

Running AD2 at 1000k SPS:

image.png.5f8451578e6b5d1632ccf8c872b2102e.png

Both devices are opened with their second configuration, so with 16k scope buffer for AD2 and 32k scope buffer for AD3.

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Szia @Andras

Are you allocating sufficient buffer for the data ?
The buffer size should be at least the number of samples you request to be retuned by FDwfAnalogInStatusData (hdwf, channel, buffer, number of samples)
If you are collecting data in a larger buffer make sure to not pass the end of the allocation. For circular buffers use FDwfAnalogInStatusData2.

The AD2 with 16k samples device buffer can capture or fetch chunks of up to 16384 samples.
The AD3 has shared Scope buffer between channels, so 32768 when two channels are enabled and 65536 when one channel.

Link to comment
Share on other sites

  • 0

Szia @attila

Yes, I think I have the proper array size, but could you take a look?

_ = dwf.FDwfAnalogInBufferSizeInfo(dwfHandle, out int bufferSizeMinimum, out int bufferSizeMaximum);
bufferSize = Math.Min(bufferSizeMaximum, (int)acquisitionSamplerate);
logger.LogTrace($"Device buffer size range: {bufferSizeMinimum:N0} - {bufferSizeMaximum:N0} samples, set to {bufferSize:N0}.");
voltData = new double[bufferSize];

This means that voltData is a 32768-sized double array when I open AD3 with the second configuration.

 

Then later I call FDwfAnalogInStatusRecord to get the number of samples available and I call FDwfAnalogInStatusData to get them.

_ = dwf.FDwfAnalogInStatusRecord(dwfHandle, out int cAvailable, out int cLost, out int cCorrupted);
...
_ = dwf.FDwfAnalogInStatusData(dwfHandle, 0, voltData, cAvailable);

 

But as you mentioned the shared scope buffer, I realized that it might be possible to have a situation when cAvailable > bufferSizeMaximum with AD3?
I'll test this and get back to you! Thank you for the details!

Link to comment
Share on other sites

  • 0

Alright, that was it! I added a few more lines to make sure that we always have a big enough buffer.

if (cAvailable > voltData.Length)
{
	_logger.LogWarning($"The data available on the device is more than our local buffer size ({cAvailable} > {voltData.Length}), so we double the size of the buffer.");
	voltData = new double[voltData.Length * 2];
}

Thank you @attila!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...