How can I perform a multi-trigger acquisition with startBackground (Data Acquisition Toolbox)

2 views (last 30 days)
I got an application where I would like aquire data at multiple triggered times and read it out at the end alltogether (using the Data Acquisition Toolbox and an NI DAQ PCI-6221). However, my problem is that I can only read out the data acquired after each trigger individually. My code looks like this:
s = daq.createSession('ni');
s.Rate = 25e3;
s.DurationInSeconds = 0.001;
chAI1 = addAnalogInputChannel(s,'Dev2','ai1','Voltage');
chAI1.TerminalConfig = 'Differential';
s.addTriggerConnection('External', 'Dev2/PFI12', 'StartTrigger');
s.Connections(1).TriggerCondition = 'FallingEdge';
s.TriggersPerRun = 10;
s.addlistener('DataAvailable', @MyReadoutFnc);
prepare(s);
startBackground(s);
The problem is that the listener is triggered through the DataAvailable event which is defined by s.NotifyWhenDataAvailableExceeds = 25, i.e. the NumberOfScans acquired for a single trigger. When trying to set s.NotifyWhenDataAvailableExceeds higher I get the error: "NotifyWhenDataAvailableExceeds must be less than or equal to the NumberOfScans.". How can I manage to buffer the data on the device and read it out once all data is taken?

Answers (0)

Products


Release

R2016b

Community Treasure Hunt

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

Start Hunting!