VL53L1 Ambient light measurement
- August 4, 2021
- 3 replies
- 1501 views
Hi all,
I'm working on a project where I need to analyze the raw histograms from the VL53L1 sensor. For my analysis to work I need to subtract the ambient light from the histograms.
I get the histogram data using VL53L1_GetAdditionalData(), and I can see that every other histogram contains four bins of ambient light measurement. The problem is that all of the histograms with ambient light measurements have consistently larger bin values than all corresponding histograms without ambient light measurements, which causes an overestimation of the ambient light.
I read in other posts about normalizing by the number of active SPADs - but that doesn't help, because the number of SPADs doesn't change on consecutive measurements where the setup is the same (i.e same distance from target, same lighting conditions etc).
Is there a different scaling factor or offset for ranging loops with ambient measurement than loops without?
Anyone has an idea how to fix that?
The image attached shows a comparison of two consecutive histograms - the blue one contains ambient measurement and is shifted four bins to the left for alignment.
Edit:
I found out that there is a VL53L1_TUNINGPARM_HIST_AMB_EVENTS_SCALER_DEFAULT parameter in the file vl53l1_tuning_parm_defaults.h, which is set to 4157, and I found a section in the file vl53l1_hist_algos_gen3.c that uses it:
tmp = (int64_t)pbins->VL53L1_p_004;
tmp *= (int64_t)ambient_threshold_events_scaler;
tmp += 2048;
tmp = do_division_s(tmp, 4096);
amb_events = (int32_t)tmp;but unfortunately, 4157/4096 is about 1.01, which is not a big enough factor to explain the difference that I see in the histograms (which is about a factor of 1.2, at least in some simple tests I did).
