VisionBox Interface Library  1.7.11.0 (2024-12-03)
VIB::Multiplexer Class Reference
+ Inheritance diagram for VIB::Multiplexer:

Detailed Description

This class controls the Multiplexer unit which connects signal sources and sinks with each other.

The following image gives a simplified overview of the signal path inside the VisionBox.

Multiplexer
Multiplexer block diagram

Connecting sources and sinks

The multiplexer can be used to connect different FPGA units with each other. The multiplexer provides multiple independent output lines. They can be connected to different source signals, for example a trigger signal coming from the digital input module. The selected output line of the multiplexer can then be used by other FPGA units as input signal, for example by the strobe unit. Each output line can be used by multiple destinations.

Sources

The availability of source signals depends on the hardware (e.g. number of installed digital I/O modules) and support by firmware (e.g. number of I/O Schedulers). Selecting a source from a unit which is not present will set the output line to low.

The following source signals are available (see MUX_SOURCE):

Sinks

The multiplexer output lines can be used by the following units:

+ Example code
The following example creates the following connection between FPGA units by using two multiplexer lines:
                                |----------------------------------------> digitalOut(0)
  DigIn(0) --> multiplexer(0) --+
                                |--> ioScheduler(0) --> multiplexer(1) --> digitalOut(1)
The digital input 0 is directly connected to the digital output 0 by using the Multiplexer line 0.
The I/O Scheduler is using the same Multiplexer signal as trigger source. The output 0 of the I/O Scheduler is connected to the digital output 1 by using the Multiplexer line 1.
VIB::Multiplexer multiplexer;
VIB::IOScheduler ioScheduler;
VIB::DigitalOutput digitalOut;
// Open devices:
// Multiplexer:
multiplexer.Open();
// I/O Scheduler:
ioScheduler.Open(0);
// Digital Output:
digitalOut.Open(0);
// Connect Multiplexer lines:
// Configure multiplexer line 0 and 1 as source for the digital outputs:
// Configure I/O Scheduler:
// Reset I/O Scheduler:
ioScheduler.Reset();
// Select multiplexer line 0 as trigger source
ioScheduler.SetTriggerSource(0, false);
Please note that error checking was removed to keep the code as simple as possible.

Multiplexer Events

The Multiplexer supports generation of events for the first 16 Multiplexer output lines.

After the desired lines are configured with ConfigureEvent(), the function WaitForEvent() can be used to block execution until a signal change occurs.

+ Example code
VIB::Multiplexer multiplexer;
// Open the Multiplexer device:
multiplexer.Open();
// Connect Multiplexer lines to some useful source signals:
multiplexer.ConnectOutput(1, VIB::Multiplexer::MUX_SRC_...);
multiplexer.ConnectOutput(4, VIB::Multiplexer::MUX_SRC_...);
// Configure Multiplexer to generate events on rising edges for line 1 and on falling edges for line 4:
multiplexer.ConfigureEvent(1<<1, 1<<4);
// Check for new events in a loop:
while (1)
{
unsigned int currentState, changedState;
if (!multiplexer.WaitForEvent(1000, currentState, changedState))
{
printf("WaitForEvent(): timeout or abort occurred.\n");
break;
}
printf("Multiplexer event, current signals: 0x%02x, changed signals: 0x%02x\n", currentState, changedState);
}
Please note that error checking was removed to keep the code as simple as possible.

Event FIFO and event timestamps

Enhancement for RTCC version ≥ 1.0.0.52:

  • Events are stored in a FIFO holding up to 256 events. This helps to avoid dropped events if they are arriving too fast.
  • The time interval between events can be read with GetEventTime().

Watchdog Reset

For hardware platforms with watchdog support, the multiplexer output lines can be reset by the watchdog. If the watchdog timer expires, the output lines are reset to the source Multiplexer::MUX_SRC_OFF. The lines can then be reconfigured to different sources again.

Call Service::WatchdogSetup() with Service::SERVICE_WDT_RESET_TYPE_MULTIPLEXER to activate this mode.

Hardware, library and firmware dependencies

Available capabilities depend on the combination of hardware type, software library and FPGA version.

Click the entries below to show the dependencies:

