FG Camera Library  1.7.0.0 (2025-06-26)
VisionCam XM / XM2

There are two VisionCam XM hardware generations available:

  • VisionCam XM / LM: dual-core ARM Cortex-A15 (armhf architecture).
  • VisionCam XM2 / LM2: hexa-core / octa-core ARM Cortex-A78 (arm64 architecture).

Take a look at the Sensors page for information about supported sensors for each platform.

The VisionCam XM / XM2 provides a user-configurable FPGA, the "Real Time Communication Controller" (RTCC). It contains functional units for controlling trigger signals without CPU intervention.

The RTCC is controlled by the VisionBox Interface Library. The library modules controlling trigger signals are listed below:

Hardware trigger

The function FG_set_trigger_mode() is used to configure one of the trigger modes:

  • Free-run
  • Software triggered
  • Hardware triggered

Example:

// Activate hardware trigger:

The VisionCam uses the VIB::Multiplexer output line 0 as hardware trigger by default. The Multiplexer line can be changed with the special feature TriggerLine. The sensor will trigger on the selected edge of the signal. There are no restrictions on the pulse length.

Property name Description Library
TriggerLine Sets the VIB::Multiplexer line for hardware triggered mode (default: 0):
0...15: Use Multiplexer output line 0...15 with rising edge
100...115: same as 0...15 (compatibile with VisionSensor PV3 + I/O Expansion)
200...215: Use Multiplexer output line 0...15 with falling edge
≥ 1.1.1.0
Note
The VisionCam LM2 with the Gpixel GL7004 line-scan sensor additionally supports a Frame trigger mode.


+ Example 1: Use a digital input to trigger the sensor

In the following example, the digital input 0 is connected to the sensor by using the Multiplexer output 2:

VIB::Multiplexer multiplexer;
unsigned int muxOutput = 2;
// Open the multiplexer device
multiplexer.Open();
// Connect the multiplexer output with the first digital input
// Setup the FG camera interface
// Use hardware triggered mode
// Select the multiplexer output for triggering the sensor
FG_set_special_option("TriggerLine", muxOutput);
...

Please note that no error checking is performed in the examples in order to simplify the code.

+ Example 2: Derive the trigger signal from a rotary encoder

The following example shows how to configure the RTCC for using a rotary encoder to generate an adequate trigger signal. A divider is used to reduce the frequency of the signal.

The example uses DividerA withtin the Trigger Unit (VIB::TriggerGenerator) with the encoder signals A and B. The divider value EncoderDivider (1...) determines the ratio between encoder speed and trigger frequency.

This setup can be used to adapt the frequency for line scan applications, or to trigger a frame after a certain number of encoder steps.

void SetupTrigger(unsigned int EncoderDivider)
{
VIB::TriggerGenerator triggerUnit;
VIB::Multiplexer multiplexer;
char text[200];
// Open Multiplexer and Trigger Unit
multiplexer.Open();
triggerUnit.Open();
// Connect RS-422 encoder signals A and B to MUX output 0 and 1
multiplexer.ConnectOutput(0, VIB::Multiplexer::MUX_SRC_SYNC_0); // encoder signal A
multiplexer.ConnectOutput(1, VIB::Multiplexer::MUX_SRC_SYNC_1); // encoder signal B
// Setup DividerA using both encoder signals to get the highest input frequency:
snprintf(text, sizeof(text), "DividerA=%u,TrigIn0/1_Both", EncoderDivider);
triggerUnit.ConfigureSet(text);
// We use Divider output 'TrigInB' because it has twice the frequency compared to output 'DividerA'
triggerUnit.ConfigureSet("MuxIntern0=TrigInB");
// Connect the trigger signal to output 0 of the Trigger Unit
triggerUnit.ConfigureSet("TrigOut0_Mux=TrigIntern0");
// Connect the trigger signal to MUX output 2
// Configure the sensor to use MUX output 2, the default is 0
FG_set_special_option("TriggerLine", 2);
// Activate hardware trigger for the sensor
}

