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-05 02:43 PM
I have just noticed this in your example:
if ((DeviceInfo.ProductRevisionMajor != 1) || (DeviceInfo.ProductRevisionMinor != 1)) {
printf("Warning expected cut 1.1 but found cut %d.%d\n", DeviceInfo.ProductRevisionMajor, DeviceInfo.ProductRevisionMinor);
}
While the sensor I have returns:
Name: VL53L1 cut1.0
Type: VL53L1
Product type: 0
Version major: 1
Version minor: 0
Do I need other version of sensor for Multizone scanning to work?
2020-11-06 02:34 AM
Hi John,
Unfortunately still returns negative values with RangingStatus==0.
run VL53L1_StartMeasurement
Number of measurements = 0
Number of Objects Found = 0
RoiNumber= 0
RoiStatus= 0
Stream Count=0
DmaxMilliMeter=0
Number of measurements = 1
Number of Objects Found = 2
RoiNumber= 0
RoiStatus= 1
Stream Count=0
DmaxMilliMeter=0
SignalRateRtnMegaCps= 1.92
AmbientRateRtnMegaCps= 0.88
EffectiveSpadRtnCount= 27464
SigmaMilliMeter= 6.97
RangeMilliMeter= -1051
RangeMinMilliMeter= -1052
RangeMaxMilliMeter= -1048
RangeStatus= 4
SignalRateRtnMegaCps= 511.99
AmbientRateRtnMegaCps= 0.88
EffectiveSpadRtnCount= 27464
SigmaMilliMeter= 1.00
RangeMilliMeter= -69
RangeMinMilliMeter= -262
RangeMaxMilliMeter= 122
RangeStatus= 4
Number of measurements = 2
Number of Objects Found = 2
RoiNumber= 1
RoiStatus= 2
Stream Count=1
DmaxMilliMeter=0
SignalRateRtnMegaCps= 1.64
AmbientRateRtnMegaCps= 0.97
EffectiveSpadRtnCount= 27920
SigmaMilliMeter= 8.39
RangeMilliMeter= -1077
RangeMinMilliMeter= -1077
RangeMaxMilliMeter= -1065
RangeStatus= 4
SignalRateRtnMegaCps= 511.99
AmbientRateRtnMegaCps= 0.97
EffectiveSpadRtnCount= 27920
SigmaMilliMeter= 1.00
RangeMilliMeter= -70
RangeMinMilliMeter= -263
RangeMaxMilliMeter= 121
RangeStatus= 0
Number of measurements = 3
Number of Objects Found = 0
RoiNumber= 0
RoiStatus= 1
Stream Count=2
DmaxMilliMeter=0
Number of measurements = 4
Number of Objects Found = 0
RoiNumber= 1
RoiStatus= 2
Stream Count=3
DmaxMilliMeter=0
Number of measurements = 5
Number of Objects Found = 2
RoiNumber= 0
RoiStatus= 1
Stream Count=4
DmaxMilliMeter=0
SignalRateRtnMegaCps= 3.68
AmbientRateRtnMegaCps= 1.85
EffectiveSpadRtnCount= 27464
SigmaMilliMeter= 5.36
RangeMilliMeter= -1057
RangeMinMilliMeter= -1057
RangeMaxMilliMeter= -1053
RangeStatus= 4
SignalRateRtnMegaCps= 511.99
AmbientRateRtnMegaCps= 1.85
EffectiveSpadRtnCount= 27464
SigmaMilliMeter= 1.00
RangeMilliMeter= -69
RangeMinMilliMeter= -262
RangeMaxMilliMeter= 122
RangeStatus= 4
Number of measurements = 6
Number of Objects Found = 2
RoiNumber= 1
RoiStatus= 2
Stream Count=5
DmaxMilliMeter=0
SignalRateRtnMegaCps= 3.53
AmbientRateRtnMegaCps= 1.95
EffectiveSpadRtnCount= 27920
SigmaMilliMeter= 5.84
RangeMilliMeter= -1073
RangeMinMilliMeter= -1073
RangeMaxMilliMeter= -1061
RangeStatus= 4
SignalRateRtnMegaCps= 511.99
AmbientRateRtnMegaCps= 1.95
EffectiveSpadRtnCount= 27920
SigmaMilliMeter= 1.00
RangeMilliMeter= -70
RangeMinMilliMeter= -263
RangeMaxMilliMeter= 121
RangeStatus= 0
Number of measurements = 7
Number of Objects Found = 0
RoiNumber= 0
RoiStatus= 1
Stream Count=6
DmaxMilliMeter=0
Number of measurements = 8
Number of Objects Found = 0
RoiNumber= 1
RoiStatus= 2
Stream Count=7
DmaxMilliMeter=0
Number of measurements = 9
Number of Objects Found = 2
RoiNumber= 0
RoiStatus= 1
Stream Count=8
DmaxMilliMeter=0
SignalRateRtnMegaCps= 5.35
AmbientRateRtnMegaCps= 2.91
EffectiveSpadRtnCount= 27464
SigmaMilliMeter= 4.48
RangeMilliMeter= -1056
RangeMinMilliMeter= -1056
RangeMaxMilliMeter= -1053
RangeStatus= 4
SignalRateRtnMegaCps= 511.99
AmbientRateRtnMegaCps= 2.91
EffectiveSpadRtnCount= 27464
SigmaMilliMeter= 1.00
RangeMilliMeter= -69
RangeMinMilliMeter= -262
RangeMaxMilliMeter= 122
RangeStatus= 4
Number of measurements = 10
Number of Objects Found = 2
RoiNumber= 1
RoiStatus= 2
Stream Count=9
DmaxMilliMeter=0
SignalRateRtnMegaCps= 5.34
AmbientRateRtnMegaCps= 3.02
EffectiveSpadRtnCount= 27920
SigmaMilliMeter= 4.86
RangeMilliMeter= -1068
RangeMinMilliMeter= -1068
RangeMaxMilliMeter= -1057
RangeStatus= 4
SignalRateRtnMegaCps= 511.99
AmbientRateRtnMegaCps= 3.02
EffectiveSpadRtnCount= 27920
SigmaMilliMeter= 1.00
RangeMilliMeter= -70
RangeMinMilliMeter= -263
RangeMaxMilliMeter= 121
RangeStatus= 0
Number of measurements = 11
Number of Objects Found = 0
RoiNumber= 0
RoiStatus= 1
Stream Count=10
DmaxMilliMeter=0
Number of measurements = 12
Number of Objects Found = 0
RoiNumber= 1
RoiStatus= 2
Stream Count=11
DmaxMilliMeter=0
Number of measurements = 13
Number of Objects Found = 3
RoiNumber= 0
RoiStatus= 1
Stream Count=12
DmaxMilliMeter=0
SignalRateRtnMegaCps= 0.95
AmbientRateRtnMegaCps= 3.26
EffectiveSpadRtnCount= 27464
SigmaMilliMeter= 16.62
RangeMilliMeter= -1804
RangeMinMilliMeter= -1804
RangeMaxMilliMeter= -1803
RangeStatus= 4
SignalRateRtnMegaCps= 5.27
AmbientRateRtnMegaCps= 3.26
EffectiveSpadRtnCount= 27464
SigmaMilliMeter= 4.71
RangeMilliMeter= -1058
RangeMinMilliMeter= -1058
RangeMaxMilliMeter= -1054
RangeStatus= 4
SignalRateRtnMegaCps= 511.99
AmbientRateRtnMegaCps= 3.26
EffectiveSpadRtnCount= 27464
SigmaMilliMeter= 1.00
RangeMilliMeter= -69
RangeMinMilliMeter= -262
RangeMaxMilliMeter= 122
RangeStatus= 4
Number of measurements = 14
Number of Objects Found = 3
RoiNumber= 1
RoiStatus= 2
Stream Count=13
DmaxMilliMeter=0
SignalRateRtnMegaCps= 0.98
AmbientRateRtnMegaCps= 3.30
EffectiveSpadRtnCount= 27920
SigmaMilliMeter= 17.58
RangeMilliMeter= -1826
RangeMinMilliMeter= -1832
RangeMaxMilliMeter= -1826
RangeStatus= 4
SignalRateRtnMegaCps= 5.64
AmbientRateRtnMegaCps= 3.30
EffectiveSpadRtnCount= 27920
SigmaMilliMeter= 4.73
RangeMilliMeter= -1059
RangeMinMilliMeter= -1059
RangeMaxMilliMeter= -1052
RangeStatus= 0
SignalRateRtnMegaCps= 511.99
AmbientRateRtnMegaCps= 3.30
EffectiveSpadRtnCount= 27920
SigmaMilliMeter= 1.00
RangeMilliMeter= -70
RangeMinMilliMeter= -263
RangeMaxMilliMeter= 121
RangeStatus= 0
Number of measurements = 15
Number of Objects Found = 0
RoiNumber= 0
RoiStatus= 1
Stream Count=14
DmaxMilliMeter=0
Number of measurements = 16
Number of Objects Found = 0
RoiNumber= 1
RoiStatus= 2
Stream Count=15
DmaxMilliMeter=0
Number of measurements = 17
Number of Objects Found = 3
RoiNumber= 0
RoiStatus= 1
Stream Count=16
DmaxMilliMeter=0
SignalRateRtnMegaCps= 1.39
AmbientRateRtnMegaCps= 3.56
EffectiveSpadRtnCount= 27464
SigmaMilliMeter= 15.07
RangeMilliMeter= -1825
RangeMinMilliMeter= -1825
RangeMaxMilliMeter= -1820
RangeStatus= 4
SignalRateRtnMegaCps= 5.42
AmbientRateRtnMegaCps= 3.56
EffectiveSpadRtnCount= 27464
SigmaMilliMeter= 4.82
RangeMilliMeter= -1062
RangeMinMilliMeter= -1065
RangeMaxMilliMeter= -1052
RangeStatus= 4
SignalRateRtnMegaCps= 511.99
AmbientRateRtnMegaCps= 3.56
EffectiveSpadRtnCount= 27464
SigmaMilliMeter= 1.00
RangeMilliMeter= -69
RangeMinMilliMeter= -262
RangeMaxMilliMeter= 122
RangeStatus= 4
Number of measurements = 18
Number of Objects Found = 3
RoiNumber= 1
RoiStatus= 2
Stream Count=17
DmaxMilliMeter=0
SignalRateRtnMegaCps= 1.66
AmbientRateRtnMegaCps= 3.64
EffectiveSpadRtnCount= 27920
SigmaMilliMeter= 14.32
RangeMilliMeter= -1807
RangeMinMilliMeter= -1816
RangeMaxMilliMeter= -1806
RangeStatus= 4
SignalRateRtnMegaCps= 5.69
AmbientRateRtnMegaCps= 3.64
EffectiveSpadRtnCount= 27920
SigmaMilliMeter= 4.77
RangeMilliMeter= -1053
RangeMinMilliMeter= -1056
RangeMaxMilliMeter= -1046
RangeStatus= 0
SignalRateRtnMegaCps= 511.99
AmbientRateRtnMegaCps= 3.64
EffectiveSpadRtnCount= 27920
SigmaMilliMeter= 1.00
RangeMilliMeter= -70
RangeMinMilliMeter= -263
RangeMaxMilliMeter= 121
RangeStatus= 0
Number of measurements = 19
Number of Objects Found = 0
RoiNumber= 0
RoiStatus= 1
Stream Count=18
DmaxMilliMeter=0
2020-11-06 10:51 AM
Looking at the data, I'm wondering if you don't have a byte-swap issue. Or perhaps a word swap issue.
I have a bit of code that I want you to insert and run just prior to doing an work, but after you have established communcation with the sensor.
It will prove that we don't have a communication issue.
The output should be identical - no matter if you read/write in bytes, words or longwords.
Oddly a lot of those numbers look good .
One expects the range to be between the min and max.
Can you think of a way you can byte or word swap -1053 to get whatever you think the right answer should be?
Run the enclosed code.
See if it looks right to you.
2020-11-11 03:06 AM
Hi John,
Sorry for delay. Indeed, there are some problems with byte order:
expected = 3939242239
read_multi = 234 204 16 255
read_bytes = 234 204 16 255
read words = 60108 4351
read dword = 3939242239
expected = 287454020
read_multi = 17 34 51 68
read_bytes = 17 34 51 68
read words = 4386 13124
read dword = 287454020
expected = 4293844428
read_multi = 255 238 221 204
read_bytes = 255 238 221 204
read words = 65518 56780
read dword = 4293844428
expected = 1432778632
read_multi = 85 102 119 136
read_bytes = 85 102 119 136
read words = 21862 30600
read dword = 1432778632
expected = 287454020
read_multi = 17 34 51 68
read_bytes = 17 34 51 68
read words = 4386 13124
read dword = 287454020
i2c test failed - please check it. Status = 1
My ReadMulti function looks like this:
VL53L1_Error VL53L1_ReadMulti(VL53L1_DEV Dev, uint16_t index, uint8_t *pdata,
uint32_t count) {
Wire.beginTransmission(Dev->i2c_slave_address >> 1);
Wire.write((index >> 8) & 0xff);
Wire.write(index & 0xff);
if (Wire.endTransmission() != 0) {
return VL53L1_ERROR_CONTROL_INTERFACE;
}
while (count > 0) {
uint8_t reading = Wire.requestFrom(Dev->i2c_slave_address >> 1, count);
if (reading == 0) {
return VL53L1_ERROR_CONTROL_INTERFACE;
}
count -= reading;
while (reading-- > 0) {
*pdata++ = Wire.read();
}
}
return VL53L1_ERROR_NONE;
}
So probably there is wrong assumption about Endianness somewhere in the driver code related to histogram modes?
2020-11-11 03:37 AM
Sorry, I have double checked the response, actually multi-byte responses are constructed correctly, what fails is 135 register write/read:
Status += VL53L1_WriteMulti(dev, 0x01, long_out,
135); // check if WriteMulti can write 135bytes
Status += VL53L1_ReadMulti(dev, 0x01, long_in,
135); // check if WriteMulti can read 135 bytes
for (i = 0; i < 135; i++) {
if (long_in[i] != long_out[i]) {
err_count++;
Serial.print(i);
Serial.print(": ");
Serial.print(long_out[i]);
Serial.print(" != ");
Serial.println(long_in[i]);
}
}
if (err_count > 10)
Status++;
Returns:
48: 2 != 3
63: 2 != 255
64: 0 != 255
65: 0 != 255
66: 0 != 255
67: 0 != 255
68: 0 != 255
69: 32 != 255
70: 11 != 255
71: 0 != 255
72: 0 != 255
73: 2 != 255
74: 20 != 255
75: 33 != 255
76: 0 != 255
77: 0 != 255
78: 2 != 255
79: 0 != 255
80: 0 != 255
81: 0 != 255
82: 0 != 255
83: 200 != 255
84: 0 != 255
85: 0 != 255
86: 56 != 255
88: 1 != 255
89: 0 != 255
90: 1 != 255
91: 0 != 255
92: 2 != 255
93: 0 != 255
94: 157 != 255
95: 7 != 255
96: 0 != 255
97: 210 != 255
98: 5 != 255
99: 1 != 255
100: 104 != 255
101: 0 != 255
102: 192 != 255
103: 8 != 255
104: 56 != 255
105: 0 != 255
106: 0 != 255
107: 0 != 255
108: 0 != 255
109: 3 != 255
110: 182 != 255
111: 0 != 255
112: 1 != 255
113: 0 != 255
114: 0 != 255
115: 0 != 255
116: 0 != 255
117: 0 != 255
118: 1 != 255
119: 7 != 255
120: 5 != 255
121: 6 != 255
122: 6 != 255
123: 1 != 255
124: 0 != 255
125: 2 != 255
126: 199 != 255
128: 139 != 255
129: 0 != 255
130: 0 != 255
131: 0 != 255
132: 1 != 255
133: 1 != 255
134: 64 != 255
It seems access of registers over 63 is somewhat wrong. Also note that register 48 reads wrong
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-11 07:14 AM
You know I'm wondering if its your print statements that are goofing up.
You got:
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:
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.
2020-11-12 05:36 AM
John, thanks a ton!
You are right - my I2C library buffer was 64 bytes long. As soon as I set it to 136, the sensor ranges fine!
2020-12-10 04:04 AM
Hi, I have general question about speed - in manual, there is line about timing budget which is from 20ms -> 50Hz, but there is InterMeasurement time which is needed to be at least timingBuget + 4ms so single measurement takes (timingBudget + InterMeasurementTime + 4ms) - the measurement time is in this standard approach 25Hz? I know that there is some walkaround for shorter distances but I´m trying to solve this for long range measurements.
2020-12-10 06:48 AM
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?