2021-12-23 01:50 PM
2022-01-04 07:34 AM
In order to get the range, the histogram information is uploaded to your MCU, and some processing is done. So the data you seek is already on your host. The function is called
VL53LX_Error VL53LX_GetAdditionalData(VL53LX_DEV Dev,
VL53LX_AdditionalData_t *pAdditionalData);
But it's not quite that easy. There are 2 ranges and they toggle back an forth. One range consists of 4 bins of ambient light and 20 data bins.
The alternating range consists of 24 range bins.
Range on a flat wall print out the 24 bins, gathering the data into a spreadsheet.
You will soon figure it out.
(The two range timing have to do with a search for 'radar aliasing' effects. google it.)
And each bin is about 20cm worth of distance.
2022-01-06 06:12 PM
Can you please provide a sample project in which the above function is used. I cant figure out how to do so.
2022-01-07 08:00 AM
I used it like this:
if(pMultiRangingData->RangeData[j].RangeMilliMeter <10) {
VL53LX_GetAdditionalData(Dev,pAdditionalData);
if ((pMultiRangingData->StreamCount & 1) == 1){
for (j=4;j<24;j++){
printf("%ld,", pAdditionalData->VL53LX_p_006.bin_data[j]);
}
}else{
for (j=0;j<20;j++){
printf("%ld,", pAdditionalData->VL53LX_p_006.bin_data[j]);
}
}
printf("\n");
}
In this bit of code, I was interested in what the histogram of a very near object looked like.
If a near target, then get the additional data. Use the streamcount to determine even or odd. The first 4 bins of the odd numbered collects contain ambient light data. So you need to remove those.
Dump the data into excel and you should see it all line up.
2022-01-07 08:23 AM
How to declare the dev and padditonaldata variables? Also where should I write this code, in main.c or app_tof.c. Also what should i include as header files?
2022-01-07 08:56 AM
I did all my work in main.c
There are not so many lines that it's worth breaking out.
VL53LX_AdditionalData_t AdditionalData;
VL53LX_AdditionalData_t *pAdditionalData= &AdditionalData;
And the trouble with including snippets is that one is always leaving out the declarations.
I included my main.c if that helps.
The trouble is this is some code I hacked as an experiment. Please don't judge it too harshly.
2022-01-07 06:12 PM
Dev->I2cHandle = &hi2c1;
Dev->I2cDevAddr = 0x52;
These lines throw an error
/home/dashingzombie/Downloads/asas/Projects/NUCLEO-F401RE/Examples/53L3A2/53L3A2_SimpleRanging/Src/main.c:113:6: error: 'VL53L3CX_Object_t' {aka 'struct <anonymous>'} has no member named 'I2cHandle'
113 | Dev->I2cHandle = &hi2c1;
| ^~
/home/dashingzombie/Downloads/asas/Projects/NUCLEO-F401RE/Examples/53L3A2/53L3A2_SimpleRanging/Src/main.c:114:6: error: 'VL53L3CX_Object_t' {aka 'struct <anonymous>'} has no member named 'I2cDevAddr'
114 | Dev->I2cDevAddr = 0x52; | ^~
2022-01-10 11:30 AM
in the main.c is the line:
I2C_HandleTypeDef hi2c1;
Which defines the I2C handle.
The structure I2C_HandleTypeDef is defined in stm32F4xx_hal.i2c.h
But if you are using the F401RE, the example code provided on ST.com should just work.
that code is in: