2022-05-06 02:29 PM
2022-05-09 06:28 AM
Hello @Iknig.1 ,
Take a look at the following example provided under the WB Firmware Package.
This may help you.
BeST Regards,
Walid
2022-05-16 01:24 AM
Hello
The code below is the calibration code for the L1CX. It will work the same way on the L0.
int8_t VL53L1X_CalibrateOffset(uint16_t dev, uint16_t TargetDistInMm, int16_t *offset)
{
uint8_t i, tmp;
int16_t AverageDistance = 0;
uint16_t distance;
VL53L1X_ERROR status = 0;
status |= VL53L1_WrWord(dev, ALGO__PART_TO_PART_RANGE_OFFSET_MM, 0x0);
status |= VL53L1_WrWord(dev, MM_CONFIG__INNER_OFFSET_MM, 0x0);
status |= VL53L1_WrWord(dev, MM_CONFIG__OUTER_OFFSET_MM, 0x0);
status |= VL53L1X_StartRanging(dev); /* Enable VL53L1X sensor */
for (i = 0; i < 50; i++) {
tmp = 0;
while (tmp == 0){
status |= VL53L1X_CheckForDataReady(dev, &tmp);
}
status |= VL53L1X_GetDistance(dev, &distance);
status |= VL53L1X_ClearInterrupt(dev);
AverageDistance = AverageDistance + distance;
}
status |= VL53L1X_StopRanging(dev);
AverageDistance = AverageDistance / 50;
*offset = TargetDistInMm - AverageDistance;
status |= VL53L1_WrWord(dev, ALGO__PART_TO_PART_RANGE_OFFSET_MM, *offset*4);
return status;
}
Duplicate that and it will work fine.
There is some reference code in the L0 library from st.com : VL53L0X_perform_offset_calibration
Anne