FG Camera Library  1.5.0.0 (2023-09-08)
VisionCam XM / LM

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

The RTCC can be configured by using the VisionBox Interface Library. The relevant modules are listed below:

Also take a look at the Sensors page for information about available sensors.

Using hardware trigger mode

The VisionCam XM uses the VIB::Multiplexer output line 0 as trigger source for the sensor by default. The Multiplexer line can be changed with the special feature TriggerLine, see example code below. The sensor will trigger on a rising edge of the signal. There are no restrictions on the pulse length.

+ 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. This is often useful for line scan applications (Dragster Line Scan sensor or Lince5M181 sensor in Line scan mode).

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.

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.

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 the LED Strobe unit

The exposure signal is available to the Multiplexer by using VIB::Multiplexer::MUX_SRC_SYNC_1_0 as source signal.

In the following example, we use the exposure signal from the sensor to activate the internal LED ring light.

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 internal LED ring light as strobe output
// 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
...

Please note that error checking was removed to keep the code as simple as possible.

Using embedded image, trigger and timestamp counters

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

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 special 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:605
FG_TRIGGER_MODE_HARDWARE
@ FG_TRIGGER_MODE_HARDWARE
Hardware triggered mode.
Definition: FG_CameraInterface.h:142
VIB::Multiplexer::MUX_SRC_DIG_IN0
MUX_SRC_DIG_IN0
FG_IMAGE::pixel_ptr
UINT8 *const pixel_ptr
Pointer to image memory.
Definition: FG_CameraInterface.h:156
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:282
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:642
FG_IMAGE
This structure stores information associated with image buffers
Definition: FG_CameraInterface.h:151
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:134
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)
FG_free_image
UINT32 DLL_FG_API FG_free_image(FG_IMAGE *img)
Releases an image buffer.
Definition: FG_CameraInterface.cpp:579
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::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:129
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:592
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:893
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:566
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:770
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:477