2025-11-12 3:43 AM
2025-11-19 6:36 PM
Hi
This sound strange, may I know your test setup
Br
Zhiyuan.Han
2025-12-05 7:10 AM
Hello,
Are you sure to be checking Number of targets before browsing Result[] array for each zone?
Results beyond Number of tarjets for each zone shoudl not be considerede. Neither should be considered a distance of a valid tarjet whose status code is not 0x05 (valid measurement).
Example of a scan for valid distances reported in Result:
for( my_Target = 0; my_Target < Result.ZoneResult[number_of_zone].NumberOfTargets; my_Target ++ )
2025-12-08 4:27 PM
AlexCloned is right
With the VL54L5, L7 or L8, one really should check the number of targets and the status before even looking at the distance data. These sensors do NOT clear out stale data but simply overwrite what is in the buffer. So, if you go from 1 target with a valid status, to ZERO targets, the old distance and the old status is still in there.
(As a computer scientist, this drives me crazy, but it's a big buffer and takes time to clear, so the chip designers opted not to do it.)
You get No target when the signal is too low, meaning the distance is too great or the target has a very low reflectivity. It can also happen if the ambient light is too great - generally caused by sunlight.
Look at the user manual and look for the Range Status - there are a dozen ways to fail.
But if you are going from valid to invalid, you are on the edge of something.
It's easy for me to say -just print out the number of targets, and the Range Status and the distances, but I realize not all systems are connected to serial ports.
Change your code to what AlexCloned or use this logic
If (targets >= 1 AND RangeStatus is valid - 5,6,9 and possibly 12) Return distance.
you might consider
If (targets >= 1 AND RangeStatus is INvalid) Return a negative Range Status.
That way you can gather statistics on likely failure modes.
- john
That might clear up some things.