Data Acquisition Toolbox issue with R2019a

Hi, I have an issue using Data Acquisition Toolbox with last Matlab release R2019a.
While my program runs correctly with earlier versions, it seems that DaQ does not report acquisition ended for non-continuous acquisitions (at least using my Data Translation Daq). The Daq stops correctly (LED changes color) but the session.IsRunning state remains on 1, and a timeout throw the error "Daq did not report it ended...".
Do I need to share more details/code or is it a clear bug with the latest release?
While I am writing this message I just remembered that I have also got an issue using VideoReader class with the latest release, but this will require another post.
Thanks for helping.
Valentin

3 Comments

Hi Valentin,
Did you ever figure this out? I've been running into the same issue with 2023b.
Because this is an intermittent issue it's difficult to verify it's been resolved, but Mathworks support has told me the following will be effective workarounds to the issue:
Add a short pause before stop: After the DAQ has finished running, insert a small delay before calling stopso the hardware has time to fully stop and report its state. For example:
start(DAQ, "Duration", dt_Sampling);
pause(dt_Sampling); % wait for the run to finish
stop(DAQ); % then stop
Run the DAQ in continuous mode instead of duration mode : Instead of using a fixed"Duration", start the DAQ in continuous mode and stop it explicitly when you are done. This avoids the timing related issue that causes the error. For example:
start(DAQ); % run continuously
pause(dt_Sampling); % run for your desired time
stop(DAQ); % stop when finished
These two workarounds usually prevent the message by giving the hardware more time to stop and avoiding the fragile duration bound stop transition.
In my case, I was calling stop(daq) from a timer, which would sometimes call stop again before the first stop signal had resolved (hence the intermittence)
An additional update that might be helpful to some others:
The daq wasn't reporting it had finished acquisition after it had output all queued scans, so I was stopping it manually and this was causing the error. I was tracking whether it had finished acquiring using daq.NumScansAcquired
This worked, but sometimes meant I was calling stop(daq) before my PC had finished reading from the data buffer, throwing a new error. Using Pause didn't fix the issue because it paused execution of the code reading from the buffer too.
I'm calling the "check if the DAQ is finished" function repeatedly, so I've put a two-stage check in using tic/toc as below:
function CheckFinished(daq): % called every ~0.25 seconds
persistent TimeoutTic;
if daq.NumScansAcquired == length(queuedData) && isempty(TimeoutTic)
TimeoutTic = tic;
end
if ~isempty(TimeoutTic) && toc(TimeoutTic) > 5
TimeoutTic = [];
stop(daq); % I'm actually calling a custom Stop() function. Codebase linked.
end
end
This seems to have completely resolved the issue.
My full codebase is available here for anyone who wants additional context.

Sign in to comment.

Answers (0)

Categories

Asked:

on 18 Apr 2019

Commented:

on 26 Mar 2026 at 23:39

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!