Reads from digital inputs immediately.

Namespace:  Quanser.Hardware
Assembly:  Quanser.Hardware.Hil (in Quanser.Hardware.Hil.dll)

Syntax

Visual Basic (Declaration)
Public Sub ReadDigital ( _
	channels As Integer(), _
	bits As SByte() _
)
C#
public void ReadDigital(
	int[] channels,
	sbyte[] bits
)
Visual C++
public:
void ReadDigital(
	array<int>^ channels, 
	array<signed char>^ bits
)
JavaScript
function readDigital(channels, bits);

Parameters

channels
Type: array< System..::.Int32 >[]()[]

An array containing the numbers of the digital input channels to be read. Channel numbers are zero-based. Thus, channel 0 is the first channel, channel 1 the second channel, etc.

Select a board type from the list for board-specific details: .

bits
Type: array< System..::.SByte >[]()[]

An array for receiving the binary values read from the digital inputs. Each element in the bits array corresponds to the same element in the channels array. Hence, there must be as many elements in the bits array as there are channels.

Remarks

The ReadDigital method reads from the specified digital input channels immediately. The method does not return until the data has been read.

Warning

Many cards allow the digital I/O lines to be programmed as inputs or outputs. The digital I/O lines are configured as inputs or outputs using the SetDigitalDirections(array<Int32>[]()[], array<Int32>[]()[]) method. All the channels which will be used as digital inputs or outputs must be configured accordingly using this function. Failure to configure the digital I/O may result in the ReadDigital(array<Int32>[]()[], array<SByte>[]()[]) method failing to read the digital I/O as expected.

Examples

This example illustrates how to read digital inputs immediately. It reads digital channels 0-3. Exceptions are ignored for simplicity.
C# Copy Code
int []   channels = { 0, 1, 2, 3 };
sbyte [] buffer   = new sbyte [channels.Length];

card.ReadDigital(channels, buffer);
Visual Basic Copy Code
Dim channels() As Integer = {0, 1, 2, 3}
Dim buffer(channels.Length - 1) As SByte

card.ReadDigital(channels, buffer)
Visual C++ Copy Code
array<int>^  channels = { 0, 1, 2, 3 };
array<char>^ buffer   = gcnew array<char>(channels->Length);

card->ReadDigital(channels, buffer);

Exceptions

ExceptionCondition
Quanser.Hardware..::.HilException If the read cannot be performed then an exception is thrown. This situtation typically arises if the board does not support digital inputs or the hardware resources required are in use by a task.

See Also