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

Inconsistent Measurement Timing with VL53L1X in Continuous Mode #28

Open
MartinR3924 opened this issue Sep 2, 2024 · 1 comment
Open

Comments

@MartinR3924
Copy link

I'm using the VL53L1X sensor with the following configuration in continuous mode:

sensor.setDistanceMode(VL53L1X::Long);
sensor.setMeasurementTimingBudget(50000);
sensor.startContinuous(50);
I tried adjusting the settings as follows:

sensor.setDistanceMode(VL53L1X::Short);
sensor.setMeasurementTimingBudget(20000);
sensor.startContinuous(20);
However, I noticed that the sensor's readings do not occur every 20ms as expected but instead take longer, approximately 30ms. I’ve verified that the startContinuous() period is at least as long as the timing budget, but the issue persists.

Question:

Is there any additional configuration I need to set to ensure the measurements occur exactly at the specified intervals, or is there an inherent limitation in the timing precision of the sensor?

@kevin-pololu
Copy link
Member

Hello,

I was able to reproduce some similar behavior to what you described; with your settings, I got a reading roughly every 20 ms when there was nothing in front of the sensor, but when there was something that it could detect, the interval would often double to closer to 40 ms.

There is a discussion on the ST community site with a lot of good information about setting up consistent fast readings. This library sets up the sensor to use the LOWPOWER_AUTONOMOUS preset mode, and in that mode, John Kvam recommends using an inter-measurement period (the value passed to startContinuous() in our library) of at least 5 ms longer than the timing budget. So using startContinuous(25) seems to work and consistently give me readings every 25 ms. Or if you really need readings every 20 ms, it also seems to work if I do setMeasurementTimingBudget(15000) and startContinuous(20), even though 15 ms is below the supposed minimum timing budget of 20 ms .

John recommends using the LITE_RANGING preset mode for predictable timing, but unfortunately this library does not support any preset modes other than LOWPOWER_AUTONOMOUS. If you want to look into that configuration, you might consider trying the full ST VL53L1X API instead of this library; we have an example implementation for Arduino.

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

2 participants