Skip to main content
Associate III
February 11, 2025
Solved

VL53L4CX RefSPAD caliberation - no target?

  • February 11, 2025
  • 5 replies
  • 1523 views

Hi,


i'm playing around with the VL53L4CX after putting it on my own pcb (yay).

The user guide states that for the SPAD caliberation, NO target should be placed. The crosstalk requires a 600mm target.

Do i understand correctly that the SPAD caliberation therefor is best performed outside and upwards to the sky? Or maybe in a room that is at least 6 meter long?
It confuses me because i wonder how this is done in a factory where space is a premium :)

 

Kind regards,

        Ruben

 

Best answer by John E KVAM

The requirements for the RefSPAD calculation are "no close target" and by that they mean 5cm or so. 

If you wanted, in your factory to do the offset calculation at say 14cm (it's what we suggest). It would be fine to set up a target at 14cm, do the RefSpad calc, then do the offset calc. 

Once that is done, we have to work on Crosstalk.

You need a target where the normal ranging ends up being 10-20% short. If you use a dark target, that might only be 30cm. Or it could be more depending on the target reflectivity and the quality of your coverglass.

Experiment to find this. Make sure the diameter of the target is at least 1/2 the distance you are ranging. 

Once you have this distance. Create a set-up to do your calibration. Create some sort of flap that can fall down and create the 14cm offset target. 

Fold the flap down, do the RefSpad and the offset cal. Then lift the flap and do the crosstalk cal.

If you have very consistent glass quality and the air gap between sensor and glass is consistent, consider calibration of the first few off the production line, then just use the worst of these calibration values for your entire line.

(The penalty for over calibration of the cross talk is a short measurement, but under calibration can lead to a ghost image - and you don't want that. 

For the best accuracy, go ahead and crosstalk cal them all. But if you don't absolutely need the best accuracy, lots of people crosstalk the design, then just use the numbers.

- john

5 replies

John E KVAM
John E KVAMBest answer
ST Employee
February 11, 2025

The requirements for the RefSPAD calculation are "no close target" and by that they mean 5cm or so. 

If you wanted, in your factory to do the offset calculation at say 14cm (it's what we suggest). It would be fine to set up a target at 14cm, do the RefSpad calc, then do the offset calc. 

Once that is done, we have to work on Crosstalk.

You need a target where the normal ranging ends up being 10-20% short. If you use a dark target, that might only be 30cm. Or it could be more depending on the target reflectivity and the quality of your coverglass.

Experiment to find this. Make sure the diameter of the target is at least 1/2 the distance you are ranging. 

Once you have this distance. Create a set-up to do your calibration. Create some sort of flap that can fall down and create the 14cm offset target. 

Fold the flap down, do the RefSpad and the offset cal. Then lift the flap and do the crosstalk cal.

If you have very consistent glass quality and the air gap between sensor and glass is consistent, consider calibration of the first few off the production line, then just use the worst of these calibration values for your entire line.

(The penalty for over calibration of the cross talk is a short measurement, but under calibration can lead to a ghost image - and you don't want that. 

For the best accuracy, go ahead and crosstalk cal them all. But if you don't absolutely need the best accuracy, lots of people crosstalk the design, then just use the numbers.

- john

cyclopsAuthor
Associate III
February 11, 2025

Thanks john!


i'm assuming that i can not do the refSPAD calibration with the coverglass? For  me it would mean placing the cover glass after the first refSPAD calibration - that's ok. It is another step though.

The manual states that the crosstalk should be done at 600mm in a dark environment. i have noticed that VL53L4CX_PerformOffsetPerVcselCalibration has a parameter, so i'm assuming that I can just put it at 300mm as well. But, the VL53L4CX_PerformXTalkCalibration does not. So is that what you're saying with the 10-20% short? Or should i just stick to the 600mm?

My setup is of course not a factory :) I'm a hobbyst and i'm just thinking to make a box for this where i can shove the device in and perform the calibration in there. I'm happy to do that in steps and in between put the coverglass on.

Additionally. In my setup it would be ideal if i could do these steps separately. Can i run the the refSPAD and PerformOffsetPerVcselCalibration in one method and GetCalibrationData(), to then load that again before doing the PerformXTalkCalibration?

cyclopsAuthor
Associate III
February 14, 2025

So, i did some experimenting.

 

I've run the `VL53L4CX_PerformRefSpadManagement` with a piece of white paper at ~15cm above the sensor.

Then i did the offset calibration. I did that with the `VL53L4CX_PerformOffsetPerVcselCalibration` and a 300mm parameter. Paper of course at 30cm above the sensor.

I store these results on the esp32s littleFS (i just dump the `VL53L4CX_CalibrationData_t` struct to a file).

 

Then i've added the lid of my enclosure (which is the cover glass). I do this without power, which is why i've stored the calibration data.

Then i do a second calibration for the Xtalk. So i read the calibration data from the file and run the `VL53L4CX_SetCalibrationData`, and then the `VL53L4CX_PerformXTalkCalibration`. After this i again store the struct to a file.

For the normal measurement i read the struct from disk and load it with the SetCalibrationData method, and i then also perform:

  • VL53L4CX_SetXTalkCompensationEnable(1);
  • VL53L4CX_SetMeasurementTimingBudgetMicroSeconds(33333);
  • VL53L4CX_SetDistanceMode(VL53L4CX_DISTANCEMODE_LONG);
  • VL53L4CX_SetOffsetCorrectionMode(VL53L4CX_OFFSETCORRECTIONMODE_PERVCSEL);
  • VL53L4CX_SmudgeCorrectionEnable(VL53L4CX_SMUDGE_CORRECTION_CONTINUOUS);

 

I then do the StartMeasurement() and get the readings.

 

This seems to work well for now. I need to work on a setup with a box so the measurements are more exact and it becomes easier to run this calibration process, but overall - i'm happy like this.

Is there anything that i could do differently to get better accuracy and/or less issues with (for example) dirty cover glass?

John E KVAM
ST Employee
May 6, 2025

We have huge debates on the topic. Turns out the Xtalk would like the offset done first and the offset calibration would like the crosstalk done first. But these are pretty minor effects. 

But just follow the manual.

Either way, the refspad does NOT need a target, but doesn't mind one either. So set it up for Crosstalk, then do the refspad and then the crosstalk. Lastly insert your 14cm target and do the offset. 

Sorry I added to the confusion. We recommend doing it different ways on different models of the VL53. I just depends on who was doing the work. 

But with a 14cm bright target the effect of the crosstalk is minimized. And the offset error is pretty minor given a target at a goodly distance. 

But follow the manual.

- john

Visitor II
May 6, 2025

Thanks!  One more thing -- I've seen different things on different models -- for the VL53L4CX, should I use a light target for offset and a dark target for xtalk? Does it matter?

John E KVAM
ST Employee
May 6, 2025

It does matter. The bright close target used for offset will return 20million photons per second, so the  hundred thousand from the cover glass won't change the answer much. So the offset cal works.

The dull, distant target will return 500,000 photons per second, and the coverglass will return that same hundred thousand. So, you will end up 20% short - which is what you want for crosstalk calibration.

White printer paper is the best offset cal target. And matte finish Black spray paint over something like cardboard would work for a crosstalk target.

- john

Visitor II
May 6, 2025

You're understanding it correctly — for SPAD calibration, the goal is to minimize reflections, so pointing it upwards to the sky or in a long, empty indoor space is ideal. In factory settings, they often use non-reflective chambers or controlled environments to simulate “no target” conditions without needing much physical space. It’s more about reducing any detectable return signal rather than actual distance.

John E KVAM
ST Employee
May 6, 2025

RMcmillan is correct - for some of our ToF sensors. 

The VL53L4CX, the VL53L1CB and the VL53L3 all use 'histograms'. And with a histogram you can directly measure the number of photons reflecting off the cover glass. Each histogram bin is the number of photons that are collected during each clock cycle.

But the VL53L4CD (and the VL53L1CX) do NOT use histograms. So, they find the cross talk by ranging on a target By knowing the true distance, the measured distance and the total number of photons, the crosstalk is derived. If the range is 20% short, then 20% of the photons must have come from the coverglass. (Actually, the algo is more complex than that, but it's basically how it works.)

So for the VL53L4CD (and the VL53L1CX) one must do a little work to find a target and a distance that ranges 10 or 20% of the true distance. 

cyclopsAuthor
Associate III
September 27, 2025

I've left this project for a bit and now started to pick things up again, so this is a somewhat late reply :)

 

I'm using https://itead.cc/product/sonoff-ip66/ for the enclosure and the sensor is jammed against the lid.

 

I perform the caliberation as i described earlier, and this does give good results. I however sometimes get 2 objects of which one is only 0mm or maybe 5mm or so. I guess this is still crosstalk causing an issue?

 

So, when i do the crosstalk calibration, i do this with a white sheet of paper at ~60cm of distance. Is there any specific other things that i can do to improve this?

Zhiyuan.Han
Technical Moderator
September 30, 2025

Hi 

Your two targets issue is typical issue caused by crosstalk. 

About crosstalk calibration, normally we suggest use low reflectance target, as John suggested in previous reply "matte finish Black spray paint over something like cardboard would work for a crosstalk target."

After crosstalk calibration, remember to save the crosstalk result and load it to sensor again after rebooting. 

 

Br

Zhiyuan.Han

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.
cyclopsAuthor
Associate III
January 10, 2026

Thanks for the pointers.

I have been able to get better results with calibration. It's ok for now. I do however want to create a dedicated calibration box, and was wondering if there are any documents on how to do that exactly?

Currently, my thinking is:

  • Wooden (probably MDF) box with an internal height from sensor to top of 60cm
  • Matt black paint on the inside
  • drawer mechanism at around 15cm with a white underside
  • box fully enclosed and only the drawer mechanism and a small cutout at the bottom to push the sensor in.

 

Is this the right approach? One thing that isn't very clear for me is what the light conditions should be during this caliberation. The above would put this all into a nearly completely dark box, which to me makes sense... but i'm not sure if that's correct?