National Instruments Data Acquisition Trigger Events & Listeners

14 views (last 30 days)
I have a National Instruments 6353 Data Acquisition (DAQ) box. I have an external trigger operating at 10 Hz, so 0.1 seconds per pulse.
When a trigger occurs, I wish to measure 0.05 seconds of the pulse and send the data from analogue input channels to the computer for processing. I want this to occur until I give the stop command.
Ideally, I wish there was a listener that listened for triggers, and when a trigger occurs, it collects the data, sends it to the PC and notifies that the data is ready.
I have spent a lot of time going through the documentation but have still not found the solution. I understand that this is trivial to setup in Labview, but I want to achieve this in Matlab 32 bit.
Any help/examples will be much appreciated.

Accepted Answer

Chaitra
Chaitra on 25 Jun 2014
MATLAB documentation lists the following example to acquire data in the background by creating a session and adding a listener to access the acquired data using an anonymous function. For a continuous background generation, add a listener event to queue additional data to be output:
s = daq.createSession('ni');
s.addAnalogOutputChannel('cDAQ1Mod2', 0, 'Voltage');
s.IsContinuous = true;
s.Rate = 10000;
data = linspace(-1, 1, 5000)';
lh = s.addlistener('DataRequired', ...
@(src,event) src.queueOutputData(data));
s.queueOutputData(data)
s.startBackground();
% perform other MATLAB operations during the generation.
The operation is continuous,
s.stop();
delete(lh);
As to how you can add a trigger connection and send data to computer for processing, you can refer to the link provided below: http://www.mathworks.com/help/daq/ref/addtriggerconnection.html#bt_7mfo-1

More Answers (0)

Community Treasure Hunt

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

Start Hunting!