AFBR-S50 API Reference Manual v1.5.6
AFBR-S50 Time-of-Flight Sensor SDK for Embedded Software
Loading...
Searching...
No Matches
Crosstalk Calibration CLI

A CLI module to interactively run crosstalk calibration. More...

Collaboration diagram for Crosstalk Calibration CLI:

Macros

#define READY()   (rxdataS[0]=='y')
 Macro to proceed to next step, see User_Query.
 
#define ABORT()   (rxdataS[0]=='n')
 Macro to abort crosstalk calibration, see User_Query.
 
#define PROMPT_INPUT()   (rxdataS[0])
 Macro to get user input, see Argus_XtalkCalibration_CLI.
 
#define CLEAR_INPUT()   (rxdataS[0] = 0, rxdataS[1] = 0, flag = 0)
 Macro to clear user input.
 
#define ARGUS_XTALK_CAL_CLI_VERSION   "v1.0"
 Version number of the xtalk calibration CLI.
 
#define ELEC_XTK_AMPL_LMT   (25U)
 The xtalk measurement amplitude limits in LSB for the electrical part.
 
#define OPT_ELEC_XTK_AMPL_LMT   (200U)
 The xtalk measurement amplitude limits in LSB for the optical part.
 
#define T_GLASS   (236U)
 Wavelength dependent transmission of a cover glass.
 

Functions

static void User_Query (void)
 CLI function while performing crosstalk calibration steps.
 
static void Device_Query (argus_hnd_t *hnd)
 Queries device status and invokes timeout.
 
static void Set_DCA_to_MaxState (argus_hnd_t *hnd)
 Sets the integration parameters to maximum.
 
static void Exec_SingleMeasurement (argus_hnd_t *hnd, uint8_t const cnt, bool print_all)
 Measurement sequence calling the Argus_TriggerMeasurement function a certain number of times. Results are going be printed according to the assigned print function (via set_print_fct) at the end.
 
static void Exec_XtalkMeasurement (argus_hnd_t *hnd, argus_cal_xtalk_table_t *xtk, uint8_t step)
 Measurement sequence to acquire crosstalk values.
 
static void Print_BinnedResults (argus_results_t const *res)
 Prints the contend of binned parameters and the status of the frame.
 
static void Print_PixelAmplResults (argus_results_t const *res)
 Prints the amplitudes of all 32 pixels in an 8 x 4 matrix.
 
static void Print_PixelSatResults (argus_results_t const *res)
 Prints the saturation status of all 32 pixels in an 8 x 4 matrix.
 
static void Print_PixelMapCoordinates (void)
 Prints the coordinates of all 32 pixels in an 8 x 4 matrix.
 
static void Print_XtalkMap (argus_cal_xtalk_table_t *extXtalk, uint8_t step)
 Prints the crosstalk values of each pixel in an 8x4 matrix.
 
static void Print_XtalkVectorTable (char *mode, argus_cal_xtalk_table_t *extXtalk)
 Prints the crosstalk values of each pixel in a table.
 
static void Print_FP_XtalkVectorTable (char *mode, argus_cal_xtalk_table_t *extXtalk)
 Prints the crosstalk fixed-point values of each pixel in a table.
 
static void Print_TotalXtalkMap (argus_hnd_t *hnd)
 Calculates and prints the total crosstalk values of each pixel in an 8x4 matrix.
 
static void Print_IntegrationEnergyInfo (argus_results_t const *res)
 Prints the values of integration parameters of a frame.
 
static void Get_GoldenPixel (argus_hnd_t *hnd)
 Gets the golden pixel coordinates stored in the EEPROM.
 
static void Interpolate_ActivePixels (argus_hnd_t *hnd)
 Interpolates crosstalk values in the total crosstalk vector table.
 
static void Set_Xtalk_AmplitudeThreshold (argus_hnd_t *hnd, uint8_t step, uint8_t trim)
 Sets the crosstalk amplitude threshold based on input parameters.
 
