VisionBox .NET Library  1.7.10.0 (2024-04-16)
VIB_NET::DigitalInput Class Reference
+ Inheritance diagram for VIB_NET::DigitalInput:

Detailed Description

This class represents a group of optically coupled input signals.

See class VIB::DigitalInput in the VisionBox Interface Library for a detailed description.

Examples

Public Member Functions

void AbortWaitingForInputEvent ()
 Aborts any thread that waits for an input event and disables further events. More...
 
void ConfigureDebounceTime (UInt32 nsLow, UInt32 nsHigh)
 Sets debouncing time for the digital input signals. More...
 
void ConfigureDebounceTime (UInt32 nsLow, UInt32 nsHigh, UInt32 enableMask)
 Sets debouncing time for the digital input signals. More...
 
void ConfigureInputEvent (UInt32 SensitivityMaskRising, UInt32 SensitivityMaskFalling)
 Configures the sensitivity of the input events. More...
 
 DigitalInput ()
 Default constructor for the device object More...
 
Boolean GetBit (UInt32 BitIndex)
 Reads the state of the spicified digital input signal. More...
 
void Reset ()
 Resets the device to default settings. More...
 
UInt32 WaitForInputEvent (UInt32 msTimeout)
 Waits for an input event More...
 
UInt32 WaitForInputEvent (UInt32 msTimeout, UInt32 % EventSignals)
 Waits for an input event More...
 
- Public Member Functions inherited from VIB_NET::iDevice
void Close ()
 Closes a device More...
 
bool isOpen ()
 Returns the open state of a device object More...
 
void Open ()
 Opens a device More...
 
void Open (unsigned int Index)
 Opens a device More...
 

Properties

UInt32 Input [get]
 Reads the state of the digital input signals. More...
 
UInt32 NumberOfInputs [get]
 Returns the number of digital input signals. More...
 
UInt32 SensitivityMask [set]
 Configures the sensitivity of the input events. More...
 
virtual VIB_NET::eDEVICE_TYPE Type [get]
 Returns the device type for the current instance, see eDEVICE_TYPE More...
 
- Properties inherited from VIB_NET::iDevice
virtual VIB_NET::eDEVICE_TYPE Type [get]
 Returns the device type for the current instance, see eDEVICE_TYPE More...
 

Constructor & Destructor Documentation

◆ DigitalInput()

VIB_NET::DigitalInput::DigitalInput ( )

Default constructor for the device object

The device must be opened with Open() before it can be used.

Member Function Documentation

◆ AbortWaitingForInputEvent()

void VIB_NET::DigitalInput::AbortWaitingForInputEvent ( )

Aborts any thread that waits for an input event and disables further events.

The function will not return before any thread leaves the internal critical area. By using this function, the device can safely be closed after the call.

◆ ConfigureDebounceTime() [1/2]

void VIB_NET::DigitalInput::ConfigureDebounceTime ( UInt32  nsLow,
UInt32  nsHigh 
)

Sets debouncing time for the digital input signals.

Digital input signals are filtered by a debounce function within the FPGA This affects the values returned by Input and GetBit(), the event function WaitForInputEvent(), and any use by other FPGA units like the Multiplexer.

The time values are specified for high and low state separately. A value of 0 deactivates the debouncing function. The FPGA uses a default setting of 200 ns after power-up.

The same debouncing setting is applied to all input signals.

Parameters
nsLowTime in nano-seconds the signal must stay low before it takes effect (falling edge), range 0...10000000 (10 ms)
nsHighTime in nano-seconds the signal must stay high before it takes effect (rising edge), range 0...10000000 (10 ms)
Example:
C#: DigInOut_Example.cs
Visual Basic: DigInOut_Example.vb

◆ ConfigureDebounceTime() [2/2]

void VIB_NET::DigitalInput::ConfigureDebounceTime ( UInt32  nsLow,
UInt32  nsHigh,
UInt32  enableMask 
)

Sets debouncing time for the digital input signals.

Digital input signals are filtered by a debounce function within the FPGA This affects the values returned by Input and GetBit(), the event function WaitForInputEvent(), and any use by other FPGA units like the Multiplexer.

The time values are specified for high and low state separately. A value of 0 deactivates the debouncing function. The FPGA uses a default setting of 200 ns after power-up.

Debouncing can be enabled for specific inputs only by using the enableMask argument.

