This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.


Control firing of DataRequired event


When working with the session-based interface to generate output signals continuously, the DataRequired event is fired when you need to queue more data. This occurs when the ScansQueued property drops below the value specified in the NotifyWhenScansQueuedBelow property.


By default the DataRequired event fires when 1/2 second worth of data remains in the queue. To specify a different threshold, change this property value to control when the event is fired.


Control When DataRequired Event Is Fired

Specify a threshold below which the DataRequired event fires.

Create a session and add an analog output channel.

s = daq.createSession('ni')
addAnalogOutputChannel(s,'cDAQ1Mod2', 0, 'Voltage')

Queue some output data.

outputData = (linspace(-1,1,1000))';

Set the threshold of scans queued to 100.

s.NotifyWhenScansQueuedBelow = 100;

Add an anonymous listener and generate the signal in the background:

lh = s.addlistener('DataRequired', ...
@(src,event) src.queueOutputData(outputData));