Please note that no error checking is performed in the examples in order to simplify the code.

+ Example 3: Using an encoder and a frame trigger signal

This example is based on the previous example. An external frame trigger signal is now used to start acquistion for a limited number of trigger events. After a frame trigger happens, only the specified number of trigger events (TriggerCount) will be sent to the sensor. Further events are ignored, until the next frame trigger arrives. Further, the value TriggerDelay can be used to delay the first sensor event after the frame trigger. This value is also based on encoder position, not on time.

Please note that the VisionCam LM2 provides a dedicated frame trigger mode which ensures synchronization between frame trigger and captured images.

void SetupTrigger(unsigned int EncoderDivider, unsigned int TriggerCount, unsigned int TriggerDelay)
{
VIB::TriggerGenerator triggerUnit;
VIB::Multiplexer multiplexer;
char text[200];
// Open Multiplexer and Trigger Unit
multiplexer.Open();
triggerUnit.Open();
multiplexer.ConnectOutput(0, VIB::Multiplexer::MUX_SRC_SYNC_0); // encoder signal A
multiplexer.ConnectOutput(1, VIB::Multiplexer::MUX_SRC_SYNC_1); // encoder signal B
multiplexer.ConnectOutput(2, VIB::Multiplexer::MUX_SRC_DIG_IN0); // frame trigger at digital input 0
// multiplexer.ConnectOutput(2, VIB::Multiplexer::MUX_SRC_SYNC_2); // alternatively: use encoder zero pulse as frame trigger
// Setup DividerA using both encoder signals to get the highest input frequency:
snprintf(text, sizeof(text), "DividerA=%u,TrigIn0/1_Both", EncoderDivider);
triggerUnit.ConfigureSet(text);
triggerUnit.ConfigureSet("DividerA_Reset=TrigIntern3"); // Use divider-reset to reduce jitter
triggerUnit.ConfigureSet("MuxIntern1=DividerA");
// Use CounterB to generate a delay after the frame trigger signal
triggerUnit.ConfigureSet("MuxIntern2=TrigIn2");
triggerUnit.ConfigureSet("CounterB_Start=TrigIntern2"); // Use frame trigger as start signal
// Setup ON / OFF times to create a short output pulse after reaching the delay position:
snprintf(text, sizeof(text), "CounterB=%u,TrigIn0/1_Both CounterB_ON=%u CounterB_OFF=%u",
EncoderDivider * TriggerDelay + 1, EncoderDivider * TriggerDelay, EncoderDivider * TriggerDelay + 1);
triggerUnit.ConfigureSet(text);
triggerUnit.ConfigureSet("CounterB_Reset=Auto"); // Reset counter automatically after reaching the highest value
triggerUnit.ConfigureSet("MuxIntern3=CounterB"); // CounterB output is the start signal for CounterA
// Use CounterA to mask the divider output
triggerUnit.ConfigureSet("CounterA_Start=TrigIntern3"); // Use CounterB output as start signal
// Setup ON / OFF times to create the mask signal:
snprintf(text, sizeof(text), "CounterA=%u,TrigIntern1_Both CounterA_On=1 CounterA_Off=%u", TriggerCount + 1, TriggerCount + 1);
triggerUnit.ConfigureSet(text);
triggerUnit.ConfigureSet("CounterA_Reset=Auto"); // Reset counter automatically after reaching the highest value
// Divider output 'TrigInB' is masked by CounterA
triggerUnit.ConfigureSet("MuxIntern0=TrigInB");
// Connect the trigger signal to output 0 of the Trigger Unit
triggerUnit.ConfigureSet("TrigOut0_Mux=TrigIntern0");
// Connect the trigger signal to MUX output 3
// Configure the sensor to use MUX output 3, the default is 0
FG_set_special_option("TriggerLine", 3);
// Activate hardware trigger for the sensor
}