static void Handle_Error (status_t status, char const *msg)
 A callback function from the example code whenever an error occurs.
 
static void Get_UARTRxdata (void)
 Generic function to retrieve and assign UART data.
 
static void UART_Rx_Callback (uint8_t const *data, uint32_t const size)
 Received UART data ready callback implementation.
 
void Argus_XtalkCalibration_CLI (argus_hnd_t *hnd)
 Interactive Xtalk Calibration Procedure CLI.
 

Variables

static void(* set_print_fct )(argus_results_t const *)
 
static uint8_t loop_var = 0
 
static volatile uint8_t rxdata = 0
 
static uint8_t rxdataS [1280] = { 0 }
 
static bool flag = 0
 
static bool quit = false
 
static uint16_t max_ampl
 
static uint8_t sat_pixels_cnt
 
static uint32_t frame_time
 
static uint8_t gp_x = 0
 
static uint8_t gp_y = 0
 
static status_t status = STATUS_OK
 
static argus_mode_t myMode
 
static argus_dfm_mode_t myDFM
 
static argus_cfg_dca_t myDCA
 
static argus_cal_xtalk_table_t myXtalk
 
static argus_cal_xtalk_table_t totalXtalk
 
static argus_cal_xtalk_table_t eXtalkArr
 
static argus_cal_xtalk_table_t oeXtalkNoCoverArr
 
static argus_cal_xtalk_table_t oeXtalkCoverArr
 
static bool cancel_xtalk_cal_flag = false
 
static uint32_t const my_meas_time_ms = 1000
 
static uint32_t const device_query_timer_ms = 6000
 
static uint8_t const cnt_trig_meas = 20
 

Detailed Description

A CLI module to interactively run crosstalk calibration.



This interactive procedure guides through the steps needed to compensate the application specific crosstalk (xtalk) using the AFBR-S50 API.

Please read application note AFBR-S50-XTK-Crosstalk-Guide to get more information.

Macro Definition Documentation

◆ ABORT

#define ABORT ( )    (rxdataS[0]=='n')

Macro to abort crosstalk calibration, see User_Query.


Supportive function for the CLI.

◆ ARGUS_XTALK_CAL_CLI_VERSION

#define ARGUS_XTALK_CAL_CLI_VERSION   "v1.0"

Version number of the xtalk calibration CLI.


Changes:

  • v1.0:
    • Initial release.

◆ CLEAR_INPUT

#define CLEAR_INPUT ( )    (rxdataS[0] = 0, rxdataS[1] = 0, flag = 0)

Macro to clear user input.


Supportive function for the CLI.

◆ ELEC_XTK_AMPL_LMT

#define ELEC_XTK_AMPL_LMT   (25U)

The xtalk measurement amplitude limits in LSB for the electrical part.


Note
These values can but should not be increased to meet target sensor performance.

◆ OPT_ELEC_XTK_AMPL_LMT

#define OPT_ELEC_XTK_AMPL_LMT   (200U)

The xtalk measurement amplitude limits in LSB for the optical part.


Note
These values can but should not be increased to meet target sensor performance.

◆ PROMPT_INPUT

#define PROMPT_INPUT ( )    (rxdataS[0])

Macro to get user input, see Argus_XtalkCalibration_CLI.


Supportive function for the CLI.

◆ READY

#define READY ( )    (rxdataS[0]=='y')

Macro to proceed to next step, see User_Query.


Supportive function for the CLI.

◆ T_GLASS

#define T_GLASS   (236U)

Wavelength dependent transmission of a cover glass.


Wavelength dependent transmission or transmittance factor of the specific cover glass.

Example: Gorilla glass has 92% transmittance @ 850nm which is translated as UQ0.8 by 0.92 * 2^8 = 236

Note
* AFBR-S5xxx85x devises use 850nm,
  • AFBR-S5xxx68x use 680nm

