PVCAM  3.9.x
Programmable Virtual Camera Access Method library
Programmable Scan Mode

This code sample is built on top of Single Image Callbacks example. Most commonly shared functions are omitted for clarity.

First we enumerate all items for PARAM_SCAN_MODE and PARAM_EXPOSE_OUT_MODE parameters using the ReadEnumeration helper function. If any of these parameters is not available, the sample ends with an error. The PARAM_SCAN_MODE is required to demonstrate the scan mode feature. The PARAM_EXPOSE_OUT_MODE is needed to configure the camera expose mode to a scan-specific mode. Once configured, a per-line pulse will be generated on the expose-out pin of the camera output signals. See Scan Mode chapter for detailed description of this feature.

To enable the scan mode, we set the PARAM_SCAN_MODE to PL_SCAN_MODE_PROGRAMMABLE_LINE_DELAY. In the "line delay" mode the PARAM_SCAN_LINE_DELAY parameter will become available for read-write and the delay is represented in number of lines. The PARAM_SCAN_WIDTH will become read-only and its value will be auto-calculated and reported by the camera.

if (PV_OK != pl_set_param(ctx->hcam, PARAM_SCAN_MODE, (void*)&newScanMode))
{
PrintErrorMessage(pl_error_code(), "pl_set_param(PARAM_SCAN_MODE) error");
CloseAllCamerasAndUninit(contexts);
return APP_EXIT_ERROR;
}
const uns16 newScanLineDelay = 20;
(void*)&newScanLineDelay))
{
PrintErrorMessage(pl_error_code(), "pl_set_param(PARAM_SCAN_LINE_DELAY) error");
CloseAllCamerasAndUninit(contexts);
return APP_EXIT_ERROR;
}

We can also configure the camera to flip the scan direction after every frame by writing PL_SCAN_DIRECTION_DOWN_UP to PARAM_SCAN_DIRECTION. In alternate "down-up" scan direction mode we can also reset the direction for every acquisition by writing TRUE to PARAM_SCAN_DIRECTION_RESET or keep the direction unaltered by writing FALSE. See the full sample code for details.

The acquisition is setup using the extended exposure mode, a combination of EXT_TRIG_INTERNAL trigger mode and EXPOSE_OUT_LINE_TRIGGER expose-out mode. In scan mode, the camera can also be triggered externally, in such case, an external trigger mode such as EXT_TRIG_EDGE_RISING should be combined with the EXPOSE_OUT_LINE_TRIGGER option.

Once all the settings are applied to the camera, we can read parameters that depend on the setup routine, such as PARAM_SCAN_LINE_TIME or PARAM_SCAN_WIDTH:

long64 newScanLineTimeNs = 0;
(void*)&newScanLineTimeNs))
{
PrintErrorMessage(pl_error_code(), "pl_get_param(PARAM_SCAN_LINE_TIME) error");
CloseAllCamerasAndUninit(contexts);
return APP_EXIT_ERROR;
}
printf("Line time after setup: %lldns\n", newScanLineTimeNs);
uns16 currentScanWidth = 0;
(void*)&currentScanWidth))
{
PrintErrorMessage(pl_error_code(), "pl_get_param(PARAM_SCAN_WIDTH) error");
CloseAllCamerasAndUninit(contexts);
return APP_EXIT_ERROR;
}
printf("Current scan width: %u\n", currentScanWidth);