Main Content

startForeground

(Not recommended) Start foreground operations

This session object function is not recommended. Use DataAcquisition object functions instead. See Version History.

Description

startForeground(s); starts operations of the session object, s, and blocks MATLAB® command line and other code until the session operation is complete.

example

data = startForeground(s); returns the data acquired in the output parameter, data.

example

[data,timeStamps,triggerTime] = startForeground(s); returns the data acquired, timestamps relative to the time the operation is triggered, and a trigger time indicating the absolute time the operation was triggered.

example

Examples

collapse all

Acquire data by creating a session with an analog input channel.

s = daq.createSession('ni');
addAnalogInputChannel(s,'cDAQ1Mod1','ai0','Voltage');

Start the acquisition and save the acquired data into the variable data:

	data = startForeground(s);

Generate a signal by creating a session with an analog output channel.

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

Create and queue an output signal and start the generation:

outputSignal = linspace(-1,1,1000)';
queueOutputData(s,outputSignal);
startForeground(s);
s = daq.createSession('ni');
addAnalogInputChannel(s,'cDAQ1Mod1','ai0','Voltage');

Start the acquisition and save the acquired data in the variable data, the acquisition timestamp in timestamps, and the trigger time in triggerTime:

[data,timestamps,triggerTime] = startForeground(s);

Input Arguments

collapse all

Data acquisition session, specified as a session object. Create the session object using daq.createSession. Use the data acquisition session for acquisition and generation operations. Create one session per vendor and use that vendor session to perform all data acquisition operations.

Output Arguments

collapse all

Values of acquired data, returned as an m-by-n array of doubles, where m is the number of scans acquired, and n is the number of input channels in the session.

Recorded timestamp relative to the time the operation is triggered, returned as an m-by-1 array, where m is the number of scans.

Timestamp of acquired data which is a MATLAB serial date timestamp representing the absolute time when timeStamps = 0.

Version History

Introduced in R2010b

collapse all

R2020a: session object interface is not recommended

Use of this function with a session object is not recommended. To access a data acquisition device, use a DataAcquisition object with its functions and properties instead.

For more information about using the recommended functionality, see Transition Your Code from Session to DataAcquisition Interface.