Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Annoying Reading After Out of Range #57

Open
matriawan opened this issue Aug 14, 2022 · 12 comments
Open

Annoying Reading After Out of Range #57

matriawan opened this issue Aug 14, 2022 · 12 comments

Comments

@matriawan
Copy link

matriawan commented Aug 14, 2022

I use example code and everything works fine, but when I put the sensor without a barrier or to get out of range, the output from Arduino Serial Monitoring sometime shows random numbers such as 2mm or 4mm. How to solve this, just make sure the result/output is always out of range not random numbers.

@fafiunal
Copy link

fafiunal commented Aug 31, 2022

i am having the same problems. I use a protective glass as an extra. I occasionally read absurd values when the sensor is out of range. @matriawan

@caternuson
Copy link
Contributor

Which example code is being run? Is RangeStatus being checked?

@fafiunal
Copy link

fafiunal commented Sep 1, 2022

I use interrupt example with NEW_MEASURE_READY. I am checking RangeStatus variable, when i measure distance.

When I occasionally read absurd values, ,I observe that range status is 2(Signal Fail). @caternuson @matriawan

@fafiunal
Copy link

fafiunal commented Sep 1, 2022

Specially, . I tested the sky distance :) .(No target) I occasionally read absurd values in this state. I fixed as controlling the LimitCheckValue. But, I can not measure max distance in datasheet value becasue of limitCheckCurrentValue.

Is it correct that the sensor gives absurd values when there is no target? @caternuson @matriawan

@caternuson
Copy link
Contributor

When I occasionally read absurd values, ,I observe that range status is 2(Signal Fail).

Only occasionally? Sometimes you get absurd values with a range status that is OK?

@fafiunal
Copy link

fafiunal commented Sep 4, 2022

Sorry for my late response.

Yes occasionally.

I get absurd values with range status that is "2" or "4".
You can say that you can read measurement when a range status is "0". But, After 200mm, range status is changed from "0 " to "2" by sensor. 200mm measured distance is not enough for me. :) @caternuson @matriawan

@caternuson
Copy link
Contributor

The example sketches may not fully cover all possible failure cases. For example, the interrupt example only checks for phase failures:

if (measure.RangeStatus != 4) { // phase failures have incorrect data

In general, if the status is anything other than valid, then the measurement should be considered incorrect. Various things can cause this. The status code helps indicate why.

2 = Signal Fail
4 = Phase Fail

@fafiunal This could be related to your use of cover glass.

@matriawan Are you using a cover glass of some kind? What is the target object? What are the ambient lighting conditions?

@viktak
Copy link

viktak commented May 21, 2024

@fafiunal
Having a behavior here too...:
In my case, even when the status code is 2, the measured distance is still correct. However, the device seems to be measuring distances only up to ~ 1300mm
Have you figured how to fix/work around this?

@caternuson
Copy link
Contributor

A status code of 2 is a signal fail, so the reading would not be correct in that case. Only a status code of 0 is valid.

VL53L0X_Error VL53L0X_get_range_status_string(uint8_t RangeStatus,
char *pRangeStatusString) {
VL53L0X_Error Status = VL53L0X_ERROR_NONE;
LOG_FUNCTION_START("");
switch (RangeStatus) {
case 0:
VL53L0X_COPYSTRING(pRangeStatusString,
VL53L0X_STRING_RANGESTATUS_RANGEVALID);
break;
case 1:
VL53L0X_COPYSTRING(pRangeStatusString, VL53L0X_STRING_RANGESTATUS_SIGMA);
break;
case 2:
VL53L0X_COPYSTRING(pRangeStatusString, VL53L0X_STRING_RANGESTATUS_SIGNAL);
break;
case 3:
VL53L0X_COPYSTRING(pRangeStatusString, VL53L0X_STRING_RANGESTATUS_MINRANGE);
break;
case 4:
VL53L0X_COPYSTRING(pRangeStatusString, VL53L0X_STRING_RANGESTATUS_PHASE);
break;
case 5:
VL53L0X_COPYSTRING(pRangeStatusString, VL53L0X_STRING_RANGESTATUS_HW);
break;
default: /**/
VL53L0X_COPYSTRING(pRangeStatusString, VL53L0X_STRING_RANGESTATUS_NONE);
}
LOG_FUNCTION_END(Status);
return Status;
}

@viktak
Copy link

viktak commented May 24, 2024

@caternuson I understand the concept :) but experiments show, that as long as the distance is under 1300mm, the measurement is correct, even if the status code is 2 (300-1300mm).
Could it be because of a (faulty) sensor? I'll try it later...

@caternuson
Copy link
Contributor

caternuson commented May 24, 2024

It could be for many reasons. Target size. Target color. Ambient lighting conditions. Sensor settings. etc.

Keep in mind the sensor has a field of view of 25deg on the range sensing element:
image
That equates to an object size of over 500mm at a distance of 1300mm, and over 800mm at the 2000mm full range.

In terms of sensor setting, these are the options:

/** Sensor configurations */
typedef enum {
VL53L0X_SENSE_DEFAULT = 0,
VL53L0X_SENSE_LONG_RANGE,
VL53L0X_SENSE_HIGH_SPEED,
VL53L0X_SENSE_HIGH_ACCURACY
} VL53L0X_Sense_config_t;

which have different trade offs in performance:
image
Only the long range mode provides sensing beyond 1200mm, and has caveats of being in dark conditions without any infrared (IR) sources.

It is probably worth reading through the datasheet and other documents to verify the sensor is being configured and used correctly for your application:
https://www.st.com/en/imaging-and-photonics-solutions/vl53l0x.html#documentation

In general, these issues do not sound like library code issues.

@viktak
Copy link

viktak commented May 24, 2024

@caternuson Thank you for all the info you mention, I appreciate it!
I didn't think for a moment it was a library issue (I checked the source code before coming here) - I only came here to see if others have encountered the same thing.
Thanks again for your efforts!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants