Generate Signals in the Background

This example shows how to generate signals in the background.

Create an NI session object and add an analog output 'Voltage' channel to cDAQ1Mod2:

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

Specify the channel ID on NI devices using a terminal name, like ao1, or a numeric equivalent like 1.

Create the data to output:

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

Queue the output data:

queueOutputData(s,outputData);

Generate the signal:

startBackground(s);

You can execute other MATLAB® commands while the generation is in progress. In this example, issue a pause(), which causes the MATLAB command line to wait for you to press any key.

pause();

Related Topics