cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot read more than one zone with VL53L3CX

clcarrasco
Associate

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?

1 ACCEPTED SOLUTION

Accepted Solutions
John E KVAM
ST Employee

The VL53L3CX (L3) is a single zone sensor. There is no lens, so any photons that hit the sensor will be recorded, but we don't really know from where in the Field of View they come from. 

A similar sensor (VL53L1CB) does have a lens and so one can limit the field of view. Using this you can get 4 zones in 4 different ranges. The VL53L8CX can do 64 zones - but it's a lot more complex and a bit more expensive.

But looking at your code, it appears you are expecting to see 4 different targets at 4 different distances. All of them within the 27-degree field of view. And the L3 CAN do that. 

But it takes some work. 

Each target can only fill a portion of the Field of view. Clearly if the first target covers the entire FoV, there is no way to see behind it. 

But the targets have to be 80 cm apart from each other in distance. Otherwise, the histogram data is merged together, and you get one muddled target instead of 2 separate ones.

Start with something easy. Point your sensor at a wall - at about 1Meter. 

Then slowly move your hand into the field of view - at 10 or 20cm. You will see two targets. This is really handy for finding people standing in front of a wall. You get both the wall and the person. 

Getting 4 targets is mathematically possible. But I've never done it outside the lab.  Getting 4 targets that have enough reflectivity and cover a bit of the FoV without covering too much and having the right distances is a rare case. 

But two - or even 3 is doable. 

- john

 


If this or any post solves your issue, please mark them as 'Accept as Solution' It really helps. And if you notice anything wrong do not hesitate to 'Report Inappropriate Content'. Someone will review it.

View solution in original post

2 REPLIES 2
John E KVAM
ST Employee

The VL53L3CX (L3) is a single zone sensor. There is no lens, so any photons that hit the sensor will be recorded, but we don't really know from where in the Field of View they come from. 

A similar sensor (VL53L1CB) does have a lens and so one can limit the field of view. Using this you can get 4 zones in 4 different ranges. The VL53L8CX can do 64 zones - but it's a lot more complex and a bit more expensive.

But looking at your code, it appears you are expecting to see 4 different targets at 4 different distances. All of them within the 27-degree field of view. And the L3 CAN do that. 

But it takes some work. 

Each target can only fill a portion of the Field of view. Clearly if the first target covers the entire FoV, there is no way to see behind it. 

But the targets have to be 80 cm apart from each other in distance. Otherwise, the histogram data is merged together, and you get one muddled target instead of 2 separate ones.

Start with something easy. Point your sensor at a wall - at about 1Meter. 

Then slowly move your hand into the field of view - at 10 or 20cm. You will see two targets. This is really handy for finding people standing in front of a wall. You get both the wall and the person. 

Getting 4 targets is mathematically possible. But I've never done it outside the lab.  Getting 4 targets that have enough reflectivity and cover a bit of the FoV without covering too much and having the right distances is a rare case. 

But two - or even 3 is doable. 

- john

 


If this or any post solves your issue, please mark them as 'Accept as Solution' It really helps. And if you notice anything wrong do not hesitate to 'Report Inappropriate Content'. Someone will review it.
clcarrasco
Associate

Thanks! we were able to detect more than one target using your instructions.