Question
VL53L1X(Ultra Lite Driver)- Function VL53L1X_GetRangeStatus() return values 255
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;
}
