cancel
Showing results for 
Search instead for 
Did you mean: 

VL53L1 erroneously reports valid data for some time after target is removed.

wild
Associate II

Greetings.

I am using the VL53L1CB and I am seeing it report valid range data when it shouldn’t.

I place a target in front of the VL53L1CB and it reports the distance to the target without any problems. However, when I remove the target and the VL53L1CB points off into an out-of-range distance, it will continue to report the same value for a while before it decides that it can no longer acquire the range (i.e. rangeData.RangeStatus is still reporting success after the target is removed).

This duration of this behavior seems to be dependent on what is behind the target.

Is there a way to always immediately report when the target has been removed?

Thank you

Scott Wild

This is the data I'm seeing. Note that I remove the target at 3.2 seconds.

0693W000008yc8ZQAQ.png 

Here is my sampling code (note: I updated the code snippet by adding the ROI setting code because it seems to make the problem easier to duplicate)

VL53L1_software_reset( &vl53l1Dev );
    VL53L1_DataInit( &vl53l1Dev );
    VL53L1_StaticInit( &vl53l1Dev );
    VL53L1_SetPresetMode( &vl53l1Dev, VL53L1_PRESETMODE_RANGING );
    VL53L1_SetDistanceMode( &vl53l1Dev, VL53L1_DISTANCEMODE_MEDIUM );
 
    // Move ROI higher to reduce reflections from the floor
    VL53L1_RoiConfig_t roiConfig;
    roiConfig.NumberOfRoi = 1;
    roiConfig.UserRois[0].TopLeftX = 6;
    roiConfig.UserRois[0].TopLeftY = 15;
    roiConfig.UserRois[0].BotRightX = 9;
    roiConfig.UserRois[0].BotRightY = 12;
    VL53L1_SetROI(&vl53l1Dev, &roiConfig);
 
    while (1)
    {
        // If we're not taking a reading, start a measurement
        if( !takingReading )
        {
            if( VL53L1_ClearInterruptAndStartMeasurement( &vl53l1Dev ) == 0 )
                takingReading = true;
            else
                range = 0;
        }
        else // Waiting for a reading to complete
        {
            // If the reading has completed
            uint8_t ready = 0;
            VL53L1_GetMeasurementDataReady( &vl53l1Dev, &ready );
            if( ready )
            {
                VL53L1_RangingMeasurementData_t rangeData;
                if( VL53L1_GetRangingMeasurementData( &vl53l1Dev, &rangeData ) == 0 )
                {
                    // If the sensor chip returned a valid value
                    if( rangeData.RangeStatus == 0 )
                        range = rangeData.RangeMilliMeter;
                    else
                        range = 0;
                }
                else
                    range = 0;
 
                takingReading = false;
            }
        }
    }

1 REPLY 1
wild
Associate II

The solution to this problem turned out to be checking the RangeQualityLevel as well.

                VL53L1_RangingMeasurementData_t rangeData;
                if( VL53L1_GetRangingMeasurementData( &vl53l1Dev, &rangeData ) == 0 )
                {
                    // If the sensor chip returned a valid value
                    if( rangeData.RangeStatus == 0 && rangeData.RangeQualityLevel != 0 )
                        range = rangeData.RangeMilliMeter;
                    else
                        range = 0;
                }