Function Documentation

◆ Argus_XtalkCalibration_CLI()

void Argus_XtalkCalibration_CLI ( argus_hnd_t hnd)

Interactive Xtalk Calibration Procedure CLI.


This interactive procedure guides through the steps needed to compensate the application specific crosstalk (xtalk) using the AFBR-S50 API.

Please read application note AFBR-S50-XTK-Crosstalk-Guide to get more information.

Examples
05_simple_example_debug.c.

◆ Device_Query()

static void Device_Query ( argus_hnd_t hnd)
static

Queries device status and invokes timeout.


Checks Argus_GetStatus function and triggers a timeout based on global variable device_query_timer_ms.

Parameters
hndThe API handle; contains all internal states and data.

◆ Exec_SingleMeasurement()

static void Exec_SingleMeasurement ( argus_hnd_t hnd,
uint8_t const  cnt,
bool  print_all 
)
static

Measurement sequence calling the Argus_TriggerMeasurement function a certain number of times. Results are going be printed according to the assigned print function (via set_print_fct) at the end.


Supportive function to the xtalk calibration sequence. In the crosstalk calibration sequence it is used to measure the pixel amplitudes while performing the crosstalk calibration. It will be called x-times to accommodate deviations in the first frames when DFM is used (default). See function Exec_XtalkMeasurement for more details.

Parameters
hndThe API handle; contains all internal states and data.
cntA counter as integer value to determine which frame is printed at the CLI.
print_allBoolean to indicate if all or just last single measurement is printed

◆ Exec_XtalkMeasurement()

static void Exec_XtalkMeasurement ( argus_hnd_t hnd,
argus_cal_xtalk_table_t xtk,
uint8_t  step 
)
static

Measurement sequence to acquire crosstalk values.


The calibration measurement is carried out by the following steps:

  1. The integration parameters are set to maximum (see Set_DCA_to_MaxState). Intention is to display maximum pixel amplitudes to make user aware of insufficient blocking or too high reflections.
  2. Measure and print pixel coordinates (see Print_PixelMapCoordinates) and amplitudes (see Print_PixelAmplResults) to visualize the amplitude distribution over the pixel matrix.
  3. Set crosstalk amplitude threshold (see Set_Xtalk_AmplitudeThreshold). This threshold determines at which amplitude the error -112 is invoked. (see Argus_SetCalibrationCrosstalkSequenceAmplitudeThreshold, status)
  4. Crosstalk measurement by calling the Argus_ExecuteXtalkCalibrationSequence
  5. Save measured crosstalk table by calling Argus_GetCalibrationCrosstalkVectorTable
  6. Printing single xtalk values in a 8x4 matrix (see Print_XtalkMap).
Parameters
hndThe API handle; contains all internal states and data.
xtkA pointer to the argus_cal_xtalk_table_t structure that will be populated with measured crosstalk calibration data.
stepInteger indicating the calling calibration step (1-3)

◆ Get_GoldenPixel()

static void Get_GoldenPixel ( argus_hnd_t hnd)
static

Gets the golden pixel coordinates stored in the EEPROM.


Gets the golden pixel coordinates and stores it to gp_x and gp_y (see Argus_GetCalibrationGoldenPixel)

Parameters
hndThe API handle; contains all internal states and data.

◆ Get_UARTRxdata()

static void Get_UARTRxdata ( void  )
static

Generic function to retrieve and assign UART data.


Supportive function for the CLI.

◆ Handle_Error()

static void Handle_Error ( status_t  status,
char const *  msg 
)
static

A callback function from the example code whenever an error occurs.


The example code calls this function whenever an unexpected error occurs, for example, if an API function returns an error code.

This implementation of the function will print the error message and then enter an infinite loop. The infinite loop is intended to prevent the program from continuing execution in case of errors.

Warning
This is only a simple example implementation that does not handle errors in a production system. It is intended to demonstrate the usage of the API and to provide a starting point for custom applications.

