2025-02-25 10:02 PM
Hi all, I'm using pololu VL53L7CX sensor carrier board interfaced with Nucleo-L552zeq EVK for ranging application. For first level, iam using the Simple ranging application that comes with software package. Sensor api calls till getting the data seems working fine. But when viewing the result, the status is always 0. For first frame its 6, but i understood it will be 6 for the first frame. The expected status should be 5 (or 9), but for me its always 0. For now i have set the resolution as VL53L7CX_RESOLUTION_4X4 with ranging mode as VL53L7CX_RANGING_MODE_CONTINUOUS.
Additionally, am not using INT pin or LPn pin. Is there anything i need to take care in the hardware side?
Or is there anything to be handled in the sensor configuration in the app side?
Below is the some zone result i got from a single frame:
Details:{NumberOfTargets = 1, Distance = {53}, Status = {0}, Ambient = {0}, Signal = {0}}
Details:{NumberOfTargets = 1, Distance = {51}, Status = {0}, Ambient = {0}, Signal = {0}}
Details:{NumberOfTargets = 1, Distance = {50}, Status = {0}, Ambient = {0}, Signal = {0}}
Details:{NumberOfTargets = 1, Distance = {46}, Status = {0}, Ambient = {0}, Signal = {0}}
Details:{NumberOfTargets = 1, Distance = {51}, Status = {0}, Ambient = {0}, Signal = {0}}
Details:{NumberOfTargets = 1, Distance = {45}, Status = {0}, Ambient = {0}, Signal = {0}}
2025-02-26 7:14 AM
You are close. But I noticed a few things.
1) your signal cannot be zero. The sensor needs between 0.5M and 20M photons to work. 0 is wrong.
2) your ambient signal will not be zero either. Even in a dark room there is going to be some.
3) Is your distance right? If so, then you know the sensor is working and you have a coding error somewhere.
4) in the platform.h file did you uncomment some of the defines? If so you might have taken too much out. At a minimum, you need distance, status, and number of targets.
In order to claim a good distance one needs to check:
If the number of targets >0 AND the status is either 5, 6, or 9 THEN good range.
(There is stale data in the buffer so you have to check this.)
- john
2025-02-26 11:22 AM
1,2) The signal and ambient values were zero because I had disabled them in the app (inside the MX_VL53L7CX_SimpleRanging_Process() function). Once I enabled them again, I started getting some values. Below shown are some results:
ZoneResult[0]
Details:{NumberOfTargets = 1, Distance = {57}, Status = {0}, Ambient = {0}, Signal = {4904}}
ZoneResult[1]
Details:{NumberOfTargets = 1, Distance = {58}, Status = {0}, Ambient = {0}, Signal = {5131}}
ZoneResult[2]
Details:{NumberOfTargets = 1, Distance = {61}, Status = {0}, Ambient = {7}, Signal = {5470}}
ZoneResult[3]
Details:{NumberOfTargets = 1, Distance = {54}, Status = {0}, Ambient = {19}, Signal = {5653}}
ZoneResult[4]
Details:{NumberOfTargets = 1, Distance = {56}, Status = {0}, Ambient = {1}, Signal = {5151}}
ZoneResult[5]
Details:{NumberOfTargets = 1, Distance = {54}, Status = {0}, Ambient = {0}, Signal = {5802}}
3) The distance appears to be approx. correct, but I'm getting a target status of 0 instead of the expected 5/6/9.
4)I haven't uncommented any defines in platform.h. I'm reading the status, number of targets detected, distance, ambient, and signal values.
Could you please help on this target status part since am not getting any of the expected value? Is there anything specific in the sensor configuration or on the driver side that I need to pay attention to?
2025-02-26 11:58 AM
Does your code look like this?
if(isReady)
{
vl53l7cx_get_ranging_data(&Dev, &Results);
/* As the sensor is set in 4x4 mode by default, we have a total
* of 16 zones to print. For this example, only the data of first zone are
* print */
printf("Print data no : %3u\n", Dev.streamcount);
for(i = 0; i < 16; i++)
{
printf("Zone : %3d, Status : %3u, Distance : %4d mm\n",
i,
Results.target_status[VL53L7CX_NB_TARGET_PER_ZONE*i],
Results.distance_mm[VL53L7CX_NB_TARGET_PER_ZONE*i]);
}
printf("\n");
loop++;
}
If it does not, then you have a coding issue.
if it does, then we need to check the Results data structure.
So set your debugger to break at the for loop and display the data structure, you should see those 5's.
There is a RangeStatus == 0, but it means 'no update'. One should never see this and if you are seeing the range change, then clearly you are getting an update.
Could it be that you need a bigger stack? That results structure is pretty large, and you could be overflowing it.
- john
2025-02-26 1:48 PM
I just checked. By default, that data struct is 1360 bytes. It's kind of large - and Status is at the end of it.
So the stack overflow is a very likely cause.
If you change the platform.h to remove some returns values, you can shorten it.
Try:
//#define VL53L7CX_DISABLE_AMBIENT_PER_SPAD
#define VL53L7CX_DISABLE_NB_SPADS_ENABLED
// #define VL53L7CX_DISABLE_NB_TARGET_DETECTED
#define VL53L7CX_DISABLE_SIGNAL_PER_SPAD
#define VL53L7CX_DISABLE_RANGE_SIGMA_MM
// #define VL53L7CX_DISABLE_DISTANCE_MM
//#define VL53L7CX_DISABLE_REFLECTANCE_PERCENT
// #define VL53L7CX_DISABLE_TARGET_STATUS
#define VL53L7CX_DISABLE_MOTION_INDICATOR
This will shorten the structure to 648 bytes.
Try that and see if you get your status back.
notice I left in Ambient, NB_Targets, Signal, distance and status. That's near the minimum.
Although one could argue to use Refective Percent instead Signal. (Signal is a 4-byte interger and percent is one byte.)
But you'd have to change the example code for that.
- john