cancel
Showing results for 
Search instead for 
Did you mean: 

VL53L1X(Ultra Lite Driver)- Function VL53L1X_GetRangeStatus() return values 255

YZ.2
Associate

Hello.​

I'm using VL53L1X sensor with Ultra Lite Driver (ULD).

VL53L1X_GetRangeStatus function returns all the time status 255. This value comes from the array status_rtn[1]

static const uint8_t status_rtn[24] = { 255, 255, 255, 5, 2, 4, 1, 7, 3, 0,
	255, 255, 9, 13, 255, 255, 255, 255, 10, 6,
	255, 255, 11, 12
};
 
 
VL53L1X_ERROR VL53L1X_GetRangeStatus(uint16_t dev, uint8_t *rangeStatus)
{
	VL53L1X_ERROR status = 0;
	uint8_t RgSt;
 
	*rangeStatus = 255;
	status = VL53L1_RdByte(dev, VL53L1_RESULT__RANGE_STATUS, &RgSt); //RgSt:0x01
	RgSt = RgSt & 0x1F;
	if (RgSt < 24)
		*rangeStatus = status_rtn[RgSt]; //RgSt:0x01  status_rtn[RgSt]:255
	return status;
}

and The laser doesn't work from the camera of the mobile phone​.

​What does it mean? How to solve this problem? thanks.

ps:​

there is the code about VL53L1X ​

#define NOBODY                    0
#define SOMEONE                   1
#define LEFT                      0
#define RIGHT                     1
  
#define PROFILE_STRING                               "DOOR_JAM_2400"
#define DISTANCES_ARRAY_SIZE                         5   // nb of samples
#define MAX_DISTANCE                                 1900 // mm
#define MIN_DISTANCE                                 0   // mm
#define DIST_THRESHOLD                               1600  // mm
#define ROWS_OF_SPADS                                8 // 8x16 SPADs ROI
 
 
 