Please note that no error checking is performed in the examples in order to simplify the code.

Controlling LED lighting

Within the RTCC, the sensor's exposure signal can be used by the VIB::Multiplexer with VIB::Multiplexer::MUX_SRC_SYNC_1_0 as the source signal.

External lighting units

The following example sends the exposure signal to a digital output which then can be connected to an external lighting unit as trigger signal:

VIB::Multiplexer multiplexer;
// Open the Multiplexer device
multiplexer.Open();
// Open the DigitalOutput device
digOut.Open();
// Connect the Multiplexer line 4 with the exposure signal comming from the sensor
// Connect the digital output 0 to the Multiplexer line 4

VisionCam XM Strobe unit

The VIB::Strobe device controls the internal Strobe unit for the VisionCam XM. It can be used for the internal LED ring light if installed, or for an external LED connected to the I/O connector.

Example:

VIB::Multiplexer multiplexer;
VIB::Strobe strobe;
bool strobeInternal = true;
int result;
// Open the Multiplexer device
multiplexer.Open();
// Open the Strobe device
strobe.Open();
// Initialize the strobe unit
strobe.Init();
// Select the strobe output
if (strobeInternal)
strobe.SetOutputType(VIB::Strobe::STROBE_OUTPUT_TYPE_INTERNAL); // internal LED ring light
else
// Set strobe parameters
strobe.SetFixedCurrent(24 /*SupplyVoltage*/, 12 /*LoadVoltage*/, 1000/*MaxOnTime*/, 0/*MinOffTime*/, 1000 /*Current*/, result);
// Connect the Multiplexer output 0 with the exposure signal comming from the sensor
// Use the Multiplexer output 0 as trigger signal for the strobe unit
// Configure the strobe trigger mode to copy the exposure signal
// Setup the FG Camera interface and start acquisition
...

VisionCam XM2 ring light

If the optional LED ring light is enabled, the LED turns on during the integration period of the sensor. The image brightness can be changed by adjusting the integration time and the LED current.

The ring light is controlled by the following special features:

Property name Description
StrobeEnable Enables or disables the LED
0: disable (default)
1: enable
LedCurrent LED current in percent
20...100 (default: 100)
LedDutyCycle Returns the maximum usable duty cycle in percent (read-only)
Note
The maximum allowed duty cycle is calculated by the library to protect against hardware damage. If the frame rate is too high for the given exposure time, the LED ON-time will be reduced. This results in a reduction of the image brightness.

Embedded counters (VisionCam XM / LM)

Three special features are provided in order to embed additional information into the beginning of each frame or each line for line scan cameras:

  • InsertImageCounter: a 16 bit value counting the number of sensor frames or lines for line scan cameras.
  • InsertTriggerCounter: a 16 bit value counting the number of trigger events received.
  • InsertTimeStamp: a 32 bit timestamp value in microseconds
Property name Description Version requirements
Library FPGA
InsertImageCounter Enables or disables insertion of a frame / line counter.
0: disable counter (default)
1: enable counter
≥ 1.2.4.0 ≥ 1.0.0.48
InsertTriggerCounter Enables or disables insertion of a trigger counter.
0: disable counter (default)
1: enable counter
InsertTimeStamp Enables or disables insertion of a time stamp.
0: disable time stamp (default)
1: enable time stamp

The image counter can be used for detection of dropped senor lines which are caused by insufficient acquisition buffers.

The trigger counter is used in hardware triggered mode for detection of ignored trigger events when the trigger signal is arriving too fast. This counter doesn't increment in free run mode.

Note
  • Embedded counters are not avalailable for the VisionCam XM2
  • The counters must be configured before buffers are allocated.
  • Because of the processing pipeline delay for the Dragster line scan sensors, the inserted trigger counter can be inaccurate. Use the Dragster feature InsertLineCounters for getting a synchronized trigger counter, see Embedded line and trigger counters.