+ Number of Multiplexer lines
The following table lists the number of available output lines:
Hardware Library Version FPGA Version Multiplexer lines
VisionBox AGE-X5 1.6.5.6 1.0.0.42 24
VisionBox AGE-X4 /
Machine Vision Controller
1.6.5.5 1.0.0.41 24
1.6.3.0 1.0.0.28 16
VisionBox AGE-X3 1.6.2.0 1.0.0.25 16
VisionBox AGE-X2 1.6.5.5 1.0.0.40 24
1.5.1.0 1.0.0.21 16
1.3.0.0 1.0.0.17 8
VisionBox DAYTONA 1.6.8.3 1.0.0.46 8
VisionBox LE MANS 1.6.5.0 1.0.0.31 16
VisionCam XM 1.6.4.0 1.0.0.30 16
VisionSensor PV3 + I/O Expansion 1.7.10.0 1.0.0.75 16
Machine Vision Manager 1.6.3.0 1.0.0.27 16
The function Multiplexer::GetNumberOfOutputs() can be used to obtain the number of multiplexer lines at runtime.
The usable Multiplexer lines by CameraLinkIn and TriggerOverEthernet is limited to the first 16.
+ Assignment of SYNC source signals
Hardware FPGA Version Multiplexer::MUX_SOURCE
MUX_SRC_SYNC_<0...3> MUX_SRC_SYNC_1_<0...3> MUX_SRC_SYNC_2_<0...3>
VisionBox AGE-X5 1.0.0.45 RS-422 IN (first connector) RS-422 IN (second connector) -
1.0.0.44 no
1.0.0.42 no
VisionBox AGE-X4 /
Machine Vision Controller
1.0.0.33 RS-422 IN (first connector) RS-422 IN (second connector) RS-422 IN (third connector)
1.0.0.28 -
VisionBox AGE-X3 1.0.0.25 - - -
VisionBox AGE-X2 1.0.0.17 RS-422 IN - -
VisionBox DAYTONA 1.0.0.46 RS-422 IN - -
VisionBox LE MANS 1.0.0.31 RS-422 IN (first connector) RS-422 IN (second connector) -
VisionCam XM 1.0.0.43 RS-422 IN Sensor signals:
MUX_SRC_SYNC_1_0: exposure
MUX_SRC_SYNC_1_1: frame-valid
MUX_SRC_SYNC_1_2: line-valid
MUX_SRC_SYNC_1_3: trigger
-
1.0.0.30 no
VisionSensor PV3 + I/O Expansion 1.0.0.75 RS-422 IN Sensor signals:
MUX_SRC_SYNC_1_0: exposure
-
Machine Vision Manager (MVM) 1.0.0.27 RS-422 IN (first connector) RS-422 IN (second connector) -
+ Multiplexer events
  • Support for multiplexer events requires library version ≥ 1.6.8.0 and RTCC version ≥ 1.0.0.37.
  • Reading the time interval between events with GetEventTime() requires RTCC version ≥ 1.0.0.52 and library version ≥ 1.7.3.0.
  • WaitForEvent() timeout handling:
    • On Windows, the resolution of the timeout value depends on the Windows timer resolution, which defaults to 15.6 ms. A timeout value smaller than this may result in an immediate timeout. The resolution can be changed with the Windows function timeBeginPeriod().
    • For Linux SDK version < 1.7.5.0 and Windows SDK < 1.7.10.0:
      After a timeout, the function ConfigureEvent() must be called again, which results in dropping of all pending events.
    • For Linux SDK version ≥ 1.7.5.0:
      After a timeout, WaitForEvent() can be called again without losing any events between calls. Calling ConfigureEvent() after a timeout is not required.
+ Watchdog reset
Support for Multiplexer reset by the Watchdog requires library version 1.6.5.3 and RTCC version 1.0.0.37 or later.

Public Types

enum  MUX_SOURCE
 Source signal definitions for the Multiplexer More...
 

Public Member Functions

bool AbortWaitingForEvent ()
 Aborts all threads waiting for events. More...
 
bool ConfigureEvent (unsigned int SensitivityMaskRising, unsigned int SensitivityMaskFalling)
 Configures the sensitivity for Multiplexer events. More...
 
bool ConnectOutput (unsigned int OutputIndex, Multiplexer::MUX_SOURCE Source)
 Selects the source signal for the specified output line. More...
 
bool GetEventTime (unsigned int &time_us, bool &eventsDropped)
 Reads the event time for the received event. More...
 
