2020-11-04 07:19 AM
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?
Solved! Go to Solution.
2020-11-11 06:51 AM
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.
2020-11-04 07:21 AM
Also 6.6.1 library has a bug: ExtendedRangeEnabled has to be int32_t. Library crashes my system if it's int8_t as originally written in the library.
2020-11-04 07:39 AM
The answer is your Range_status =4 VL53L1_RANGESTATUS_OUTOFBOUNDS_FAIL Raised when phase is out of bounds.
there are two instances you can get range status=4.
One is if the target is farther than the range of the sensor and you get something called "Radar aliasing" - which you should google.
Or there is so much motion that the two internal ranges do not get an answer.
Pick distace from your desk to the ceiling and range on that. It's a constanst known distance. And hopefully lower than 4Meters.
Check the range_status before anything else. If the range_status is bad, then perhaps the rest of the data is bad as well.
ST just released Maint _6.0 on the VL53L1CB. Consider upgrading to that. It's on st.com
Works the same way, but has more advanced processing to help deal with wrap issues.
2020-11-04 01:53 PM
Hi John,
Thanks for your prompt answer.
I am pointing sensor to ceiling that is ~2m away and it does not move. Also sometimes RangeStatus alternates between 4 and 7.
AUTONOMIC mode works fine, it returns proper distance, I am having problems just in Ranging and Multi Zone Scanning modes.
I could not post the whole log, but there are also negative distances with RangeStatus == 0 returned:
--------------------------------------------------------
MultiRangingData.DmaxMilliMeter: 0
MultiRangingData.EffectiveSpadRtnCount 24408
MultiRangingData.HasXtalkValueChanged: 0
MultiRangingData.NumberOfObjectsFound: 2
MultiRangingData.RecommendedDistanceMode: 3
MultiRangingData.RoiNumber: 0
MultiRangingData.RoiStatus: 2
MultiRangingData.StreamCount: 5
MultiRangingData.RangeData[0].AmbientRateRtnMegaCps: 3072
MultiRangingData.RangeData[0].ExtendedRange: 0
MultiRangingData.RangeData[0].RangeFractionalPart: 0
MultiRangingData.RangeData[0].RangeMaxMilliMeter: -1944
MultiRangingData.RangeData[0].RangeMilliMeter: -2060
MultiRangingData.RangeData[0].RangeMinMilliMeter: -2060
MultiRangingData.RangeData[0].RangeQualityLevel: 50
MultiRangingData.RangeData[0].RangeStatus: 4
MultiRangingData.RangeData[0].SigmaMilliMeter: 137728
MultiRangingData.RangeData[0].SignalRateRtnMegaCps: 1171456
MultiRangingData.RangeData[1].AmbientRateRtnMegaCps: 3072
MultiRangingData.RangeData[1].ExtendedRange: 1
MultiRangingData.RangeData[1].RangeFractionalPart: 0
MultiRangingData.RangeData[1].RangeMaxMilliMeter: 1659
MultiRangingData.RangeData[1].RangeMilliMeter: 1467
MultiRangingData.RangeData[1].RangeMinMilliMeter: 625
MultiRangingData.RangeData[1].RangeQualityLevel: 50
MultiRangingData.RangeData[1].RangeStatus: 0
MultiRangingData.RangeData[1].SigmaMilliMeter: 65536
MultiRangingData.RangeData[1].SignalRateRtnMegaCps: 11184640
--------------------------------------------------------
MultiRangingData.DmaxMilliMeter: 0
MultiRangingData.EffectiveSpadRtnCount 24408
MultiRangingData.HasXtalkValueChanged: 0
MultiRangingData.NumberOfObjectsFound: 2
MultiRangingData.RecommendedDistanceMode: 3
MultiRangingData.RoiNumber: 0
MultiRangingData.RoiStatus: 2
MultiRangingData.StreamCount: 6
MultiRangingData.RangeData[0].AmbientRateRtnMegaCps: 6144
MultiRangingData.RangeData[0].ExtendedRange: 0
MultiRangingData.RangeData[0].RangeFractionalPart: 0
MultiRangingData.RangeData[0].RangeMaxMilliMeter: -2811
MultiRangingData.RangeData[0].RangeMilliMeter: -2819
MultiRangingData.RangeData[0].RangeMinMilliMeter: -2819
MultiRangingData.RangeData[0].RangeQualityLevel: 50
MultiRangingData.RangeData[0].RangeStatus: 4
MultiRangingData.RangeData[0].SigmaMilliMeter: 92160
MultiRangingData.RangeData[0].SignalRateRtnMegaCps: 2344960
MultiRangingData.RangeData[1].AmbientRateRtnMegaCps: 6144
MultiRangingData.RangeData[1].ExtendedRange: 1
MultiRangingData.RangeData[1].RangeFractionalPart: 0
MultiRangingData.RangeData[1].RangeMaxMilliMeter: 121
MultiRangingData.RangeData[1].RangeMilliMeter: -70
MultiRangingData.RangeData[1].RangeMinMilliMeter: -262
MultiRangingData.RangeData[1].RangeQualityLevel: 50
MultiRangingData.RangeData[1].RangeStatus: 0
MultiRangingData.RangeData[1].SigmaMilliMeter: 65536
MultiRangingData.RangeData[1].SignalRateRtnMegaCps: 8388096
--------------------------------------------------------
MultiRangingData.DmaxMilliMeter: 0
MultiRangingData.EffectiveSpadRtnCount 19200
MultiRangingData.HasXtalkValueChanged: 0
MultiRangingData.NumberOfObjectsFound: 2
MultiRangingData.RecommendedDistanceMode: 3
MultiRangingData.RoiNumber: 0
MultiRangingData.RoiStatus: 2
MultiRangingData.StreamCount: 7
MultiRangingData.RangeData[0].AmbientRateRtnMegaCps: 5120
MultiRangingData.RangeData[0].ExtendedRange: 0
MultiRangingData.RangeData[0].RangeFractionalPart: 0
MultiRangingData.RangeData[0].RangeMaxMilliMeter: -1945
MultiRangingData.RangeData[0].RangeMilliMeter: -2057
MultiRangingData.RangeData[0].RangeMinMilliMeter: -2057
MultiRangingData.RangeData[0].RangeQualityLevel: 50
MultiRangingData.RangeData[0].RangeStatus: 4
MultiRangingData.RangeData[0].SigmaMilliMeter: 109568
MultiRangingData.RangeData[0].SignalRateRtnMegaCps: 1576448
MultiRangingData.RangeData[1].AmbientRateRtnMegaCps: 5120
MultiRangingData.RangeData[1].ExtendedRange: 1
MultiRangingData.RangeData[1].RangeFractionalPart: 0
MultiRangingData.RangeData[1].RangeMaxMilliMeter: 1659
MultiRangingData.RangeData[1].RangeMilliMeter: 1467
MultiRangingData.RangeData[1].RangeMinMilliMeter: 1275
MultiRangingData.RangeData[1].RangeQualityLevel: 50
MultiRangingData.RangeData[1].RangeStatus: 0
MultiRangingData.RangeData[1].SigmaMilliMeter: 65536
MultiRangingData.RangeData[1].SignalRateRtnMegaCps: 8388096
--------------------------------------------------------
MultiRangingData.DmaxMilliMeter: 0
MultiRangingData.EffectiveSpadRtnCount 19200
MultiRangingData.HasXtalkValueChanged: 0
MultiRangingData.NumberOfObjectsFound: 2
MultiRangingData.RecommendedDistanceMode: 3
MultiRangingData.RoiNumber: 0
MultiRangingData.RoiStatus: 2
MultiRangingData.StreamCount: 8
MultiRangingData.RangeData[0].AmbientRateRtnMegaCps: 5632
MultiRangingData.RangeData[0].ExtendedRange: 0
MultiRangingData.RangeData[0].RangeFractionalPart: 0
MultiRangingData.RangeData[0].RangeMaxMilliMeter: -2818
MultiRangingData.RangeData[0].RangeMilliMeter: -2827
MultiRangingData.RangeData[0].RangeMinMilliMeter: -2827
MultiRangingData.RangeData[0].RangeQualityLevel: 50
MultiRangingData.RangeData[0].RangeStatus: 4
MultiRangingData.RangeData[0].SigmaMilliMeter: 86528
MultiRangingData.RangeData[0].SignalRateRtnMegaCps: 2626048
MultiRangingData.RangeData[1].AmbientRateRtnMegaCps: 5632
MultiRangingData.RangeData[1].ExtendedRange: 1
MultiRangingData.RangeData[1].RangeFractionalPart: 0
MultiRangingData.RangeData[1].RangeMaxMilliMeter: 121
MultiRangingData.RangeData[1].RangeMilliMeter: -70
MultiRangingData.RangeData[1].RangeMinMilliMeter: -262
MultiRangingData.RangeData[1].RangeQualityLevel: 50
MultiRangingData.RangeData[1].RangeStatus: 0
MultiRangingData.RangeData[1].SigmaMilliMeter: 65536
MultiRangingData.RangeData[1].SignalRateRtnMegaCps: 6710784
--------------------------------------------------------
MultiRangingData.DmaxMilliMeter: 0
MultiRangingData.EffectiveSpadRtnCount 9048
MultiRangingData.HasXtalkValueChanged: 0
MultiRangingData.NumberOfObjectsFound: 2
MultiRangingData.RecommendedDistanceMode: 3
MultiRangingData.RoiNumber: 0
MultiRangingData.RoiStatus: 2
MultiRangingData.StreamCount: 9
MultiRangingData.RangeData[0].AmbientRateRtnMegaCps: 2560
MultiRangingData.RangeData[0].ExtendedRange: 0
MultiRangingData.RangeData[0].RangeFractionalPart: 0
MultiRangingData.RangeData[0].RangeMaxMilliMeter: -1947
MultiRangingData.RangeData[0].RangeMilliMeter: -2060
MultiRangingData.RangeData[0].RangeMinMilliMeter: -2060
MultiRangingData.RangeData[0].RangeQualityLevel: 50
MultiRangingData.RangeData[0].RangeStatus: 4
MultiRangingData.RangeData[0].SigmaMilliMeter: 101888
MultiRangingData.RangeData[0].SignalRateRtnMegaCps: 1621504
MultiRangingData.RangeData[1].AmbientRateRtnMegaCps: 2560
MultiRangingData.RangeData[1].ExtendedRange: 1
MultiRangingData.RangeData[1].RangeFractionalPart: 0
MultiRangingData.RangeData[1].RangeMaxMilliMeter: 1659
MultiRangingData.RangeData[1].RangeMilliMeter: 1467
MultiRangingData.RangeData[1].RangeMinMilliMeter: 1275
MultiRangingData.RangeData[1].RangeQualityLevel: 50
MultiRangingData.RangeData[1].RangeStatus: 0
MultiRangingData.RangeData[1].SigmaMilliMeter: 65536
MultiRangingData.RangeData[1].SignalRateRtnMegaCps: 6710784
--------------------------------------------------------
MultiRangingData.DmaxMilliMeter: 0
MultiRangingData.EffectiveSpadRtnCount 9048
MultiRangingData.HasXtalkValueChanged: 0
MultiRangingData.NumberOfObjectsFound: 2
MultiRangingData.RecommendedDistanceMode: 3
MultiRangingData.RoiNumber: 0
MultiRangingData.RoiStatus: 2
MultiRangingData.StreamCount: 10
MultiRangingData.RangeData[0].AmbientRateRtnMegaCps: 4608
MultiRangingData.RangeData[0].ExtendedRange: 0
MultiRangingData.RangeData[0].RangeFractionalPart: 0
MultiRangingData.RangeData[0].RangeMaxMilliMeter: -2818
MultiRangingData.RangeData[0].RangeMilliMeter: -2827
MultiRangingData.RangeData[0].RangeMinMilliMeter: -2827
MultiRangingData.RangeData[0].RangeQualityLevel: 50
MultiRangingData.RangeData[0].RangeStatus: 4
MultiRangingData.RangeData[0].SigmaMilliMeter: 86528
MultiRangingData.RangeData[0].SignalRateRtnMegaCps: 2188288
MultiRangingData.RangeData[1].AmbientRateRtnMegaCps: 4608
MultiRangingData.RangeData[1].ExtendedRange: 1
MultiRangingData.RangeData[1].RangeFractionalPart: 0
MultiRangingData.RangeData[1].RangeMaxMilliMeter: 121
MultiRangingData.RangeData[1].RangeMilliMeter: -70
MultiRangingData.RangeData[1].RangeMinMilliMeter: -262
MultiRangingData.RangeData[1].RangeQualityLevel: 50
MultiRangingData.RangeData[1].RangeStatus: 0
MultiRangingData.RangeData[1].SigmaMilliMeter: 65536
MultiRangingData.RangeData[1].SignalRateRtnMegaCps: 5592064
--------------------------------------------------------
How do I read range to the ceiling in Ranging mode? Sensor reports that two objects are detected, one RangeData is with RangeStatus==4, other RangeStatus==0, but the reading fluctuates between -70 and 1659. Can the reading be negative if RangeStatus!=0? Can it be negative while RangeStatus==0?
2020-11-05 04:45 AM
I have double-checked my code again, also I have tried other preset modes. The bogus data seems to come only in histogram-related modes - Ranging and Multizone. LightRaging and Autonomous presets work fine and return correct data.
Is there a known good Ranging and/or Multizone implementation example for VL53L1CBV0FY I could try to reproduce?
We have chosen VL53L1CBV0FY specifically for it's Multizone capability and it does not seem to work with 6.6.1 or 6.5.1 version of API.
2020-11-05 05:17 AM
I experienced the same issue with both version 6.6.1 and 6.5.1, the histogram-based preset modes sometimes delivered wrong measurement values with status 0 (including negative values). In the same measurement setup LightRanging and Autonomous worked fine.
2020-11-05 07:37 AM
Ouch - I know the answer. And I'm embarassed that I didn't see it sooner.
In histogram mode you get a lot of things. You get multiple targets for one.
But you don't get autonomous ranging.
The tiny MCU in the sensor is not powerful enough to process the histograms. So we pass the raw data up to your host and process the last bit in your MCU.
And it works - but as you can see you really do have to process every range and cannot use threshold interrupts.
I'm sorry about that.
And I'm really sorry I didn't see it sooner.
2020-11-05 08:31 AM
Hi John,
Thanks for your reply. I am not interested in AUTONOMOUS mode, I am interested in Multizone ranging in particular. Now neither Multizone nor Ranging works. I suspect that calculation is faulty somewhere in host code in histogram mode. I have tried filtering all RangeData by RangeStatus==0 and I get a lot of incorrect data - negative values and positive values that don't make sense (oscillate between -70mm and ~1600mm when real distance is ~1900mm). If I try holding my hand above the sensor I get negative distance readings with RangeStatus==0 only. Readings correlate to hand being moved somewhat, but it seems calculations somewhere in the driver code overflow resulting in negative values.
Is there a known good Ranging or Multizone project that runs on 32bit micro-controller for VL53L1?
2020-11-05 01:43 PM
Here is an example of how multi-zone rangeing works.
We have several drivers for the VL53L1 - and you need to know which one you have.
The Ultralite driver for the VL53L1X will do multizone scanning - but it's tricky - you need to change the zone before the next range starts.
But this example uses the bare driver - or linux driver, and once set up it changes the zones automatically.
You will know you have the right driver if you have the function VL53L1_SetROI().
I think this example uses 3 zones but you get 4 max. Compare this to what you were doing.
VL53L1_Error SetROIExample(VL53L1_DEV Dev)
{
VL53L1_Error Status = VL53L1_ERROR_NONE;
VL53L1_RoiConfig_t RoiConfig;
uint8_t MaxNumberOfROI;
Status = VL53L1_GetMaxNumberOfROI(Dev, &MaxNumberOfROI);
printf("MaxNumberOfROI : %d\n", MaxNumberOfROI);
if (Status == VL53L1_ERROR_NONE) {
RoiConfig.NumberOfRoi = 3;
RoiConfig.UserRois[0].TopLeftX = 3;
RoiConfig.UserRois[0].TopLeftY = 10;
RoiConfig.UserRois[0].BotRightX = 10;
RoiConfig.UserRois[0].BotRightY = 3;
RoiConfig.UserRois[1].TopLeftX = 5;
RoiConfig.UserRois[1].TopLeftY = 12;
RoiConfig.UserRois[1].BotRightX = 12;
RoiConfig.UserRois[1].BotRightY = 5;
RoiConfig.UserRois[2].TopLeftX = 6;
RoiConfig.UserRois[2].TopLeftY = 13;
RoiConfig.UserRois[2].BotRightX = 13;
RoiConfig.UserRois[2].BotRightY = 6;
Status = VL53L1_SetROI(Dev, &RoiConfig);
}
return Status;
}
2020-11-05 02:36 PM
Thanks!
I know I have VL53L1CBV0FY sensor (VL53L1, NOT VL53L1X) and I know I use a bare driver found in VL53L1 page, STSW-IMG019, containing bare driver version 6.6.1. So yes, I have access to VL53L1_SetROI() function.
I will port the code you posted verbatim and test it tomorrow.
I am compiling this using GCC under 32bit ARM, not on Linux.
Also note, v6.6.1 contains a bug that prevents using the driver on 32bit ARM, meaning, VL53L1_GetMultiRangingData() does not work out of the box. ExtendedRangeEnabled has to be int32_t, not int8_t.