cancel
Showing results for 
Search instead for 
Did you mean: 

[VL53L1X] question on #01> correctness of range measurement, #02> Usage of VL53L1_PRESETMODE_LITE_RANGING

SSong.2
Associate II

Hi ST engineers,

I would like to figure out how to get accurate measured distance value and getting the value with reasonable interval.

[testing environment]

Nordic NRF52840, vl53l1_platform.c file implemented to use nordic I2C api,

SW version: en.STSW-IMG007 (2.3.3)

refered the reference implementation (STM32CubeExpansion_53L1A1_V2.1.0)

I need only short distance measurement(<1m)

user polling only (not using interrupt)

[VL53L1 test items]

#01. Simple mode

status = VL53L1_WaitDeviceBooted(pdev);

status = VL53L1_DataInit(pdev);

status = VL53L1_StaticInit(pdev);

status = VL53L1_SetDistanceMode(pdev, VL53L1_DISTANCEMODE_LONG);

status = VL53L1_SetMeasurementTimingBudgetMicroSeconds(pdev, 50000);

status = VL53L1_SetInterMeasurementPeriodMilliSeconds(pdev, 500);

status = VL53L1_StartMeasurement(pdev);

RESULT:

There are too many measurement errors(checked via RangingData.RangeStatus that is not 0) and the measured distance is not correct.

#02. fast ranging test

status = VL53L1_WaitDeviceBooted(pdev);

status = VL53L1_DataInit(pdev);

status = VL53L1_StaticInit(pdev);

status = VL53L1_SetPresetMode(pdev, VL53L1_PRESETMODE_LITE_RANGING);

status = VL53L1_SetDistanceMode(pdev, VL53L1_DISTANCEMODE_SHORT);

status = VL53L1_SetMeasurementTimingBudgetMicroSeconds(pdev, 20000);

status = VL53L1_SetInterMeasurementPeriodMilliSeconds(pdev, 25);

status = VL53L1_SetUserROI(pdev, &roiData);

status = VL53L1_StartMeasurement(pdev);

RESULT:

The measured distance roughly correct, but the read interval is too long. it seems to me the value updated interval is longer than 1 sec. I have read the user manual and data sheet. Based on the materials, the fast ranging should be much faster than my test result.

#03. other

status = VL53L1_WaitDeviceBooted(pdev);

status = VL53L1_DataInit(pdev);

status = VL53L1_StaticInit(pdev);

status = VL53L1_SetPresetMode(pdev, VL53L1_PRESETMODE_AUTONOMOUS);

status = VL53L1_SetDistanceMode(pdev, VL53L1_DISTANCEMODE_SHORT);

status = VL53L1_SetMeasurementTimingBudgetMicroSeconds(pdev, 10000);

status = VL53L1_StartMeasurement(pdev);

RESULT:

too many measurement error. update interval is much faster than fast ranging test.

And one more thing I found that is after the FOV change to 4x4 (via VL53L1_SetUserROI) the measured distance looks more accurate.

My Questions are as below.

#A. How can I get correct distance value?

#B. How can I get correct distance value with shorter interval ( ex> 100ms)

​I have read the Q&A in ST. But I also have confusion of three mode(VL53L1_PRESETMODE_AUTONOMOUS, VL53L1_PRESETMODE_LITE_RANGING, VL53L1_PRESETMODE_LOWPOWER_AUTONOMOUS)

​I don't have experience on ST ToF sensor, so any small help or comment will be much helpful for me.

6 REPLIES 6
Julien NGUYEN
ST Employee

​Hi,

The VL53L1_PRESETMODE_LITE_RANGING and VL53L1_PRESETMODE_AUTONOMOUS ranging are not recommended.

Please use only the VL53L1_PRESETMODE_LOWPOWER_AUTONOMOUS.

Accuracy depends on the SNR.

The SNR depends on the return signal rate and the ambient.

The return signal rate depends on the target size, the target reflectance and the distance of the target

Please precise the parameter listed above to help me to help you to improve the measurement accuracy.

Julien


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

Thank you for your reply.

