Initiates analog input scanning session
mdaqAIScanInit(channels, range, isDifferential, rate, duration)
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. 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: Some MicroDAQ configurations doesn't support running simultaneously AI and AO scanning sessions - check MicroDAQ datasheet.
channels: Scalar or vector with channels to be read
range: Range matrix - single row matrix e.g. [-10,10] sets -10 to 10V input range which will be used for all channels. If multi-range used, row number must match selected channels e.g. range matrix for 3 channels [-10,10; -5,5; -2,2]
isDifferential: Scalar or vector with measurement mode settings: true - differential, false - single-ended mode
rate: Analog input scans per second rate
duration: Analog input scan duration [sec], (-1) - continuous operation
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));
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;
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], [true false 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;
Continuous data acquisition from 8 single-ended analog input channels, one analog input range, scan frequency of 1kHz. Stop when MicroDAQ F1 button pressed.
aiData = []; dataCount = 0; mdaqAIScanInit(1:8, [-10,10], false, 1000, -1); while(mdaqKeyRead(1) == false) [data result] = mdaqAIScan(100, true); aiData = [aiData; data]; dataCount = dataCount + result; sprintf('Acquired %d scans (total: %d scans)\n', result, dataCount) end mdaqAIScanStop(); plot(aiData); clear aiData;