Parameters
nsLowTime in nano-seconds the signal must stay low before it takes effect (falling edge), range 0...10000000 (10 ms)
nsHighTime in nano-seconds the signal must stay high before it takes effect (rising edge), range 0...10000000 (10 ms)
enableMaskBinary representation of signals with debouncing enabled
Example:
C#: DigInOut_Example.cs
Visual Basic: DigInOut_Example.vb

◆ ConfigureInputEvent()

void VIB_NET::DigitalInput::ConfigureInputEvent ( UInt32  SensitivityMaskRising,
UInt32  SensitivityMaskFalling 
)

Configures the sensitivity of the input events.

This function must be called before WaitForInputEvent().

The parameters specify which input lines will be used to generate events. The signal edge can be specified for each line individually.

Note
The function will clear all pending events on the first call or after a WaitForInputEvent() timeout or abort.
Parameters
SensitivityMaskRisingBinary representation of signals that trigger events on the rising edge
SensitivityMaskFallingBinary representation of signals that trigger events on the falling edge

◆ GetBit()

Boolean VIB_NET::DigitalInput::GetBit ( UInt32  BitIndex)

Reads the state of the spicified digital input signal.

Parameters
BitIndexInput bit, 0 ... (NumberOfInputs - 1)
Returns
Binary representation of the digital input
Example:
C#: DigInOut_Example.cs
Visual Basic: DigInOut_Example.vb

◆ Reset()

void VIB_NET::DigitalInput::Reset ( )

Resets the device to default settings.

See also VIB::DigitalInput::Reset().

◆ WaitForInputEvent() [1/2]

UInt32 VIB_NET::DigitalInput::WaitForInputEvent ( UInt32  msTimeout)

Waits for an input event

The function waits for events on digital input lines which are selected with ConfigureInputEvent(). The function blocks until a new input event occurs, the timeout expires, or AbortWaitingForInputEvent() gets called.

Note
Parameters
msTimeoutTimeout in milli-seconds, 0xffffffff for infinite timeout
The actual timeout may be twice as high if there are already other threads waiting for an event.
Returns
The function returns with an UInt32, containing the current value of the digital inputs and the changed signals:
  • Bits 0...7: binary representation of the digital input signals
  • Bits 8...15: binary representation of changed input signals since last interrupt function call
Example:
C#: DigInOut_Example.cs
Visual Basic: DigInOut_Example.vb

◆ WaitForInputEvent() [2/2]

UInt32 VIB_NET::DigitalInput::WaitForInputEvent ( UInt32  msTimeout,
UInt32 %  EventSignals 
)

Waits for an input event

See overloaded version of WaitForInputEvent() for a detailed description.

Parameters
msTimeoutTimeout in milli-seconds, 0xffffffff for infinite timeout
The actual timeout may be twice as high if there are already other threads waiting for an event.
EventSignalsAfter success, the function returns the input signals which triggered the event (binary representation).
Returns
The new state of the digital input signals (binary representation).
Example:
C#: DigInOut_Example.cs
Visual Basic: DigInOut_Example.vb

Property Documentation

◆ Input

VIB_NET::DigitalInput::Input
get

Reads the state of the digital input signals.

The returned value is the binary representation of the input signals, LSB is input 0

Example:
C#: DigInOut_Example.cs
Visual Basic: DigInOut_Example.vb

◆ NumberOfInputs

VIB_NET::DigitalInput::NumberOfInputs
get

Returns the number of digital input signals.

Returns
Number of inputs

◆ SensitivityMask

VIB_NET::DigitalInput::SensitivityMask
set

Configures the sensitivity of the input events.

The parameter SensitivityMask specifies which inputs will be used to generate events.

For every input can be configured individually, which edge will be generate an event. There a four options available, none, rising, falling and both.

Parameters
SensitivityMaskPer bit/input there are two configuration modes available.
If bit 0 ... 15 are set, the corresponding input will trigger on both edges
If bit 16 ... 31 are set, the lower bits 0 ... 15 configure the edge, 1 <> rising, 0<> falling
Example:
//input 2 generates on both edges events
pInput.SensitivityMask = 0x2;
//input 2 generate only on rising edges
pInput.SensitivityMask = 0x2 + (0x2<<16);
//input 2 generate only on falling edges
pInput.SensitivityMask = 0x2<<16;

C#: DigInOut_Example.cs
Visual Basic: DigInOut_Example.vb

◆ Type

VIB_NET::DigitalInput::Type
get

Returns the device type for the current instance, see eDEVICE_TYPE