Starts scanning operation and reads acquired data
[data, result] = mdaqAIScan(scanCount, isBlocking)
This function starts analog input scanning session and reads acquired data. A function call has to be preceded with mdaqAIScanInit() which initiates scanning session parameters. Blocking or non-blocking operation is defined by isBlocking argument. When blocking(isBlocking=true) mode is used, function will block Matlab command line until required number of scan is acquired. The function has fixed 2-second time-out, a user has to provide scanCout argument which will not cause mdaqAIScan() function time-out. When non-blocking (isBlocking=false) mode is used, function acquired scan data which is currently available in analog input data queue. The number of acquired scans is returned by result output argument. The scanCount argument in non-blocking mode determines maximum number of scans which can be acquired by function call. Values of acquired data, returned as an m-by-n array, where m is the number of acquired scans, and n is the number of used input channels (defined during initialization with mdaqAIScanInit() function call).
Limitation: Some MicroDAQ configurations doesn't support running simultaneously AI and AO scanning sessions - check MicroDAQ datasheet.
scanCount: number of scans to read, when 0 function starts acquisition without reading data
isBlocking: blocking or non-blocking read (true / false)
data: Values of acquired data, specified as an m-by-n matrix, where m is the number of scans, and n is the number of used channels.
result: number of acquired scans
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], false, 10000, 1) plot(mdaqAIScan(10000, true));)
Perform blocking 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], false, 10000, 1); for i=1:10 [data result] = mdaqAIScan(1000, true); aiData = [aiData; data]; dataCount = dataCount + result; sprintf('Acquired %d scans (total: %d scans)\n', result, dataCount) end mdaqAIScanStop(); plot(aiData); clear aiData;
Perform non-blocking 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], false, 10000, 1); while(dataCount < 10000) [data result] = mdaqAIScan(1000, false); aiData = [aiData; data]; dataCount = dataCount + result; if result > 0 sprintf('Acquired %d scans (total: %d scans)\n', result, dataCount) end end mdaqAIScanStop(); plot(aiData); clear aiData;