Main Content


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));