cancel
Showing results for 
Search instead for 
Did you mean: 

VL53L1 Ambient light measurement

PZagu.1
Associate

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).

3 REPLIES 3
John E KVAM
ST Employee

The other difference between the A range and the B range is that the time between pulses is changed.

But the amount of time dedicated to the range is the same.

So A and B have different numbers of pulses, and thus record different numbers of photons.

The number of clocks between pulses in one case and the other is 4. 10 in one and and 14 in the other 14, say. (This depends on short, medium or long ranging mode.)

This changing of the pulse repetition rate is to detect radar aliasing - which you should Google if you are interested.

So one might guess that one range should have 14/10 the number of photons in the other range.

But the data does not seem to support this ratio.

There is a lot a variabiliy between ranges, so I'd do some long averaging and see what the ratio looks to be.

  • john


If this or any post solves your issue, please mark them as 'Accept as Solution' It really helps. And if you notice anything wrong do not hesitate to 'Report Inappropriate Content'. Someone will review it.
PZagu.1
Associate

Thanks for the reply, I really appreciate it!

That helps clarify some things, but one thing is still not clear to me:

As far as I understand, the first 4 bins in the histogram with ambient measurement should contain only the ambient signal, i.e there were no laser pulses during these bins. If that is so, than why are these bins higher in counts then bins with no target in the second histogram?

If the different time between pulses was the only reason, I would expect bins with no target to be about the same (up to statistical error) as these 4 ambient-only bins.

In addition, I found the function VL53L1_hist_copy_and_scale_ambient_info in the file vl53l1_core.c, which I think I can extract this ratio from. Do you think that would be enough to solve my issue?

Thanks again :)

John E KVAM
ST Employee

I don't have much experience with that function, but it sure looks like someone went to a lot of trouble to make that and it sure sounds like what you need.

You might run a debugger and find out who calls it and when. The decide what they use the data for. It will give you some clues.

Looks like that function also adjusts the data to give signal per SPAD, and that's a plus.

Good luck,

  • john

If this or any post solves your issue, please mark them as 'Accept as Solution' It really helps. And if you notice anything wrong do not hesitate to 'Report Inappropriate Content'. Someone will review it.