2024-09-13 10:49 AM
Hello,
We have been using multiple VL53L3CX sensors for some time but only using one zone. Now, we want to use all four of them but we are running into some issues: Specifically, we can only read one zone while the rest all return status 255. In addition to this, only one object is found which makes sense considering the status. But, as said before, we need to use all the zones. The issue that we have is very similar to this thread but sadly it was not solved. So, is there any procedure, configuration or calibration that we need to do before attempting to use the rest of the zones?
Our setup consist of an Arduino Due connected to the sensor and we do the following to initialize it:
(void)VL53LX_WaitDeviceBooted(&dev);
(void)VL53LX_DataInit(&dev);
(void)VL53LX_SetDeviceAddress(&dev, address);
Then, to get the measurements the following is done:
ToFLateralStartNext(&ToFLat2_t);
ToFGetLateralMeasurement(&ToFLat2_t, 2);
Where
void ToFLateralStartNext(ToFLat_t *tof_t){
tof_t->tof.startNextMeasurement();
}
void ToFGetLateralMeasurement(ToFLat_t *tof_t, uint8_t tof_number){
if (tof_t->tof.dataIsReady()){
tof_t->prev_measurement = tof_t->measurement;
tof_t->prev_status = tof_t->status;
// Get the last measurement result and trigger a new measurement
tof_t->tof.getMeasurmentData(&(tof_t->measurement));
//tof_t->tof.startNextMeasurement();
if (tof_t->measurement.numObjs < 1){
if (debug){
SerialUSB.print("TOF ");
SerialUSB.print(tof_number);
SerialUSB.println(" Status: No objects found");
}
tof_t->status = TOF_NO_OBJECTS_FOUND;
}
else{
tof_t->status = TOF_OK;
uint8_t i = 0;
Serial.print("OBJECTS FOUND: ");
Serial.println(tof_t->measurement.numObjs);
Serial.println("PRINTING MEASUREMENT STATUS ");
for(i=0; i<VL53LX_MAX_RANGE_RESULTS; i++){
Serial.print(tof_t->measurement.rangeData[i].RangeStatus);
Serial.print(" ");
if (tof_t->measurement.rangeData[i].Range < 0){
tof_t->measurement.rangeData[i].Range = 0;
}
}
// Serial.println("DONE ");
if (debug){
SerialUSB.print("TOF ");
SerialUSB.print(tof_number);
SerialUSB.print(" Status: OK ");
SerialUSB.print("Distance: ");
SerialUSB.println(tof_t->measurement.rangeData[0].Range);
}
}
}
}
And
bool VL53L3CX::dataIsReady()
{
uint8_t ready = false;
(void)VL53LX_GetMeasurementDataReady(&dev, &ready);
return (ready != 0);
}
VL53LX_Error VL53L3CX::getMeasurmentData(MeasurmentResult *pResult)
{
VL53LX_MultiRangingData_t rangingData;
VL53LX_Error status = VL53LX_ERROR_INVALID_PARAMS;
if (pResult != NULL)
{
pResult->numObjs = 0;
status = VL53LX_GetMultiRangingData(&dev, &rangingData);
if (status == VL53LX_ERROR_NONE)
{
pResult->numObjs = rangingData.NumberOfObjectsFound;
for(int i=0; i<VL53LX_MAX_RANGE_RESULTS; i++)
{
pResult->rangeData[i].AmbientRate = (float)rangingData.RangeData[i].AmbientRateRtnMegaCps / 65536.0;
pResult->rangeData[i].Range = rangingData.RangeData[i].RangeMilliMeter;
pResult->rangeData[i].RangeMax = rangingData.RangeData[i].RangeMaxMilliMeter;
pResult->rangeData[i].RangeMin = rangingData.RangeData[i].RangeMinMilliMeter;
pResult->rangeData[i].Sigma = (float)rangingData.RangeData[i].SigmaMilliMeter / 65536.0;
pResult->rangeData[i].SignalRate = (float)rangingData.RangeData[i].SignalRateRtnMegaCps / 65536.0;
pResult->rangeData[i].RangeStatus = rangingData.RangeData[i].RangeStatus;
}
}
}
return status;
}
We are also certain that I2C is working since the measurements for the zone that works is correct, for example it returns:
507, 0, 0, 0
504, 0, 0, 0
503, 0, 0, 0
While the status are:
0, 255, 255, 255
And so on.
Could you help us with this issue?