Welcome! Log In Create A New Profile

Advanced

Buffer overflow?

Posted by lucast4 
Buffer overflow?
November 05, 2021 11:07AM
I got this error message in between trials.

Error using mldaq/MinSamplesAvailable (line 531)
NI_AITask::fetch_data:grinning smileyAQmxReadAnalogF64, The application is not able to keep up with the hardware acquisition.
Increasing the buffer size, reading the data more frequently, or specifying a fixed number of samples to read instead of reading all available samples might correct the problem.
Property: DAQmx_Read_RelativeTo
Corresponding Value: DAQmx_Val_CurrReadPos
Property: DAQmx_Read_Offset
Corresponding Value: 0

Task Name: nidaqmxDev1-AITask-12346261

Status Code: -200279

Error in drag_runtime/end_trial (line 862)
while DAQ.MinSamplesAvailable<=ml_MinSamplesExpected

Error in drag_runtime (line 1561)
end_trial;

Error in run_trial (line 129)
        runtime(MLConfig,TrialRecord,TaskObject,TrialData);

Error in monkeylogic/UIcallback (line 870)
                    result = run_trial(MLConfig,datafile);
 
Error while evaluating UIControl Callback.

Seems like a buffer overflow.

I am acquiring at 500hz, with the following input signals:
Button1
Button2
Button3
Button4

And the following outputs:
Reward
TTL1
TTL2

Using the following hardware:
NI USB-6001

Any suggestions would be appreciated.
Thanks!
Re: Buffer overflow?
November 05, 2021 11:09AM
Update: no errors if I sample at 250 Hz. This is an OK temporary fix, as I would like to get to 500 Hz if possible.
Re: Buffer overflow?
November 05, 2021 02:48PM
Please note that changing the sample rate has no effect on how the NI board works. NIMH ML always samples at 1 kHz, no matter what sample rate you choose on the menu. The menu just determines whether all collected samples will be saved or every other samples (or every fourth samples, etc.).
https://monkeylogic.nimh.nih.gov/docs_MainMenu.html#AISampleRate

What is the CPU of your computer? The message means that your computer was stalled or too busy and therefore the NI driver failed to notify NIMH ML to read samples. The size of the buffer is already huge enough to tolerate 60 failures (or failure for 900 ms in time), so this should be fixed by removing unnecessary processes in your computer or getting a faster CPU, I think.
Re: Buffer overflow?
November 05, 2021 03:40PM
Thanks that makes sense.
The CPU is Intel Core i5-1035G1 1Ghz, 4 Cores.
Can you tell from this whether I should just get a better CPU? It seems like there are no alternative solutions?
Re: Buffer overflow?
November 06, 2021 12:59AM
I actually cannot tell whether it is sufficient or not. You said you did not see an error when the sample rate was set to 250 Hz (i.e., even though there was no change in the sampling condition), so maybe it was a temporary problem. If you keep seeing the same error, it means that the system just cannot handle the load and needs a better CPU.

You may try a different version of MATLAB. MATLAB is getting heavier and slower as new versions come out. Earlier versions work much more lightly.
Re: Buffer overflow?
November 25, 2021 05:20PM
I adjusted a couple of parameters to ease the burden of the NI driver. It may help with this issue. Please try the new packages.

The National Institute of Mental Health (NIMH) is part of the National Institutes of Health (NIH), a component of the U.S. Department of Health and Human Services.