+ Example code for reading embedded counters

int main()
{
FG_IMAGE imageList[NUM_BUFFERS];
int checkCounters = 0;
unsigned short frameCounter[2];
unsigned short trgCounter[2];
unsigned int timestamp[2];
// install and configure the camera
SetupCamera();
// configure customized hardware trigger
SetupTrigger();
// activate all counters
FG_set_special_option("InsertImageCounter", 1);
FG_set_special_option("InsertTriggerCounter", 1);
FG_set_special_option("InsertTimeStamp", 1);
// allocate image buffers
for (UINT32 i = 0; i < NUM_BUFFERS; i++)
FG_alloc_image(&imageList[i]);
// start acquisition
for (UINT32 i = 0; i < NUM_BUFFERS; i++)
FG_append_image(&imageList[i]);
// enter acquisition loop
while (isRunning)
{
FG_IMAGE currentImage;
unsigned short counterDiff;
UINT32 res = FG_get_image(&currentImage, UINT_MAX);
{
// read the counter values from the beginning of the image:
frameCounter[0] = ((unsigned short *)currentImage.pixel_ptr)[0];
trgCounter[0] = ((unsigned short *)currentImage.pixel_ptr)[1];
timestamp[0] = ((unsigned int *)currentImage.pixel_ptr)[1];
if (checkCounters)
{
// check the received sensor frames
counterDiff = frameCounter[0] - frameCounter[1];
if (counterDiff != 1)
printf("%d sensor frames dropped\n", counterDiff - 1);
// check the trigger counter
counterDiff = trgCounter[0] - trgCounter[1];
if (counterDiff != 1)
printf("%d trigger events dropped\n", counterDiff - 1);
printf("Frame period: %u us\n", timestamp[0] - timestamp[1]);
}
else
{
// delayed start of counter check
checkCounters = 1;
}
// store values for the next cycle
frameCounter[1] = frameCounter[0];
trgCounter[1] = trgCounter[0];
timestamp[1] = timestamp[0];
FG_append_image(&currentImage);
}
else if (res == FG_ERROR_CODE_BrokenImage)
{
FG_append_image(&currentImage);
}
else // Error during waiting
return -1;
}
// abort image acquisition
// free buffers
for (UINT32 i = 0; i < NUM_BUFFERS; i++)
FG_free_image(&imageList[i]);
// Close the camera
return 0;
}

Please note that no error checking is performed in the examples in order to simplify the code.

