<< mdaqAIScan Data acquisition mdaqAIScanStop >>

MicroDAQ toolbox >> MicroDAQ toolbox > Data acquisition > mdaqAIScanInit

mdaqAIScanInit

Initiates analog input scanning session

Calling Sequence

mdaqAIScanInit(channels, range, isDifferential, rate, duration)
mdaqAIScanInit(linkID, channels, range, isDifferential, rate, duration)

Description

This function initiates analog input scanning session. The function must be called before acquisition started. The channels argument can be a scalar or vector and it should contain channels numbers according to MicroDAQ hardware configuration. The range argument specifies channel measurement input range. Matrix n-by-2 where n is number of used channels shall be provided. If 1x2 matrix is provided, the range setting will be used for all channels. In order to obtain supported ranges use mdaqHWInfo(). The isDifferential argument specifies measurement mode - differential or single-ended. This argument can be scalar or vector (if applicable for MicroDAQ hardware configuration). If scalar provided, its value will be used for all used channels.

The rate argument determines scans per second rate for selected analog input channels. Minimum value is 1 scan per second, maximum depends on MicroDAQ analog input type.

The duration argument specifies a duration of acquisition in seconds. When set to -1, the session will run continuously, acquiring data until stopped with mdaqAIScanStop() function.

Limitation: ADC1-DAC01 MicroDAQ configuration doesn't support running simultaneously AI and AO scanning sessions.

Input arguments

Examples

Perform blocking data acquisition from 8 single-ended analog input channels, one analog input range, scan frequency of 10kHz and 1 second duration.

mdaqAIScanInit(1:8, [-10,10], %F, 10000, 1)
plot(mdaqAIScan(10000, %T));

Data acquisition from 8 single-ended analog input channels, one analog input range, scan frequency of 10kHz and 1 second duration.

aiData = [];
dataCount = 0;
mdaqAIScanInit(1:8, [-10,10], %F, 10000, 1)
for i=1:10
    [data result] = mdaqAIScan(1000, %T);
    aiData = [aiData; data];
    dataCount = dataCount + result;
    mprintf('Acquired %d scans (total: %d scans)\n', result, dataCount);
end
mdaqAIScanStop();
plot(aiData);

Data acquisition from 2 single-ended and 1 differential analog input channels, different input ranges, scan frequency of 10kHz and 1 second duration.

NOTE: Example will work if applicable for MicroDAQ analog input configuration

aiData = [];
dataCount = 0;
mdaqAIScanInit([1 3 4], [-10,10; -5,5; -5,5], [%T %F %F], 10000, 1)
for i=1:10
    [data result] = mdaqAIScan(1000, %T);
    aiData = [aiData; data];
    dataCount = dataCount + result;
    mprintf('Acquired %d scans (total: %d scans)\n', result, dataCount);
end
mdaqAIScanStop();
plot(aiData);

Continuous data acquisition from 8 single-ended analog input channels, one analog input range, scan frequency of 1kHz. Stop when MicroDAQ F1 button pressed.

NOTE: For long acquisition Scilab stack can be exceeded!

aiData = [];
dataCount = 0;
mdaqAIScanInit(1:8, [-10,10], %F, 1000, -1)
while(mdaqKeyRead(1) == %F)
    [data result] = mdaqAIScan(100, %T);
    aiData = [aiData; data];
    dataCount = dataCount + result;
    mprintf('Acquired %d scans (total: %d scans)\n', result, dataCount);
end
mdaqAIScanStop();
plot(aiData);

See Also


Report an issue
<< mdaqAIScan Data acquisition mdaqAIScanStop >>