cancel
Showing results for 
Search instead for 
Did you mean: 

How do I read the distance of the closest detected object instead of an average distance of all detected objects with the VL53L1X?

wild
Associate II

Greetings.

If I point the sensor at a wall and then slowly move my hand into the sensor's viewing area, the sensor gradually changes its reported range from the distance to the wall to the distance to my hand as shown in this graph.

0693W000006GMiGQAW.pngIs it possible to set up the sensor to immediately report my hand's true distance as soon as it is detected instead of reporting a false distance until it has been fully moved in front of the sensor?

Here is my API setup code:

VL53L1X_SensorInit( 0 );
VL53L1X_SetTimingBudgetInMs( 0, 20 ); // 20ms sample time
VL53L1X_SetInterMeasurementInMs( 0, 20 ); // Sample every 20ms
VL53L1X_StartRanging( 0 );

Thank you

Scott Wild

1 ACCEPTED SOLUTION

Accepted Solutions
John E KVAM
ST Employee

Scott -

The VL53L1X is going to do exactly as you say. However we have a part that does what you want.

The VL53L1CB is what you want.

The chips are almost identical. But the CB version runs different code.

So identical in fact that there is a really, really good chance your X will run the CB code - but it's not guarenteed. (So if you go into production do buy the CB version. It's only a few cents more.)

Download the

STSW-IMG020 GUI for X-NUCLEO-53L1A2

if you have the EVAL kit. It will most likely will run on the -53L1A1 kit.

Download the STSW-IMG019 API for VL53L1CB

The IMG019 is pretty large. But it does a lot more.

Play with it. Make sure it does what you want.

You will get two targets in the case you suggest. You will see your wall AND your hand.

Good luck


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. It helps the next guy.

View solution in original post

5 REPLIES 5
John E KVAM
ST Employee

Scott -

The VL53L1X is going to do exactly as you say. However we have a part that does what you want.

The VL53L1CB is what you want.

The chips are almost identical. But the CB version runs different code.

So identical in fact that there is a really, really good chance your X will run the CB code - but it's not guarenteed. (So if you go into production do buy the CB version. It's only a few cents more.)

Download the

STSW-IMG020 GUI for X-NUCLEO-53L1A2

if you have the EVAL kit. It will most likely will run on the -53L1A1 kit.

Download the STSW-IMG019 API for VL53L1CB

The IMG019 is pretty large. But it does a lot more.

Play with it. Make sure it does what you want.

You will get two targets in the case you suggest. You will see your wall AND your hand.

Good luck


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. It helps the next guy.
wild
Associate II

Thank you for the info!

John E KVAM
ST Employee

And if the VL53L1CB works for you, but you don't need the adjustable Field of View or the extra distance, consider the VL53L3CX. This chip uses the exact same software as the VL53L1CB, but does not have the lens over the receive side. This would save you some money.


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. It helps the next guy.
AVand.2
Associate

John. Can you elaborate on the procedure for using the VL53L1CB API? I have the Sparkfun VL53L1X board. Do I need to use the GUI?

wild
Associate II

It's pretty straightforward. Just download the source and build it into your project. You will need to modify platform/src/vl53l1_platform.c to support your hardware's I2C and timing routines.

For simple autonomous mode, do the following in your setup routine:

  VL53L1_DataInit( &vl53l1Dev );
  VL53L1_StaticInit( &vl53l1Dev );
  VL53L1_SetPresetMode( &vl53l1Dev, VL53L1_PRESETMODE_AUTONOMOUS );
  VL53L1_SetInterMeasurementPeriodMilliSeconds( &vl53l1Dev, 50 );
  VL53L1_SetMeasurementTimingBudgetMicroSeconds( &vl53l1Dev, 40000 );
  VL53L1_SetDistanceMode( &vl53l1Dev, VL53L1_DISTANCEMODE_SHORT );
  VL53L1_StartMeasurement( &vl53l1Dev );

Then in your main loop, do this to read the range data:

	  VL53L1_RangingMeasurementData_t rangeData;
	  VL53L1_GetRangingMeasurementData( &vl53l1Dev, &rangeData );
 
	  // If a ranging error was found, return 0
	  range = rangeData.RangeStatus ? 0 : rangeData.RangeMilliMeter;

Be forewarned, the library is a hog. It takes around 44k of code space and 12k of SRAM.

Good luck!

Scott