I have folllow up ​questions.

In my memory​, I had tested the VL53L1_PRESETMODE_LOWPOWER_AUTONOMOUS mode. But it was not working. I had got the error at the VL53L1_StartMeasurement.

could you share some code snippet based on that mode?

Thank you in advanced.​

SSong.2
Associate II

I have checked ToF custom board with stm32nucleo board with 3.3v. And the sample code that I applied is a AccessRegisters (from en.X-CUBE-53L1A1/STM32CubeExpansion_53L1A1_V2.1.0/Projects/STM32F401RE-Nucleo/Examples/53L1A1/AccessRegisters). And it is working well.

So I'm sure that 3.3v is not a problem although 2.8v is recommended in data sheet.

When I have tested with below setting, there are all of the measurement error..

//Other mode -

status = VL53L1_WaitDeviceBooted(pdev);

status = VL53L1_DataInit(pdev);

status = VL53L1_StaticInit(pdev);

status = VL53L1_SetPresetMode(pdev, VL53L1_PRESETMODE_LOWPOWER_AUTONOMOUS);

// status = VL53L1_SetPresetMode(pdev, VL53L1_PRESETMODE_LITE_RANGING);

status = VL53L1_SetDistanceMode(pdev, VL53L1_DISTANCEMODE_SHORT);

status = VL53L1_SetMeasurementTimingBudgetMicroSeconds(pdev, 20000);

status = VL53L1_SetInterMeasurementPeriodMilliSeconds(pdev, 25);

// status = VL53L1_SetUserROI(pdev, &ur);

// status = VL53L1_SetUserROI(pdev, &roiData);

status = VL53L1_StartMeasurement(pdev);

--------------------------------------------------------------

result

<debug> app: [ToF] 7, 465, 14.85, 4.17

<debug> app: [ToF] 7, 459, 15.10, 4.47

<debug> app: [ToF] 7, 459, 15.10, 4.47

<debug> app: [ToF] 7, 459, 15.10, 4.47

<debug> app: [ToF] 7, 463, 15.14, 4.19

<debug> app: [ToF] 7, 463, 15.14, 4.19

<debug> app: [ToF] 7, 463, 15.14, 4.19

<debug> app: [ToF] 7, 467, 16.20, 4.44

<debug> app: [ToF] 7, 467, 16.20, 4.44

<debug> app: [ToF] 7, 467, 16.20, 4.44

<debug> app: [ToF] 7, 464, 15.01, 4.17

<debug> app: [ToF] 7, 464, 15.01, 4.17

<debug> app: [ToF] 7, 462, 14.96, 4.14

<debug> app: [ToF] 7, 462, 14.96, 4.14

<debug> app: [ToF] 7, 462, 14.96, 4.14

<debug> app: [ToF] 7, 462, 14.87, 4.26

<debug> app: [ToF] 7, 462, 14.87, 4.26

<debug> app: [ToF] 7, 462, 14.87, 4.26

<debug> app: [ToF] 7, 461, 15.21, 4.19

<debug> app: [ToF] 7, 461, 15.21, 4.19

<debug> app: [ToF] 7, 468, 14.56, 4.25

<debug> app: [ToF] 7, 468, 14.56, 4.25

<debug> app: [ToF] 7, 468, 14.56, 4.25

<debug> app: [ToF] 7, 464, 15.16, 4.12

<debug> app: [ToF] 7, 464, 15.16, 4.12

<debug> app: [ToF] 7, 464, 15.16, 4.12

<debug> app: [ToF] 7, 467, 15.60, 4.37

<debug> app: [ToF] 7, 467, 15.60, 4.37

<debug> app: [ToF] 7, 467, 15.60, 4.37

<debug> app: [ToF] 7, 464, 15.53, 4.03

<debug> app: [ToF] 7, 464, 15.53, 4.03

<debug> app: [ToF] 7, 465, 15.10, 4.48

<debug> app: [ToF] 7, 465, 15.10, 4.48

<debug> app: [ToF] 7, 465, 15.10, 4.48

<debug> app: [ToF] 7, 467, 14.13, 4.35

