cancel
Showing results for 
Search instead for 
Did you mean: 

How to read histograms and compute distances from them in VL53L3CX?

FGuti.2
Associate II

Despite many previous questions about how to read histograms from the VL53L3CX, I am still confused how the histogram data is formatted.

I currently read out the histogram as follows:

  1. I call `VL53L3A2_RANGING_SENSOR_GetDistance`
  2. Then right after getting the distance I use the following function to access the histogram data: VL53LX_GetAdditionalData
  3. Then I print out the histogram to the console

As the data is output, I then have a python script parsing the data output on the /dev/ttyACM0 serial port.

Here is an example I get for 2 histograms that are printed out sequentially when imaging a wall 0.5m away (ignore bottom plot).

My questions are:

  • Why does each histogram have 2 bumps even though I am only pointing the sensor at a flat wall?
  • Why do the two consecutive histograms look different?
  • At each frame, is the distance computed using both consecutive histograms or only one of them?
  • How would I parse this histogram data to generate an actual histogram I can compute distances through simple peak finding?

0693W00000WKTm2QAH.png

7 REPLIES 7
John E KVAM
ST Employee

there are 2 different histograms. An even and an odd. One has 4 bits of ambient light an 20 active bins. The other has 24 active bins.

the reason is we are trying to detect Radar Aliasing. By having 2 different pulse repitition rates we can tell if the light from pulse N is coming back after the light from pulse N+1.

Take your data and remove the first 4 bins of one of the histograms. They will line up.

That first 'lump' might be photons from your coverglass. (Assuming you have one.)

if you subtract the crosstalk data from the histogram - it will go away.

  • 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.
FGuti.2
Associate II

Hi John,

Thanks for the reply!

I am not sure if the extra bump is due to crosstalk. Currently I am using the bare VL53L3CX breakout board without a coverglass (which does not even have a lens). Do you have any other thoughts on what it could be? I could also look into subtracting the crosstalk. How can I access the crosstalk data?

I have a few follow-up questions:

  • When estimating distances, would you use both histograms for a single distance (i.e., blue and red in Figure above)? Or would you compute distance for each histogram independently? Would this mean that one histogram can provide a longer depth range?
  • If I remove the first 4 bins of one of the histograms would I be able to simply add the two histograms up to improve SNR?
  • Would you be able to provide a reference to "Radar Aliasing"? I tried googling it and I can't find anything about it.

Thank you very much!

Felipe

John E KVAM
ST Employee

Aliasing is also known as "wrap around".

We shoot out a squart of light. We wait enough time for the light to go out 4Meters and back. This is the wrap point.

Then we shoot out another squirt.

But look what happens if the target is 4.2M away.

The blast goes out, and nothing comes back. So we shoot out another blast.

Then the light comes back.

the sensor concludes the target is 0.2M away instead of 4.2.

So what one does do at least detect this situation is to take another range where the wrap period is 4.2M

If the ranges match, you have a good range.

if they don't match and are a fixed distance apart, you can work out where the real target is up to about 6M.

Otherwise return an error.

I'd average the ranges together. A long term average is going to give you the most accurate range.

if you have two lumps, then one might conclude that you actually have 2 targets.

Use the Evaluation kit and see what it gives you. (log the data, and search the spread sheet for the number of targets.)


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.
FGuti.2
Associate II

Hi John,

Thanks for the reply.

I see. I think I kind of understand your radar aliasing (wrap-around) explanation.

However, just removing the first 4 bins does not seem to be sufficient to combine these two histograms. Here are the histograms I obtain when capturing a wall at 0.5m and 1m, and a flat ceiling at 1.5m away. At 0.5m removing the first 4bins of ambient does make the first lump line up well. However at 1m and 1.5m the histograms do not line up. The first lump in the histogram with the ambient bins (red histogram below) seems to be jumping from the beginning of the range to the end of the range.

Histograms of flat wall at 0.5m away:

0693W00000WKg14QAD.pngHere are the histograms of a flat wall at 1m away:

0693W00000WKg19QAD.pngHere are the histograms of the ceiling at 1.5m away:

0693W00000WKg4SQAT.pngFurthermore, I am still not understanding how I could be getting two lumps if I am just imaging a flat wall. Here is the 1m capture I did for the histogram above. I just point the sensor to a flat wall 1m away:0693W00000WKg0kQAD.jpg

John E KVAM
ST Employee

I had this sort of issues as well.

Instead of trying to look at plots just print out the histogram data - 1 histo per line.

Line them up by hand.

In your first plot, that red line is exactly 4 bins after the blue one.

this makes the average useless.

Once you get the alignment right we can re-evaluate why there are extra 'lumps'.

And try using a real histogram plot.

it made thinks easier for me.

  • 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.
FGuti.2
Associate II

Hi John,

Sorry for the late reply.

What do you mean by lining them up by hand? It seems like I would need to apply a different offset for each distance.

I was also compared the results with the VL53L1A2 X-Nucleo board and that board does give me the expected histograms, and after removing the first 4 ambient bins the histogram line up correctly.

Here are the histograms I get at 0.5., 1. and 1.5m for both boards after removing the first 4 ambient bins:0693W00000WKwKHQA1.png 

0693W00000WKwKRQA1.png0693W00000WKwKbQAL.png

John E KVAM
ST Employee

The short answer is to your L3 issue is, "Switching the L3CX to long distance mode should give the same results as L1."

As explaination, we have to dig deep into the chip. There are only enough bins to go out 4 meters. (20 bins representing 20cm per each) but the L3 advertizes it can go out 6M. And basically we cheat by using the histogram in odd ways.

If you take the L3 code and simply change it to long distance mode, you will get the histogram you expect.

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