<< Data acquisition Data acquisition mdaqAIScan >>

MicroDAQ toolbox >> MicroDAQ toolbox > Data acquisition > mdaqAIRead

mdaqAIRead

Reads analog inputs

Calling Sequence

data = mdaqAIRead(channels, range, isDifferential)
data = mdaqAIRead(linkID, channels, range, isDifferential)

Description

This function returns immediately acquired values from MicroDAQ input channels as a 1-by-n array of doubles. The value is stored in data, where n is the number of input channels. The channels parameter 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.

For function usage description call function without arguments.

Input arguments

Output arguments

Examples

Read 8 single-ended channels with same channel input rage

data = mdaqAIRead(1:8, [-10,10], %F);
mprintf('Acquired data: %fV\t%fV\t%fV\t%fV\t%fV\t%fV\t%fV\t%fV \n', data)

Read 4 single-ended channels with different channel input rage

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

data = mdaqAIRead(1:4, [-10,10; -5,5; -5,5; -10,10], %F);
mprintf('Acquired data: %fV\t%fV\t%fV\t%fV\n', data)

Read 1 differential channel, 2 single-ended channels with different channel input rage

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

data = mdaqAIRead([1 3 4], [-10,10; -5,5; -10,10], [%T %F %F]);
mprintf('Acquired data: %fV\t%fV\t%fV\n', data)

Performance comparison with and without linkId parameter

// mdaqAIRead usage example with and wihtout linkID parameter
tic();
for i = 1:10
    mdaqAIRead(1, [-10,10], %F);
end
read_time = toc();
mprintf("\nExecution time for ten mdaqAIRead() call without linkId: \t%fs \n", read_time);

// Create connection with MicroDAQ beafore mdaqAIRead() call
linkID = mdaqOpen(); 
tic();
for i = 1:10
    mdaqAIRead(linkID, 1, [-10,10], %F);
end
read_time = toc();
mdaqClose(linkID);
mprintf("Execution time for ten mdaqAIRead() call with linkId: \t%fs\n", read_time);

See Also


Report an issue
<< Data acquisition Data acquisition mdaqAIScan >>