<debug> app: [ToF] 7, 467, 14.13, 4.35

<debug> app: [ToF] 7, 467, 14.13, 4.35

<debug> app: [ToF] 7, 462, 15.70, 4.56

<debug> app: [ToF] 7, 462, 15.70, 4.56

<debug> app: [ToF] 7, 466, 16.06, 4.56

<debug> app: [ToF] 7, 466, 16.06, 4.46

<debug> app: [ToF] 7, 466, 16.06, 4.46

<debug> app: [ToF] 7, 467, 15.71, 4.37

<debug> app: [ToF] 7, 467, 15.71, 4.37

<debug> app: [ToF] 7, 467, 15.71, 4.37

<debug> app: [ToF] 7, 462, 14.61, 4.23

<debug> app: [ToF] 7, 462, 14.61, 4.23

<debug> app: [ToF] 7, 462, 14.61, 4.23

<debug> app: [ToF] 7, 465, 15.61, 4.41

<debug> app: [ToF] 7, 465, 15.61, 4.41

<debug> app: [ToF] 7, 465, 15.80, 4.34

<debug> app: [ToF] 7, 465, 15.80, 4.34

<debug> app: [ToF] 7, 465, 15.80, 4.34

<debug> app: [ToF] 7, 468, 16.01, 4.30

<debug> app: [ToF] 7, 468, 16.01, 4.30

<debug> app: [ToF] 7, 468, 16.01, 4.30

<debug> app: [ToF] 7, 462, 14.12, 4.31

<debug> app: [ToF] 7, 462, 14.12, 4.31

<debug> app: [ToF] 7, 462, 14.12, 4.31

<debug> app: [ToF] 7, 463, 15.47, 4.10

<debug> app: [ToF] 7, 463, 15.47, 4.10

<debug> app: [ToF] 7, 467, 15.04, 4.71

<debug> app: [ToF] 7, 467, 15.04, 4.71

<debug> app: [ToF] 7, 467, 15.04, 4.71

<debug> app: [ToF] 7, 462, 14.94, 4.14

<debug> app: [ToF] 7, 462, 14.94, 4.14

<debug> app: [ToF] 7, 462, 14.94, 4.14

<debug> app: [ToF] 7, 464, 15.77, 4.58

<debug> app: [ToF] 7, 464, 15.77, 4.58

when I tested with below setting

status = VL53L1_WaitDeviceBooted(pdev);

status = VL53L1_DataInit(pdev);

status = VL53L1_StaticInit(pdev);

// status = VL53L1_SetPresetMode(pdev, VL53L1_PRESETMODE_LOWPOWER_AUTONOMOUS);

status = VL53L1_SetPresetMode(pdev, VL53L1_PRESETMODE_LITE_RANGING);

status = VL53L1_SetDistanceMode(pdev, VL53L1_DISTANCEMODE_SHORT);

status = VL53L1_SetMeasurementTimingBudgetMicroSeconds(pdev, 20000);

status = VL53L1_SetInterMeasurementPeriodMilliSeconds(pdev, 25);

status = VL53L1_SetUserROI(pdev, &ur);

// status = VL53L1_SetUserROI(pdev, &roiData);

status = VL53L1_StartMeasurement(pdev);

the result as below with time interval 1~1.5 sec for each line with still much of error..(some are measured )

<debug> app: [ToF] 7, 105, 11.29, 0.00

<debug> app: [ToF] 7, 51, 9.88, 0.00

<debug> app: [ToF] 7, 111, 19.32, 0.01

<debug> app: [ToF] 0, 108, 9.66, 0.01

<debug> app: [ToF] 0, 60, 10.04, 0.00

<debug> app: [ToF] 7, 103, 19.67, 0.03

<debug> app: [ToF] 7, 47, 14.88, 0.01

<debug> app: [ToF] 7, 638, 1.82, 0.09

<debug> app: [ToF] 7, 634, 1.82, 0.09

<debug> app: [ToF] 7, 643, 1.78, 0.08

<debug> app: [ToF] 7, 325, 1.84, 0.09