bool GetNumberOfOutputs (unsigned int &NumberOfOutputs)
 Returns number of multiplexer output lines. More...
 
 Multiplexer ()
 Default constructor for the device object More...
 
bool Reset ()
 Resets the device to default settings. More...
 
bool WaitForEvent (unsigned int msTimeout, unsigned int &NewState, unsigned int &ChangedState)
 Waits for a Multiplexer event. More...
 
- Public Member Functions inherited from VIB::iDevice
bool Close ()
 Closes a device More...
 
 iDevice (const iDevice &device)
 The copy constructor makes a copy of the existing device object More...
 
bool isOpen (bool &state)
 Returns the open state of a device object More...
 
bool Open (unsigned int Index=0)
 Opens a device More...
 
iDeviceoperator= (const iDevice &device)
 The assignment operator makes a copy of the existing device object More...
 
virtual ~iDevice ()
 Deletes the device object More...
 

Member Enumeration Documentation

◆ MUX_SOURCE

Source signal definitions for the Multiplexer

Enumerator
MUX_SRC_OFF 

static off

MUX_SRC_ON 

static on

MUX_SRC_DIG_IN0 

DigitalInput unit 0, wire 0.

MUX_SRC_DIG_IN1 

DigitalInput unit 0, wire 1.

MUX_SRC_DIG_IN2 

DigitalInput unit 0, wire 2.

MUX_SRC_DIG_IN3 

DigitalInput unit 0, wire 3.

MUX_SRC_DIG_IN4 

DigitalInput unit 0, wire 4.

MUX_SRC_DIG_IN5 

DigitalInput unit 0, wire 5.

MUX_SRC_DIG_IN6 

DigitalInput unit 0, wire 6.

MUX_SRC_DIG_IN7 

DigitalInput unit 0, wire 7.

MUX_SRC_STROBE_0 

Strobe signal 0.

MUX_SRC_STROBE_1 

Strobe signal 1.

MUX_SRC_STROBE_2 

Strobe signal 2.

MUX_SRC_STROBE_3 

Strobe signal 3.

MUX_SRC_SYNC_0 

SYNC group 0, signal 0.

MUX_SRC_SYNC_1 

SYNC group 0, signal 1.

MUX_SRC_SYNC_2 

SYNC group 0, signal 2.

MUX_SRC_SYNC_3 

SYNC group 0, signal 3.

MUX_SRC_TRIGGEN_OUT0 

TriggerGenerator output 0.

MUX_SRC_TRIGGEN_OUT1 

TriggerGenerator output 1.

MUX_SRC_TRIGGEN_OUT2 

TriggerGenerator output 2.

MUX_SRC_TRIGGEN_OUT3 

TriggerGenerator output 3.

MUX_SRC_IOSCHEDULER_0_OUT0 

IOScheduler unit 0, output 0.

MUX_SRC_IOSCHEDULER_0_OUT1 

IOScheduler unit 0, output 1.

MUX_SRC_IOSCHEDULER_1_OUT0 

IOScheduler unit 1, output 0.

MUX_SRC_IOSCHEDULER_1_OUT1 

IOScheduler unit 1, output 1.

MUX_SRC_IOSCHEDULER_2_OUT0 

IOScheduler unit 2, output 0.

MUX_SRC_IOSCHEDULER_2_OUT1 

IOScheduler unit 2, output 1

MUX_SRC_IOSCHEDULER_3_OUT0 

IOScheduler unit 3, output 0.

MUX_SRC_IOSCHEDULER_3_OUT1 

IOScheduler unit 3, output 1.

MUX_SRC_SYNC_1_0 

SYNC group 1, signal 0.

MUX_SRC_SYNC_1_1 

SYNC group 1, signal 1.

MUX_SRC_SYNC_1_2 

SYNC group 1, signal 2.

MUX_SRC_SYNC_1_3 

SYNC group 1, signal 3.

MUX_SRC_DIG_1_IN0 

DigitalInput unit 1, wire 0.

MUX_SRC_DIG_1_IN1 

DigitalInput unit 1, wire 1.

MUX_SRC_DIG_1_IN2 

DigitalInput unit 1, wire 2.

MUX_SRC_DIG_1_IN3 

DigitalInput unit 1, wire 3.

MUX_SRC_DIG_1_IN4 

DigitalInput unit 1, wire 4.

MUX_SRC_DIG_1_IN5 

