cancel
Showing results for 
Search instead for 
Did you mean: 

VL53L3CX calibration, great difficulty

RKreh.1
Associate

I've got a custom board with the VL53L3 connected to a Silicon Labs chip. The interface to the sensor works. Saving and restoring calibration data is kicking my ***.

My calibration code makes these calls:

 GPIO_PinOutClear(VL53L3_ENBL_PORT,VL53L3_ENBL_PIN);

 vTaskDelay(2);

 GPIO_PinOutSet(VL53L3_ENBL_PORT,VL53L3_ENBL_PIN);

 vTaskDelay(2);

VL53LX_WaitDeviceBooted(Device);

VL53LX_DataInit(Device);

// start calibration here:

VL53LX_SetDistanceMode(Device, VL53LX_DISTANCEMODE_SHORT); // before calibration, eh?

VL53LX_PerformRefSpadManagement(Device);

VL53LX_PerformXTalkCalibration(Device);

VL53LX_PerformOffsetSimpleCalibration(Device, 4);

// (I have also experimented with VL53LX_PerformOffsetZeroDistanceCalibration)

After this calibration data, I print the result...

 VL53LX_CalibrationData_t calibration;

VL53LX_GetCalibrationData(Device, &calibration);

  printf("static uint8_t calibration[] = { \n ");

  uint8_t *cal = (uint8_t *)&calibration;

  const char *comma = "";

  for(uint16_t i = 0; i < sizeof(calibration); i += 16) {

   for(uint16_t j = i; j < i+16 && j < sizeof(calibration); j++) {

    printf("%s0x%2.2x", comma, (unsigned)cal[j]);

    comma = ",";

   }

   comma = ",\n ";

  }

  printf("\n};\n");

I copy that output into a calibration_data.h file.

The code continues on and starts performing ranging operations that work well. Yay!

Now, I recompile the same code and load it to the same piece of hardware, but this time instead of the calibration steps, it #includes the calibration-data.h file:

VL53LX_WaitDeviceBooted(Device);

VL53LX_DataInit(Device);

#include "calibration-data.h"

VL53LX_SetCalibrationData(Device, (VL53LX_CalibrationData_t*)&calibration);

And now - nothing works. If any measurements return anything at all, they all have non-zero RangeStatus.

What have I overlooked?

(Yesterday's behavior was also very odd, it was doggedly reporting an object at 60mm, even when nothing was there, or if the lens was totally obscured. Is my device haunted?)

This discussion is locked. Please start a new topic to ask your question.
1 REPLY 1
RKreh.1
Associate

I've made some progress.

Calling VL53LX_StopMeasurement() after DataInit and before SetCalibrationData has gotten me past a hurdle. Now, the calibrating code can test the calibration (after printing into calibration-data.h, it can #include it again, and see the device work).

I'm moving on to using this calibration-data.h in other code on this device...