#if ROWS_OF_SPADS == 4
#define FRONT_ZONE_CENTER                            151
#define BACK_ZONE_CENTER                             247
#elif ROWS_OF_SPADS == 6
#define FRONT_ZONE_CENTER                            159
#define BACK_ZONE_CENTER                             239
#elif ROWS_OF_SPADS == 8
#define FRONT_ZONE_CENTER                            175 // was 167, see UM2555 on st.com, centre = 175 has better return signal rate for the ROI #1
#define BACK_ZONE_CENTER                             231
#endif
 
 
void init:
{
while (sensorState == 0)
  {
    status = VL53L1X_BootState (dev, &sensorState);
    user_iic_delay_1u (2000);
    printf ("vl53l1x Chip booted:%d\n", status);
  }
 
  printf ("vl53l1x Chip booted\n");
 
 
  /* Initialize and configure the device according to people counting need */
  status = VL53L1X_SensorInit (dev);
  status += VL53L1X_SetInterruptPolarity (dev, 0);
  status += VL53L1X_SetDistanceMode (dev, 2); /* 1=short, 2=long */
  status += VL53L1X_SetTimingBudgetInMs (dev, 33); /* in ms possible values [15, 20, 50, 100, 200, 500] */
  status += VL53L1X_SetInterMeasurementInMs (dev, 50);
  status += VL53L1X_SetROI (dev, ROWS_OF_SPADS, 16); /* minimum ROI 4,4 */
  
  if (status != 0)
  {
    printf ("Initialization or configuration of the device\n");
    return ;
  }
  printf ("Start counting people with profile : %s...\n", PROFILE_STRING);
  status = VL53L1X_StartRanging (dev);  /* This function has to be called to enable the ranging */
}
 
 
void loop:
{
int8 status = 0;
  uint8_t dataReady = 0;
 
 
  uint16_t Distance, Signal;
  uint8_t RangeStatus;
  static int Zone = 0;
  int PplCounter;
  int center[2] = {FRONT_ZONE_CENTER, BACK_ZONE_CENTER}; /* these are the spad center of the 2 4*16 zones */
 
  VL53L1X_CheckForDataReady (dev, &dataReady);
  if (dataReady == 0) return;
 
  dataReady = 0;
  status += VL53L1X_GetRangeStatus (dev, &RangeStatus);
  status += VL53L1X_GetDistance (dev, &Distance);
  status += VL53L1X_GetSignalPerSpad (dev, &Signal);
  status += VL53L1X_ClearInterrupt (dev); /* clear interrupt has to be called to enable next interrupt*/
  if (status != 0)
  {
    printf ("Error in operating the device\n");
    return ;
  }
  //HAL_Delay(WAIT_BEFORE_PROGRAMMING_OTHER_ZONE_CENTER);  // 10, 8, 7, 6 tested OK
  status = VL53L1X_SetROICenter (dev, center[Zone]);
  if (status != 0)
  {
    printf ("Error in chaning the center of the ROI\n");
    return ;
  }
  // check the status of the ranging. In case of error, lets assume the distance is the max of the use case
  // Value RangeStatus string Comment
  // 0 VL53L1_RANGESTATUS_RANGE_VALID Ranging measurement is valid
  // 1 VL53L1_RANGESTATUS_SIGMA_FAIL Raised if sigma estimator check is above the internal defined threshold
  // 2 VL53L1_RANGESTATUS_SIGNAL_FAIL Raised if signal value is below the internal defined threshold
  // 4 VL53L1_RANGESTATUS_OUTOFBOUNDS_ FAIL Raised when phase is out of bounds
  // 5 VL53L1_RANGESTATUS_HARDWARE_FAIL Raised in case of HW or VCSEL failure
  // 7 VL53L1_RANGESTATUS_WRAP_TARGET_ FAIL Wrapped target, not matching phases
  // 8 VL53L1_RANGESTATUS_PROCESSING_ FAIL Internal algorithm underflow or overflow
  // 14 VL53L1_RANGESTATUS_RANGE_INVALID The reported range is invalid
  if ( (RangeStatus == 0) || (RangeStatus == 4) || (RangeStatus == 7))
  {
    if (Distance <= MIN_DISTANCE) // wraparound case see the explanation at the constants definition place
      Distance = MAX_DISTANCE + MIN_DISTANCE;
  }
  else {// severe error cases
    printf ("RangeStatus Error:%d[%d]\n",RangeStatus,Distance);
    Distance = MAX_DISTANCE;
  }
  // inject the new ranged distance in the people counting algorithm
  PplCounter = ProcessPeopleCountingData (Distance, Zone, RangeStatus);
//  printf ("PplCounter:%4d", PplCounter); // only use for special EVK with display
  Distance_last = Distance;
  if (Distance < MAX_DISTANCE)
    printf ("PplCounter:%d,%d,%d,%d,%d\n", PplCounter, Zone, Distance, Signal, RangeStatus);
  Zone++;
  Zone = Zone % 2;
}

2 REPLIES 2
John E KVAM
ST Employee

The sensor goes through a lot of steps to get an answer, and if any of them fail, the sensor quits and returns 255. Actually a 255 is quite rare - except for you perhaps.

Most errors are defined by the 1-8 and 14. For these the sensor gets to the end and doesn't like the data. (except for 5 - hardware fail of course.)

But to figure out what is giving you a 255, try to find a situation where the sensor works.

Does it see your hand at 20cm for instance?

Then slowly change the conditions that give you the 255 to figure out what that condition is.

good luck,

  • 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.
John E KVAM
ST Employee

Dmity -

I'm going to guess that your returns are not random, but a result of 2 things.

1) crosstalk. If you have a coverglass, photons hitting the glass and bouncing back can cause a ghost image. To fix this there is a crosstalk calibration you can use.

2) Aliasing (or wrap around). Google "Radar Aliasing" to get a good explanation. This is a problem radars systems (and ToF sensors) have been facing for decades.

The sensor tries to detect Wrap around, but it's possible in some conditions to get a false reading.

You don't have to activate the status. It's always there. You just read it.

But I'm betting you have a crosstalk issue. Read the section on calibration. It' should solve the issue.

  • 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.