2025-01-08 12:12 AM
I am using the VL53L8CX sensor to measure distances, and I am getting correct values. After some time, the data starts to be sometimes incorrect, while slowly increasing the ratio of incorrect vs correct, until eventually all of the readings are incorrect.
I've noticed that the time it takes for the data to start being incorrect is linearly related to the ranging frequency.
The resolution I am using is 4x4.
When using ranging frequency = 5, it takes 4 minutes for the first incorrect data.
When using ranging frequency = 10, it takes 2 minutes for the first incorrect data.
When using ranging frequency = 20, it takes 1 minute for the first incorrect data.
When using ranging frequency = 60, it takes 20 seconds for the first incorrect data.
Regarding the "correctness" of the data - the sensor is roughly 200 mm from the surface, and the readings I get at the beginning are as follows:
Zone 0: ambient/spad = 2 | nb_spads_enable = 5632 | signal/spad = 1394 | distance_mm = 210 | range_sigma_mm = 1 | nb_detected = 1 | status = 9
Zone 1: ambient/spad = 2 | nb_spads_enable = 2304 | signal/spad = 3380 | distance_mm = 228 | range_sigma_mm = 1 | nb_detected = 1 | status = 9
Zone 2: ambient/spad = 5 | nb_spads_enable = 2048 | signal/spad = 2950 | distance_mm = 228 | range_sigma_mm = 1 | nb_detected = 1 | status = 9
Zone 3: ambient/spad = 12 | nb_spads_enable = 3072 | signal/spad = 2578 | distance_mm = 227 | range_sigma_mm = 1 | nb_detected = 1 | status = 9
Zone 4: ambient/spad = 5 | nb_spads_enable = 8448 | signal/spad = 1032 | distance_mm = 228 | range_sigma_mm = 1 | nb_detected = 1 | status = 5
Zone 5: ambient/spad = 2 | nb_spads_enable = 1536 | signal/spad = 3952 | distance_mm = 233 | range_sigma_mm = 1 | nb_detected = 1 | status = 9
Zone 6: ambient/spad = 4 | nb_spads_enable = 1024 | signal/spad = 13169 | distance_mm = 224 | range_sigma_mm = 1 | nb_detected = 1 | status = 9
Zone 7: ambient/spad = 5 | nb_spads_enable = 3072 | signal/spad = 2735 | distance_mm = 229 | range_sigma_mm = 1 | nb_detected = 1 | status = 9
Zone 8: ambient/spad = 6 | nb_spads_enable = 8192 | signal/spad = 947 | distance_mm = 222 | range_sigma_mm = 1 | nb_detected = 1 | status = 5
Zone 9: ambient/spad = 3 | nb_spads_enable = 1792 | signal/spad = 3936 | distance_mm = 231 | range_sigma_mm = 1 | nb_detected = 1 | status = 9
Zone 10: ambient/spad = 23 | nb_spads_enable = 1024 | signal/spad = 16233 | distance_mm = 226 | range_sigma_mm = 1 | nb_detected = 1 | status = 9
Zone 11: ambient/spad = 13 | nb_spads_enable = 3072 | signal/spad = 2690 | distance_mm = 232 | range_sigma_mm = 1 | nb_detected = 1 | status = 9
Zone 12: ambient/spad = 7 | nb_spads_enable = 11008 | signal/spad = 903 | distance_mm = 196 | range_sigma_mm = 1 | nb_detected = 1 | status = 9
Zone 13: ambient/spad = 11 | nb_spads_enable = 5376 | signal/spad = 1705 | distance_mm = 223 | range_sigma_mm = 1 | nb_detected = 1 | status = 9
Zone 14: ambient/spad = 6 | nb_spads_enable = 1536 | signal/spad = 4642 | distance_mm = 229 | range_sigma_mm = 1 | nb_detected = 1 | status = 9
Zone 15: ambient/spad = 7 | nb_spads_enable = 3584 | signal/spad = 2596 | distance_mm = 234 | range_sigma_mm = 1 | nb_detected = 1 | status = 9
And the incorrect data looks as follows:
Zone 0: ambient/spad = 4422 | nb_spads_enable = 5632 | signal/spad = 2856718 | distance_mm = 849 | range_sigma_mm = 136 | nb_detected = 1 | status = 9
Zone 1: ambient/spad = 4594 | nb_spads_enable = 2304 | signal/spad = 7066646 | distance_mm = 923 | range_sigma_mm = 137 | nb_detected = 1 | status = 5
Zone 2: ambient/spad = 11039 | nb_spads_enable = 2048 | signal/spad = 5849828 | distance_mm = 915 | range_sigma_mm = 140 | nb_detected = 1 | status = 9
Zone 3: ambient/spad = 26038 | nb_spads_enable = 3072 | signal/spad = 5033753 | distance_mm = 932 | range_sigma_mm = 134 | nb_detected = 1 | status = 5
Zone 4: ambient/spad = 12723 | nb_spads_enable = 6912 | signal/spad = 2262562 | distance_mm = 873 | range_sigma_mm = 140 | nb_detected = 1 | status = 9
Zone 5: ambient/spad = 5364 | nb_spads_enable = 1536 | signal/spad = 8380036 | distance_mm = 928 | range_sigma_mm = 142 | nb_detected = 1 | status = 9
Zone 6: ambient/spad = 8794 | nb_spads_enable = 1024 | signal/spad = 26245266 | distance_mm = 893 | range_sigma_mm = 140 | nb_detected = 1 | status = 9
Zone 7: ambient/spad = 12193 | nb_spads_enable = 3072 | signal/spad = 5388355 | distance_mm = 937 | range_sigma_mm = 138 | nb_detected = 1 | status = 5
Zone 8: ambient/spad = 13173 | nb_spads_enable = 8192 | signal/spad = 1946806 | distance_mm = 891 | range_sigma_mm = 138 | nb_detected = 1 | status = 5
Zone 9: ambient/spad = 8286 | nb_spads_enable = 1792 | signal/spad = 8007507 | distance_mm = 934 | range_sigma_mm = 142 | nb_detected = 1 | status = 5
Zone 10: ambient/spad = 45512 | nb_spads_enable = 1024 | signal/spad = 33468210 | distance_mm = 903 | range_sigma_mm = 138 | nb_detected = 1 | status = 9
Zone 11: ambient/spad = 26319 | nb_spads_enable = 3072 | signal/spad = 5362159 | distance_mm = 942 | range_sigma_mm = 137 | nb_detected = 1 | status = 5
Zone 12: ambient/spad = 14759 | nb_spads_enable = 11008 | signal/spad = 1844806 | distance_mm = 781 | range_sigma_mm = 135 | nb_detected = 1 | status = 9
Zone 13: ambient/spad = 24145 | nb_spads_enable = 5376 | signal/spad = 3501811 | distance_mm = 893 | range_sigma_mm = 136 | nb_detected = 1 | status = 9
Zone 14: ambient/spad = 13877 | nb_spads_enable = 1536 | signal/spad = 9363920 | distance_mm = 916 | range_sigma_mm = 137 | nb_detected = 1 | status = 9
Zone 15: ambient/spad = 14995 | nb_spads_enable = 3584 | signal/spad = 5318915 | distance_mm = 934 | range_sigma_mm = 132 | nb_detected = 1 | status = 9
The distance is about 4 times larger in the incorrect data, and from other tests I've done at different distances, the results always seems to be 4 times larger, no matter the distance.
I've suspected the temperature, but I've used an external fan to keep the temperature low, and the result is the same.
Any advice on how to resolve this issue will be highly appreciated.
Solved! Go to Solution.
2025-01-10 05:10 PM
There are some really interesting things in your data. You go from single digit ambient to 4 or 5 digits. I'm going to postulate this is not possible.
Your number of SPADS is bonkers. 4K per chip, not 4K per zone.
Status 9 is a 'merged pulse'. You would only see that if you had a small near target (at 200mm and say another at 300mm) .
But you would get that at the edge - not throughout the data.
My guess - you have corrupted the data packet somehow. Although I have to admit I cannot imagine how.
given the nature of the timing, you have a stack or heap issue perhaps?
2025-01-10 05:10 PM
There are some really interesting things in your data. You go from single digit ambient to 4 or 5 digits. I'm going to postulate this is not possible.
Your number of SPADS is bonkers. 4K per chip, not 4K per zone.
Status 9 is a 'merged pulse'. You would only see that if you had a small near target (at 200mm and say another at 300mm) .
But you would get that at the edge - not throughout the data.
My guess - you have corrupted the data packet somehow. Although I have to admit I cannot imagine how.
given the nature of the timing, you have a stack or heap issue perhaps?
2025-01-12 12:08 AM
Hi John,
Thanks for your reply. You are correct, I've accidently corrupted the data by putting wrong logic in the API file, to protect myself from doing a `memcpy` with a `size` value which is dynamic. My system cannot have any faults as it would be devastating to it.
After fixing the bug everything works as it should. Thanks again.