Skip to main content
AMick.1
Associate II
November 4, 2020
Solved

Can't make Ranging and Multi Zone scanning to work on VL53L1. Negative distances.

  • November 4, 2020
  • 12 replies
  • 5912 views

I have a sensor part no VL53L1CBV0FY/1 I use driver version 6.6.1.

GetDeviceInfo reports:

Name: VL53L1 cut1.0

Type: VL53L1

Product type: 0

Version major: 1

Version minor: 0

My initialization sequence is like this:

 status += VL53L1_WaitDeviceBooted(Dev);
 status += VL53L1_DataInit(Dev);
 status += VL53L1_StaticInit(Dev);
 status += VL53L1_SetPresetMode(Dev, VL53L1_PRESETMODE_RANGING);
 status += VL53L1_SetDistanceMode(Dev, VL53L1_DISTANCEMODE_LONG);
status += VL53L1_SetMeasurementTimingBudgetMicroSeconds(16 * 1000);status += VL53L1_StartMeasurement(Dev);

My Query sequence is like this:

 VL53L1_ClearInterruptAndStartMeasurement(Dev);
 VL53L1_WaitMeasurementDataReady(Dev);
 VL53L1_GetMultiRangingData(Dev, &MultiRangingData);

But returned data is totally bogus:

MultiRangingData.DmaxMilliMeter: 0
MultiRangingData.EffectiveSpadRtnCount 24408
MultiRangingData.HasXtalkValueChanged: 0
MultiRangingData.NumberOfObjectsFound: 3
MultiRangingData.RecommendedDistanceMode: 3
MultiRangingData.RoiNumber: 0
MultiRangingData.RoiStatus: 2
MultiRangingData.StreamCount: 7
MultiRangingData.RangeData[0].AmbientRateRtnMegaCps: 3072
MultiRangingData.RangeData[0].ExtendedRange: 0
MultiRangingData.RangeData[0].RangeFractionalPart: 0
MultiRangingData.RangeData[0].RangeMaxMilliMeter: -1791
MultiRangingData.RangeData[0].RangeMilliMeter: -2015
MultiRangingData.RangeData[0].RangeMinMilliMeter: -2075
MultiRangingData.RangeData[0].RangeQualityLevel: 50
MultiRangingData.RangeData[0].RangeStatus: 4
MultiRangingData.RangeData[0].SigmaMilliMeter: 99840
MultiRangingData.RangeData[0].SignalRateRtnMegaCps: 1575936
MultiRangingData.RangeData[1].AmbientRateRtnMegaCps: 3072
MultiRangingData.RangeData[1].ExtendedRange: 0
MultiRangingData.RangeData[1].RangeFractionalPart: 0
MultiRangingData.RangeData[1].RangeMaxMilliMeter: 622
MultiRangingData.RangeData[1].RangeMilliMeter: 612
MultiRangingData.RangeData[1].RangeMinMilliMeter: 612
MultiRangingData.RangeData[1].RangeQualityLevel: 50
MultiRangingData.RangeData[1].RangeStatus: 0
MultiRangingData.RangeData[1].SigmaMilliMeter: 2381824
MultiRangingData.RangeData[1].SignalRateRtnMegaCps: 7680
--------------------------------------------------------
MultiRangingData.DmaxMilliMeter: 0
MultiRangingData.EffectiveSpadRtnCount 24408
MultiRangingData.HasXtalkValueChanged: 0
MultiRangingData.NumberOfObjectsFound: 3
MultiRangingData.RecommendedDistanceMode: 3
MultiRangingData.RoiNumber: 0
MultiRangingData.RoiStatus: 2
MultiRangingData.StreamCount: 8
MultiRangingData.RangeData[0].AmbientRateRtnMegaCps: 6144
MultiRangingData.RangeData[0].ExtendedRange: 0
MultiRangingData.RangeData[0].RangeFractionalPart: 0
MultiRangingData.RangeData[0].RangeMaxMilliMeter: -2801
MultiRangingData.RangeData[0].RangeMilliMeter: -2807
MultiRangingData.RangeData[0].RangeMinMilliMeter: -2807
MultiRangingData.RangeData[0].RangeQualityLevel: 50
MultiRangingData.RangeData[0].RangeStatus: 4
MultiRangingData.RangeData[0].SigmaMilliMeter: 95744
MultiRangingData.RangeData[0].SignalRateRtnMegaCps: 1476096
MultiRangingData.RangeData[1].AmbientRateRtnMegaCps: 6144
MultiRangingData.RangeData[1].ExtendedRange: 0
MultiRangingData.RangeData[1].RangeFractionalPart: 0
MultiRangingData.RangeData[1].RangeMaxMilliMeter: -1654
MultiRangingData.RangeData[1].RangeMilliMeter: -1654
MultiRangingData.RangeData[1].RangeMinMilliMeter: -1665
MultiRangingData.RangeData[1].RangeQualityLevel: 50
MultiRangingData.RangeData[1].RangeStatus: 4
MultiRangingData.RangeData[1].SigmaMilliMeter: 1776128
MultiRangingData.RangeData[1].SignalRateRtnMegaCps: 9216
--------------------------------------------------------

Sensor is powered from 3V3, 2V8 define is defined in the code.

Please help?

This topic has been closed for replies.
Best answer by John E KVAM

check the manual on your MCU. There are a lot of MCU's that limit the length of an I2C as it saves hardware space. And 63 sounds like one of those limits.

Go into write_multi() function in the platoform.c and break up the long writes into smaller chunks. It takes a little coding.

But it's not that hard.

After that I'll bet the chip sets up better.

We actually debated about the long I2C, but didn't want to slow the boot process for all MCUs based on a few that couldn't do the long write.

12 replies

John E KVAM
ST Employee
November 11, 2020

You know I'm wondering if its your print statements that are goofing up.

You got:

  1. expected = 3939242239
  2. read_multi = 234 204 16 255
  3. read_bytes = 234 204 16 255

I've done this many times and you simply cannot print a byte and have it come out as 234.

You have to prrint this stuff out as hex values. Otherwise you will never figure it out.

The first thing you read is the part ID.

And the line is:

Status = rd_write_verification(dev, 0x10f, 0xeacc10ff); // verify the Chip ID works

So one would expect to get EA CC 10 ff - and that is what you got, but in decimal, not hex format.

The next lines:

  1. read words = 60108 4351
  2. read dword = 3939242239

Translated that is:

EACC 10FF

EACC10FF

And that looks right - so you have words and Dwords working

You can do the rest.

but do check the long I2C transactions. Lots of MCUs limit them in length. Check your MCU manual.

John E KVAM
ST Employee
December 10, 2020

the intermeasurement time is the time from the start of one ranging operation to the next. if you want to go as fast as you can simply do not set it. The next range will start immediately. But if you do set it - presumably to put some dead time between each range you have to understand that the clock that manages the timing budget is different from the one that manages the intermeasurement period. If you put the two numbers too close to each other, your IM clock might tick over just BEFORE the timing budget clock. In this case the system will wait until the next IM period. So to be safe, if you use the IM clock make it a bit longer than the TB clock. 4ms is a safe distance.

And this is a really good question. But if you simply tack it on to other questions, no one else will ever find the answer. Could I ask you to open another question, please?