This function needs to be replaced with a more sophisticated implementation to handle errors in a production system. For example, it could reset the device or try to recover from the error by re-initializing the device.

Parameters
statusThe specified status to be checked for errors.
msgThe associated error message to be printed in case of errors.

◆ Interpolate_ActivePixels()

static void Interpolate_ActivePixels ( argus_hnd_t hnd)
static

Interpolates crosstalk values in the total crosstalk vector table.


Supportive function to the xtalk calibration sequence. This function only applies to the higher focused sensor types like AFBR-S50LV85D, AFBR-S50LX85D and AFBR-S50MV68B. Due to the higher collimated laser beam it may appear that the reflex from the optical sink (:=low reflective target) yields higher crosstalk amplitudes in the active pixels which appear as peaks within the total crosstalk distribution. This effect can be mitigated by interpolating the crosstalk values of passive pixels (not receiving the reflex of the cover glass).

Parameters
hndThe API handle; contains all internal states and data.

◆ Print_BinnedResults()

static void Print_BinnedResults ( argus_results_t const *  res)
static

Prints the contend of binned parameters and the status of the frame.


Function can be called from within a measurement function type or/and get assigned to a function pointer.

Parameters
resA pointer to the results structure that will be populated with evaluated data.

◆ Print_FP_XtalkVectorTable()

static void Print_FP_XtalkVectorTable ( char *  mode,
argus_cal_xtalk_table_t extXtalk 
)
static

Prints the crosstalk fixed-point values of each pixel in a table.


Supportive function to the xtalk calibration sequence.

Parameters
extXtalkA pointer to the argus_cal_xtalk_table_t structure that will be populated with measured crosstalk calibration data.
modeA pointer to the char variable containing the current measurement mode.

◆ Print_IntegrationEnergyInfo()

static void Print_IntegrationEnergyInfo ( argus_results_t const *  res)
static

Prints the values of integration parameters of a frame.


Function can be called from within a measurement function type or/and get assigned to a function pointer.

Parameters
resA pointer to the results structure that will be populated with evaluated data.

◆ Print_PixelAmplResults()

static void Print_PixelAmplResults ( argus_results_t const *  res)
static

Prints the amplitudes of all 32 pixels in an 8 x 4 matrix.


Additionally, the maximum amplitude is shown. Supportive function to the xtalk calibration sequence.

Parameters
resA pointer to the results structure that will be populated with evaluated data.

◆ Print_PixelMapCoordinates()

static void Print_PixelMapCoordinates ( void  )
static

Prints the coordinates of all 32 pixels in an 8 x 4 matrix.


Supportive function to the xtalk calibration sequence.

◆ Print_PixelSatResults()

static void Print_PixelSatResults ( argus_results_t const *  res)
static

Prints the saturation status of all 32 pixels in an 8 x 4 matrix.


Additionally, the total number of saturated pixels is shown. It serves as a supportive function to the xtalk calibration sequence.

Parameters
resA pointer to the results structure that will be populated with evaluated data.

◆ Print_TotalXtalkMap()

static void Print_TotalXtalkMap ( argus_hnd_t hnd)
static

Calculates and prints the total crosstalk values of each pixel in an 8x4 matrix.


Supportive function to the xtalk calibration sequence.

Parameters
hndThe API handle; contains all internal states and data.

◆ Print_XtalkMap()

static void Print_XtalkMap ( argus_cal_xtalk_table_t extXtalk,
uint8_t  step 
)
static

Prints the crosstalk values of each pixel in an 8x4 matrix.


Supportive function to the xtalk calibration sequence.

Parameters
extXtalkA pointer to the argus_cal_xtalk_table_t structure that will be populated with measured crosstalk calibration data.
stepInteger indicating the calling calibration step (1-3)

◆ Print_XtalkVectorTable()

static void Print_XtalkVectorTable ( char *  mode,
argus_cal_xtalk_table_t extXtalk 
)
static