FG_get_image
UINT32 DLL_FG_API FG_get_image(FG_IMAGE *img, UINT32 TimeOut_ms)
Returns captured images to the user.
Definition: FG_CameraInterface.cpp:684
FG_install_camera
UINT32 DLL_FG_API FG_install_camera(enum eFG_CAMERA_TYPE camera_type,...)
Opens and initializes the camera.
Definition: FG_CameraInterface.cpp:283
FG_TRIGGER_MODE_HARDWARE
@ FG_TRIGGER_MODE_HARDWARE
Hardware triggered mode.
Definition: FG_CameraInterface.h:155
VIB::Multiplexer::MUX_SRC_DIG_IN0
MUX_SRC_DIG_IN0
VIB::DigitalOutput::SetSource
bool SetSource(unsigned int BitIndex, OUT_SOURCE Source, bool InvertOutput)
FG_IMAGE::pixel_ptr
UINT8 *const pixel_ptr
Pointer to image memory.
Definition: FG_CameraInterface.h:169
VIB::Strobe::STROBE_OUTPUT_TYPE_EXTERNAL
STROBE_OUTPUT_TYPE_EXTERNAL
FG_stop_image
UINT32 DLL_FG_API FG_stop_image(void)
Forces the camera to stop grabbing and using any buffers.
Definition: FG_CameraInterface.cpp:721
FG_IMAGE
This structure stores information associated with image buffers
Definition: FG_CameraInterface.h:164
VIB::Multiplexer::MUX_SRC_SYNC_0
MUX_SRC_SYNC_0
FG_CAMERA_TYPE_X_X_IMAGO_Vxx_AUTO
@ FG_CAMERA_TYPE_X_X_IMAGO_Vxx_AUTO
IMAGO VisionCam/Sensor (automatic)
Definition: FG_CameraInterface.h:54
FG_ERROR_CODE_BrokenImage
@ FG_ERROR_CODE_BrokenImage
Only valid for FG_get_image(): the returned image contents are invalid.
Definition: FG_CameraInterface.h:147
VIB::Multiplexer::ConnectOutput
bool ConnectOutput(unsigned int OutputIndex, Multiplexer::MUX_SOURCE Source)
VIB::Strobe::Init
bool Init(bool ResetParameter=true)
VIB::Strobe::SetOutputType
bool SetOutputType(STROBE_OUTPUT_TYPE OutputType)
VIB::DigitalOutput::DIG_OUT_SRC_MUX_OUT4
DIG_OUT_SRC_MUX_OUT4
FG_free_image
UINT32 DLL_FG_API FG_free_image(FG_IMAGE *img)
Releases an image buffer.
Definition: FG_CameraInterface.cpp:658
VIB::Strobe::STROBE_MODE_HARDWARE_COPY
STROBE_MODE_HARDWARE_COPY
VIB::Strobe::SetFixedCurrent
bool SetFixedCurrent(int SupplyVoltage, int LoadVoltage, unsigned int MaxOnTime, unsigned int MinOffTime, unsigned int Current, int &Result)
VIB::TriggerGenerator::ConfigureSet
bool ConfigureSet(const char Command[])
VIB::Strobe::SetTriggerMode
bool SetTriggerMode(STROBE_MODE TriggerMode, int &Result)
VIB::DigitalOutput
VIB::Strobe::STROBE_SOURCE_MUX_OUT0
STROBE_SOURCE_MUX_OUT0
FG_ERROR_CODE_NoError
@ FG_ERROR_CODE_NoError
The function was successful.
Definition: FG_CameraInterface.h:142
VIB::TriggerGenerator
FG_append_image
UINT32 DLL_FG_API FG_append_image(FG_IMAGE *img)
Puts an image buffer into the aquisition queue.
Definition: FG_CameraInterface.cpp:671
VIB::Multiplexer::MUX_SRC_TRIGGEN_OUT0
MUX_SRC_TRIGGEN_OUT0
FG_set_special_option
UINT32 DLL_FG_API FG_set_special_option(const char *option, INT64 arg)
Configures a special camera property.
Definition: FG_CameraInterface.cpp:972
FG_alloc_image
UINT32 DLL_FG_API FG_alloc_image(FG_IMAGE *img)
Allocates a new image buffer for storing sensor frames.
Definition: FG_CameraInterface.cpp:645
VIB::Multiplexer
FG_set_trigger_mode
UINT32 DLL_FG_API FG_set_trigger_mode(enum eFG_TRIGGER_MODE trigger_mode)
Sets the trigger mode.
Definition: FG_CameraInterface.cpp:849
VIB::Strobe::SetTriggerSource
bool SetTriggerSource(STROBE_SOURCE TriggerSource, int InvertTrigger)
VIB::Multiplexer::MUX_SRC_SYNC_1
MUX_SRC_SYNC_1
VIB::Multiplexer::MUX_SRC_SYNC_1_0
MUX_SRC_SYNC_1_0
VIB::Strobe
VIB::iDevice::Open
bool Open(unsigned int Index=0)
VIB::Strobe::STROBE_OUTPUT_TYPE_INTERNAL
STROBE_OUTPUT_TYPE_INTERNAL
FG_uninstall_camera
UINT32 DLL_FG_API FG_uninstall_camera(void)
Closes the camera.
Definition: FG_CameraInterface.cpp:556