DigitalInput unit 1, wire 5.

MUX_SRC_DIG_1_IN6 

DigitalInput unit 1, wire 6.

MUX_SRC_DIG_1_IN7 

DigitalInput unit 1, wire 7.

MUX_SRC_STROBE_4 

Strobe signal 4.

MUX_SRC_STROBE_5 

Strobe signal 5.

MUX_SRC_STROBE_6 

Strobe signal 6.

MUX_SRC_STROBE_7 

Strobe signal 7.

MUX_SRC_STROBE_8 

Strobe signal 8.

MUX_SRC_STROBE_9 

Strobe signal 9.

MUX_SRC_SYNC_2_0 

SYNC group 2, signal 0.

MUX_SRC_SYNC_2_1 

SYNC group 2, signal 1.

MUX_SRC_SYNC_2_2 

SYNC group 2, signal 2.

MUX_SRC_SYNC_2_3 

SYNC group 2, signal 3.

MUX_SRC_IOSCHEDULER_4_OUT0 

IOScheduler unit 4, output 0.

MUX_SRC_IOSCHEDULER_4_OUT1 

IOScheduler unit 4, output 1.

MUX_SRC_IOSCHEDULER_5_OUT0 

IOScheduler unit 5, output 0.

MUX_SRC_IOSCHEDULER_5_OUT1 

IOScheduler unit 5, output 1.

MUX_SRC_IOSCHEDULER_6_OUT0 

IOScheduler unit 6, output 0.

MUX_SRC_IOSCHEDULER_6_OUT1 

IOScheduler unit 6, output 1.

MUX_SRC_IOSCHEDULER_7_OUT0 

IOScheduler unit 7, output 0.

MUX_SRC_IOSCHEDULER_7_OUT1 

IOScheduler unit 7, output 1.

Constructor & Destructor Documentation

◆ Multiplexer()

VIB::Multiplexer::Multiplexer ( )

Default constructor for the device object

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

Member Function Documentation

◆ AbortWaitingForEvent()

bool VIB::Multiplexer::AbortWaitingForEvent ( )

Aborts all threads waiting for events.

The function wakes up all threads waiting in WaitForEvent(), which will then return with an error.

Note
After abort, events must be configured with ConfigureEvent() before WaitForEvent() can be used again.

◆ ConfigureEvent()

bool VIB::Multiplexer::ConfigureEvent ( unsigned int  SensitivityMaskRising,
unsigned int  SensitivityMaskFalling 
)

Configures the sensitivity for Multiplexer events.

This function must be called before WaitForEvent().

The parameters SensitivityMaskRising and SensitivityMaskFalling specify which of the first 16 Multiplexer output 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 timeout or abort of WaitForEvent().
Parameters
SensitivityMaskRisingBinary representation of Multiplexer signals that triggers an event on the rising edge
SensitivityMaskFallingBinary representation of Multiplexer signals that triggers an event on the falling edge
Returns
true for success, use VIBSystem::GetLastErrorString() for an error description

◆ ConnectOutput()

bool VIB::Multiplexer::ConnectOutput ( unsigned int  OutputIndex,
Multiplexer::MUX_SOURCE  Source 
)

Selects the source signal for the specified output line.

Parameters
OutputIndexOutput number, 0 ... (GetNumberOfOutputs() - 1)
SourceSource for the output
Returns
true for success, use VIBSystem::GetLastErrorString() for an error description

◆ GetEventTime()

bool VIB::Multiplexer::GetEventTime ( unsigned int &  time_us,
bool &  eventsDropped 
)

Reads the event time for the received event.

This function can be called after an event was returned by WaitForEvent(). It returns the number of microseconds between the previous and the current event. The function also returns a flag indicating an overflow of the event FIFO.

Restrictions

  • The event FIFO stores a maximum of 256 events together with the time value.
  • ConfigureEvent() starts the time measurement for the first event.
  • The returned time represents a 24-bit value which saturates at ~16.7 seconds.
  • The function cannot be called if another thread is already waiting in WaitForEvent().
Parameters
time_usEvent time in microseconds, 0...0xffffff
eventsDroppedIndicates that events were dropped before this event
Returns
true for success, use VIBSystem::GetLastErrorString() for an error description

◆ GetNumberOfOutputs()

bool VIB::Multiplexer::GetNumberOfOutputs ( unsigned int &  NumberOfOutputs)