Prints the crosstalk values of each pixel in a table.


Supportive function to the xtalk calibration sequence.

Parameters
extXtalkA pointer to the argus_cal_xtalk_table_t structure that will be populated with measured crosstalk calibration data.
modeA pointer to the char variable containing the current measurement mode.

◆ Set_DCA_to_MaxState()

static void Set_DCA_to_MaxState ( argus_hnd_t hnd)
static

Sets the integration parameters to maximum.


Supportive function to the xtalk calibration sequence.

     Note: Maximizing the integration energy is automatically done when
     calling #Argus_ExecuteXtalkCalibrationSequence, however, it does not
     return any pixel which amplitude is above the threshold!
Parameters
hndThe API handle; contains all internal states and data.

◆ Set_Xtalk_AmplitudeThreshold()

static void Set_Xtalk_AmplitudeThreshold ( argus_hnd_t hnd,
uint8_t  step,
uint8_t  trim 
)
static

Sets the crosstalk amplitude threshold based on input parameters.


Supportive function to the xtalk calibration sequence. Dynamically sets the crosstalk amplitude threshold (see Argus_SetCalibrationCrosstalkSequenceAmplitudeThreshold) based on the maximum measured pixel amplitude (see Print_PixelAmplResults).

Parameters
hndThe API handle; contains all internal states and data.
stepInteger indicating the calling calibration step (1-3)
trimScaling factor between measured pixel amplitude and crosstalk values

◆ UART_Rx_Callback()

static void UART_Rx_Callback ( uint8_t const *  data,
uint32_t const  size 
)
static

Received UART data ready callback implementation.


Supportive function for the CLI. Receives data from the UART interrupt. Note that only the first character is evaluated per call.

Parameters
dataByte pointer to the data array.
sizeSize of the data array.

◆ User_Query()

static void User_Query ( void  )
static

CLI function while performing crosstalk calibration steps.


Queries user to proceed to next step by confirming with 'ready' or 'abort'.

Variable Documentation

◆ cancel_xtalk_cal_flag

bool cancel_xtalk_cal_flag = false
static

◆ cnt_trig_meas

uint8_t const cnt_trig_meas = 20
static

◆ device_query_timer_ms

uint32_t const device_query_timer_ms = 6000
static

◆ eXtalkArr

argus_cal_xtalk_table_t eXtalkArr
static

◆ flag

bool flag = 0
static

◆ frame_time

uint32_t frame_time
static

◆ gp_x

uint8_t gp_x = 0
static

◆ gp_y

uint8_t gp_y = 0
static

◆ loop_var

uint8_t loop_var = 0
static

◆ max_ampl

uint16_t max_ampl
static

◆ my_meas_time_ms

uint32_t const my_meas_time_ms = 1000
static

◆ myDCA

argus_cfg_dca_t myDCA
static

◆ myDFM

argus_dfm_mode_t myDFM
static

◆ myMode

argus_mode_t myMode
static

◆ myXtalk

argus_cal_xtalk_table_t myXtalk
static

◆ oeXtalkCoverArr

argus_cal_xtalk_table_t oeXtalkCoverArr
static

◆ oeXtalkNoCoverArr

argus_cal_xtalk_table_t oeXtalkNoCoverArr
static

◆ quit

bool quit = false
static

◆ rxdata

volatile uint8_t rxdata = 0
static

◆ rxdataS

uint8_t rxdataS[1280] = { 0 }
static

◆ sat_pixels_cnt

uint8_t sat_pixels_cnt
static

◆ set_print_fct

void(* set_print_fct) (argus_results_t const *) ( argus_results_t const *  )
static

Function pointer for the result data structure

The argus_results_t data structure is a rich set of function which cannot be displayed all in once. This function pointer is used to call different print functions from within the same measurement function.

◆ status

◆ totalXtalk

argus_cal_xtalk_table_t totalXtalk
static