<< mdaqAOScan Data acquisition mdaqAOScanInit >>

MicroDAQ toolbox >> MicroDAQ toolbox > Data acquisition > mdaqAOScanData


Queues data to be output

Calling Sequence

result = mdaqAOScanData(channels, data, opt)
result = mdaqAOScanData(linkID, channels data, opt)


This function is part of analog scan functionality and has to be called in the following sequence:

  1. Initialize scanning session - mdaqAOScanInit()

  2. Start scanning session - mdaqAOScan()

  3. Queue new data - mdaqAOScanData()

  4. Stop scanning session - mdaqAOScanStop()

This function queues data to be output. A function call has to be preceded with mdaqAOScanInit(). Function queues data in the stream and periodic mode and its behavior depends on selected scan mode. In periodic mode, the function can queue data for every channel combination from used channels (defined in mdaqAOScanInit()). If e.g. in scanning session four channels are used: 1, 2, 3, 4 mdaqAOScanData() can be called to queue data for 1 or 4 or 1,2 or 1,4, or 3,4 etc. channel or queue data for all selected channels. In periodic mode channels argument can contain every combination of used channels, while in stream mode channel argument must be the same as used in mdaqAOScanInit(). The data argument in stream mode must have the same size as the data argument in function mdaqAOScanInit(). The mdaqAOScanInit() perform initial data queue operation. The periodic mode uses a single buffer which data is output from. When the end of the buffer is reached, data index is switched to the beginning of the buffer. The mdaqAOScanData() function overwrites the whole buffer with new data. Depending on the scanning mode opt argument has a different meaning. When the periodic mode is used opt argument allows controlling data index after queuing data. When opt=%T data index will be set to the beginning of the buffer. If opt=%F queue operation doesn't affect data index.

When stream mode is used opt argument determines blocking or non-blocking operation of mdaqAOScanData(). The blocking operation (opt=%T) will block Scilab console until data is queued. The stream mode uses two buffers to ensure uninterrupted analog signal generation. Queuing data is only possible when one buffer is empty, if both are queued function will wait(opt=%T) or return negative result(opt=%F). In blocking mode mdaqAOScanData() has 1 second time-out. If non-blocking operation (opt=%F) is used function will return immediately with result containing a number of queued data.

Data has to be queued before data index reaches the end of previously queued data. Otherwise, last value will remain on analog output.

Input arguments


Queue output data (initial data) for a single channel in periodic mode

data0 = linspace(0,2,1000)';
mdaqAOScanInit(1, data0, [0,5], %F, 1000, 10);

Queue output data (initial data) for multiple channel in periodic mode

data0 = linspace(0,1,1000)';
data1 = linspace(0,2,1000)';
mdaqAOScanInit(1:2, [data0 data1], [0,5], %F, 1000, 10);

Generate sine waveform (AO1) with increasing amplitude and acquire data from analog input (AI1) simultaneously. In this example analog output session uses stream mode. Analog output data (sine waveform) is queued in the loop. Using blocking mode for analog output and input sessions ensures function call synchronization.

aiData = [];
channels = 1
rate = 1000;
scanDataSize = 1000;
duration = 5;
expValue = -3;
sineBias = 2.5;
sineBase = sin(linspace(0, 2*%pi, scanDataSize));
expWave = exp(linspace(expValue, expValue + 0.8, scanDataSize));
sineWave = sineBase. * expWave + sineBias;

// initialize analog input/output scanning sessions
mdaqAOScanInit(channels, sineWave', [-10,10], %T, rate, duration);
mdaqAIScanInit(channels, [-10,10], %F, rate, duration);

// start AI scanning without waiting for data
mdaqAIScan(0, %T);
// start signal generation
n = (rate  * duration) / scanDataSize;

for i=1:n-1
    expValue = expValue + 0.8;
    expWave = exp(linspace(expValue, expValue + 0.8, scanDataSize));
    sineWave = sineBase. * expWave + sineBias;
    // queue new data 
    mdaqAOScanData(channels, sineWave', %T);
    // start and acquire data from analog inputs
    aiData = [aiData; mdaqAIScan(scanDataSize, %T)];
// acquire rest of samples
aiData = [aiData; mdaqAIScan(scanDataSize, %T)];


See Also

Report an issue
<< mdaqAOScan Data acquisition mdaqAOScanInit >>