Returns number of multiplexer output lines.

See also Hardware, library and firmware dependencies.

Parameters
NumberOfOutputsNumber of outputs
Returns
true for success, use VIBSystem::GetLastErrorString() for an error description

◆ Reset()

bool VIB::Multiplexer::Reset ( )

Resets the device to default settings.

Returns
true for success, use VIBSystem::GetLastErrorString() for an error description

◆ WaitForEvent()

bool VIB::Multiplexer::WaitForEvent ( unsigned int  msTimeout,
unsigned int &  SignalState,
unsigned int &  EventSignals 
)

Waits for a Multiplexer event.

The function waits for events on multiplexer lines which are selected with ConfigureEvent(). The function blocks until a line event occurs, the timeout expires, or AbortWaitingForEvent() gets called.

Note
  • Waiting threads can be interrupted with AbortWaitingForEvent(). ConfigureEvent() must then be called before waiting again.
  • Linux SDK version < 1.7.5.0 / Windows SDK < 1.7.10.0: ConfigureEvent() must be called again after a timeout has occurred, pending events may be lost.
  • Multiple threads can call this function simultaneously, except when using the method GetEventTime(). The first caller returns first with the next event.
Parameters
msTimeoutTimeout in milliseconds, 1 ... INFINITE
The actual timeout may be twice as high if there are already other threads waiting for an event.
SignalStateAfter success, the function returns the current state of the first 16 Multiplexer lines (binary representation).
EventSignalsAfter success, the function returns the Multiplexer lines which triggered the event (binary representation).
Returns
true: success, new event
false: timeout, abort or other errors; use VIBSystem::GetLastErrorString() for an error description
VIB::DigitalOutput::DIG_OUT_SRC_MUX_OUT0
@ DIG_OUT_SRC_MUX_OUT0
Multiplexer Output 0.
Definition: VIB_Interface.h:474
VIB::DigitalOutput::DIG_OUT_SRC_MUX_OUT1
@ DIG_OUT_SRC_MUX_OUT1
Multiplexer Output 1.
Definition: VIB_Interface.h:475
VIB::Multiplexer::MUX_SRC_DIG_IN0
@ MUX_SRC_DIG_IN0
DigitalInput unit 0, wire 0.
Definition: VIB_Interface.h:752
VIB::DigitalOutput::SetSource
bool SetSource(unsigned int BitIndex, OUT_SOURCE Source, bool InvertOutput)
Sets the source for the specified output signal.
Definition: DigitalOutput.cpp:154
VIB::Multiplexer::MUX_SRC_IOSCHEDULER_0_OUT0
@ MUX_SRC_IOSCHEDULER_0_OUT0
IOScheduler unit 0, output 0.
Definition: VIB_Interface.h:772
VIB::Multiplexer::ConfigureEvent
bool ConfigureEvent(unsigned int SensitivityMaskRising, unsigned int SensitivityMaskFalling)
Configures the sensitivity for Multiplexer events.
Definition: Multiplexer.cpp:475
VIB::IOScheduler
This class controls the I/O Scheduler which can store and emit output signals in hard real-time.
Definition: VIB_Interface.h:829
VIB::Multiplexer::ConnectOutput
bool ConnectOutput(unsigned int OutputIndex, Multiplexer::MUX_SOURCE Source)
Selects the source signal for the specified output line.
Definition: Multiplexer.cpp:447
VIB::IOScheduler::SetTriggerSource
bool SetTriggerSource(const unsigned int InputIndex, const bool InvertInput)
Selects the Multiplexer output signal to be used as trigger event.
Definition: IOScheduler.cpp:590
VIB::DigitalOutput
This class controls a group of digital output signals.
Definition: VIB_Interface.h:467
VIB::Multiplexer::WaitForEvent
bool WaitForEvent(unsigned int msTimeout, unsigned int &NewState, unsigned int &ChangedState)
Waits for a Multiplexer event.
Definition: Multiplexer.cpp:507
VIB::Multiplexer
This class controls the Multiplexer unit which connects signal sources and sinks with each other.
Definition: VIB_Interface.h:739
VIB::IOScheduler::Reset
bool Reset()
Resets the I/O Scheduler logic.
Definition: IOScheduler.cpp:544
VIB::iDevice::Open
bool Open(unsigned int Index=0)
Opens a device
Definition: iDevice.cpp:109