Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Migrates legacy session-based MATLAB Data Acquisition code to the modern daq interface, including callbacks, triggers, and output refill.
64% 100%+36 ptsof test cases passed
Passed 25 of 25 test cases with the skill, and 16 of 25 without it.
In legacy MATLAB DAQ sessions, developers set `s.ExternalTriggerTimeout = 15;` to prevent infinite hangs when waiting for an external start pulse. What is the equivalent property on modern `DataAcquisition` objects?
Uses DigitalTriggerTimeout to set the trigger timeout on the DataAcquisition object.
3 of 3 safety checks passed
Self-contained, runnable forms for the five patterns in SKILL.md. Each snippet has been verified against MATLAB R2026a with an NI USB-6211 attached as Dev1. Copy as-is and adapt the device name, channel IDs, rate, and duration.
trg = addtrigger(d, "Digital", "StartTrigger", "External", "Dev1/PFI0");
trg.Condition = "RisingEdge";
d.DigitalTriggerTimeout = 30;
Argument order: (d, type, role, trigSrc, trigDest). Source is 4th, Destination is 5th. "External" means "from outside MATLAB" — when an external signal drives the trigger, "External" is the Source and the device PFI terminal is the Destination.
Verify after:
disp(trg.Source); % "External"
disp(trg.Destination); % "Dev1/PFI0"
If those don't match intent, the call was wrong — fix before start.
d.ScansAvailableFcnCount = round(d.Rate * 0.5); % half a second per fire
d.ScansAvailableFcn = @(src, ~) onBlock(src);
d.ErrorOccurredFcn = @(~, evt) fprintf("DAQ error: %s\n", evt.Error.message);
function onBlock(src)
[data, t] = read(src, src.ScansAvailableFcnCount, "OutputFormat", "Matrix");
plot(t, data);
drawnow limitrate;
end
The evt argument has no Data and no TimeStamps. It is matlabshared.asyncio.buffer.ElementsAvailableInfo and exposes only NumElementsAvailable, Source, EventName. Reaching for evt.Data or evt.TimeStamps throws — and without ErrorOccurredFcn wired, the listener silently swallows the throw and the run "succeeds" while every callback fails.
Strongly recommend wiring ErrorOccurredFcn when any other *Fcn is set. For strict ports of legacy scripts that did not have an ErrorOccurred listener, surface the silent-swallow trade-off to the user instead of silently inserting the handler — let them opt in.
Next to this one in the catalogue, plus more from the same author.