2021-09-27 03:46 PM
The first pixel of each of eight rows seems to provide a good range estimate in mm but the rest of the data is either zero or some huge number that doesn't respond to changes in the field of view. I assumed I would get 64 range estimates as output of Results.distance_mm[VL53L5CX_NB_TARGET_PER_ZONE*i] but that is not what I see. What am I doing wrong? Can you post a working example of 64 zone output please?
Solved! Go to Solution.
2021-10-07 09:03 AM
Thanks John,
The example you posted is very similar to what I am already doing and didn't change my results. However, I increased the VL53L5CX_TEMPORARY_BUFFER_SIZE to 4096 in the vl53l5cx_api.h file as in here:
#if VL53L5CX_MAX_RESULTS_SIZE < 1024U
#define VL53L5CX_TEMPORARY_BUFFER_SIZE ((uint32_t) 4096U)
#else
#define VL53L5CX_TEMPORARY_BUFFER_SIZE ((uint32_t) VL53L5CX_MAX_RESULTS_SIZE)
#endif
and it works now. Thank you!
2021-09-28 12:18 AM
Hi
You can find a working project here once the X-CUBE-TOF1 is installed
C:\Users\nguyenph\STM32Cube\Repository\Packs\STMicroelectronics\X-CUBE-TOF1\2.0.0\Projects\NUCLEO-F401RE\Examples\53L5A1\53L5A1_SimpleRanging\
Type "r" to switch the resolution from 4x4 <-> 8x8
Thanks
2021-09-28 05:01 PM
Thanks Julien,
That link is blocked on my browser so I can't access it.
I was hoping for an example that was or could be part of the ST VL53L5CX API, which is what I am using, here turned into an Arduino class but using the ST APIs as intended I think.
In my version of the Arduino sketch I am calling this function:
status = vl53l5cx_set_resolution(&Dev, VL53L5CX_RESOLUTION_8X8);;
and then when I get a data ready interrupt and verify isReady == true I read the 0-63 data via:
Results.target_status[VL53L5CX_NB_TARGET_PER_ZONE*i],
Results.distance_mm[VL53L5CX_NB_TARGET_PER_ZONE*i]);
Any reason this shouldn't work for 8X8 resolution mode as well as it does for 4x4 resolution mode?
In other words, when we trivially set the resolution to VL53L5CX_RESOLUTION_8X8 in the basic ranging example we don't get the results we expect.
Is there something more required, either in setting the sensor into 8X8 mode or perhaps some trick to reading the 64 data samples in a particular way?
Again, this works fine for 4X4 but not when we naively switch to 8X8 resolution. What could the problem be?
Is it possible this is a memory issue? Data array size issue?
Any help would be much appreciated. Thanks!
2021-10-06 12:04 PM
The problem stems from how the data is returned. Basically there is too much of it in the I2C response to get data.
void get_data_by_polling(VL53L5CX_Configuration *p_dev){
do
{
status = vl53l5cx_check_data_ready(&Dev, &p_data_ready);
if(p_data_ready){
status = vl53l5cx_get_resolution(p_dev, &resolution);
status = vl53l5cx_get_ranging_data(p_dev, &Results);
for(int i = 0; i < resolution;i++){
/* Print per zone results */
printf("Zone : %2d, Nb targets : %2u, Ambient : %4lu Kcps/spads, ",
i,
Results.nb_target_detected[i],
Results.ambient_per_spad[i]);
/* Print per target results */
if(Results.nb_target_detected[i] > 0){
printf("Target status : %3u, Distance : %4d mm\n",
Results.target_status[VL53L5CX_NB_TARGET_PER_ZONE * i],
Results.distance_mm[VL53L5CX_NB_TARGET_PER_ZONE * i]);
}else{
printf("Target status : 255, Distance : No target\n");
}
}
printf("\n");
}else{
HAL_Delay(5);
}
}
while(1);
In the above code, I dump the target status and distance based on the Resolution settting.
Perhaps this example will help.
2021-10-07 09:03 AM
Thanks John,
The example you posted is very similar to what I am already doing and didn't change my results. However, I increased the VL53L5CX_TEMPORARY_BUFFER_SIZE to 4096 in the vl53l5cx_api.h file as in here:
#if VL53L5CX_MAX_RESULTS_SIZE < 1024U
#define VL53L5CX_TEMPORARY_BUFFER_SIZE ((uint32_t) 4096U)
#else
#define VL53L5CX_TEMPORARY_BUFFER_SIZE ((uint32_t) VL53L5CX_MAX_RESULTS_SIZE)
#endif
and it works now. Thank you!