ReadAIChannels()

Reads analog input data from a binary file, and stores the values in an array.

Member of the DataLogger class.

Function Prototype

VB .NET

Public Function ReadAIChannels(ByVal startSample As Integer, ByVal count Integer, ByRef aiChannels As Single) As MccDaq.ErrorInfo

C# .NET

public MccDaq.ErrorInfo ReadAIChannels(int startSample, int count, ref float [] aiChannels)

Parameter

startSample

The first sample to read from the binary file.

count

The number of samples to read from the binary file.

aiChannels

Receives the analog input values.

Returns

Notes

Analog array

The user is responsible for allocating the size of the analog data array, and ensuring that it is large enough to hold the data that will be returned. You can calculate the array allocation using the sampleCount value from GetSampleInfo(), and the aiCount value from GetAIInfo():

float* aiChannels = new float[sampleCount * aiCount];

The figure below shows the layout of the analog array, and how the elements should be indexed.

analog array

Where:

n is (numberOfChannels – 1).

CH0 – CHn refer to the channels in the array, not the input channels of the device.

For example, assume that all of the even number input channels are logged. The analog array channels are mapped as shown here:

Array ChannelDevice Input Channel
00
12
24
36

Use the following code fragment to access the elements of the analog array:

for (i=0; i<numberOfSamples; i++)

{

for (j=0; j<numberOfAIChannels; j++)

{

a = analogArray[(i *numberOfAIChannels) + j];

}

}

where

numberOfSamples is set by the sampleCount value from GetSampleInfo()

numberOfAIChannels is set by the aiCount value from GetAIChannelCount()