<debug> app: [ToF] 7, 332, 1.78, 0.09

<debug> app: [ToF] 0, 71, 42.61, 0.01

<debug> app: [ToF] 0, 47, 20.10, 0.00

<debug> app: [ToF] 0, 87, 19.89, 0.00

<debug> app: [ToF] 0, 47, 28.15, 0.00

<debug> app: [ToF] 0, 84, 20.33, 0.00

<debug> app: [ToF] 0, 47, 19.82, 0.00

<debug> app: [ToF] 0, 82, 29.59, 0.00

<debug> app: [ToF] 0, 47, 16.86, 0.00

<debug> app: [ToF] 0, 93, 16.61, 0.00

<debug> app: [ToF] 0, 47, 19.93, 0.00

<debug> app: [ToF] 0, 82, 20.58, 0.00

<debug> app: [ToF] 0, 47, 21.05, 0.00

<debug> app: [ToF] 0, 89, 18.07, 0.00

<debug> app: [ToF] 0, 47, 18.17, 0.00

<debug> app: [ToF] 0, 89, 17.84, 0.00

<debug> app: [ToF] 0, 47, 19.78, 0.00

<debug> app: [ToF] 0, 82, 20.67, 0.00

<debug> app: [ToF] 7, 331, 1.95, 0.07

<debug> app: [ToF] 7, 326, 1.95, 0.08

<debug> app: [ToF] 7, 634, 1.97, 0.07

<debug> app: [ToF] 7, 638, 1.96, 0.07

<debug> app: [ToF] 7, 327, 1.92, 0.07

<debug> app: [ToF] 7, 321, 1.86, 0.07

<debug> app: [ToF] 7, 319, 1.98, 0.07

<debug> app: [ToF] 7, 314, 1.92, 0.07

<debug> app: [ToF] 7, 322, 1.90, 0.08

<debug> app: [ToF] 7, 328, 1.90, 0.07

<debug> app: [ToF] 7, 318, 1.96, 0.07

<debug> app: [ToF] 7, 327, 1.99, 0.06

<debug> app: [ToF] 7, 632, 1.90, 0.07

<debug> app: [ToF] 7, 634, 1.96, 0.06

<debug> app: [ToF] 0, 47, 21.75, 0.01

<debug> app: [ToF] 0, 75, 21.18, 0.00

<debug> app: [ToF] 0, 47, 17.39, 0.00

<debug> app: [ToF] 0, 84, 18.28, 0.00

<debug> app: [ToF] 7, 48, 11.93, 0.00

<debug> app: [ToF] 7, 107, 10.35, 0.01

<debug> app: [ToF] 0, 54, 11.96, 0.00

<debug> app: [ToF] 0, 102, 12.08, 0.00

<debug> app: [ToF] 0, 55, 11.75, 0.00

<debug> app: [ToF] 0, 89, 15.80, 0.00

<debug> app: [ToF] 0, 47, 13.32, 0.00

I think that porting is not a issue due to read device information. Is there a possibility that a porting issue?

My testing environments are as below.

Test env. A: custom ToF board(with 3.3v) with Nucleo board - SUCCESS

Test env. B: custom ToF board with Nordic nrf52840 custom board (with I2C porting) - FAIL

Is there a some HW issue to expect..?? As I checked that 3.3v is not an issue.

( I know this question is very vague that there are so many possibility to figure out issue. )

Any kind of hint or help will be very helpful for me.

Simon

Could you share the working code snippet(with parameter setting) for using VL53L1_PRESETMODE_LOWPOWER_AUTONOMOUS ?

BR,

Simon

SSong.2
Associate II

I changed the I2C speed to 100k then it is working. But there is still error on correctness of measurement distance.

if the distance between object and ToF sensor under the 100 mm there is a measurement error about 20mm.

If the distance between object and ToF sensor about 100 mm to 150mm, there is a measurement error about 30mm.

Could someone help me to make it correct measurement?

Julien NGUYEN
ST Employee

​Hi Simon,

You probably need to perform the offset calibration.

Julien


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.