VL6180X -- Unstable inter-measurement period in continuous mode
- November 22, 2022
- 3 replies
- 2060 views
Hi everyone,
I am facing a problem where my VL6180X hangs indefinitely until reset after a seemingly random period of time. The sensor runs in continuous mode and samples at 100 Hz (thanks to this post).
I configure the sensor by setting the SYSRANGE_INTERMEASUREMENT_PERIOD and READOUT_AVERAGING_SAMPLE_PERIOD registers (see code example). The SYSRANGE_INTERMEASUREMENT_PERIOD seems to be where the problem lies. If I set this register to 0x0, then the sensor will eventually hang. If I set it to 0x1, the sensor will not hang, but my sampling frequency will be significantly reduced. However, the datasheet states that [0-254] is the acceptable range of values for this register (see datasheet image); so, 0x0 shouldn't be a problem.
Additionally, matters become more confusing when you look at the VL6180X API (see code screenshot). The input variable `InterMeasTime_msec` is bounded to at least 10 milliseconds. This means that `SetTime`, and therefore the inter-measurement register, will always be at least 1. The code comment (not written by me) in that screenshot points out that the "hanging" is a known issue.
So, is the datasheet wrong? Can the SYSRANGE_INTERMEASUREMENT_PERIOD only handle [1-254]? Or, am I missing something in my setup?
While I can handle the "hanging" as an error and reset the VL6, I'd rather not have sensor the down time be an acceptable component of my system.
Thank you for reading this post! I would greatly appreciate any help on this. :)
VL6180x_WrByte(vl6I2C, SYSRANGE_INTERMEASUREMENT_PERIOD, 0x0); // Set intermeasurement period to 10 ms
VL6180x_WrByte(vl6I2C, READOUT_AVERAGING_SAMPLE_PERIOD, 0x18); // Cut the recommended averaging time in half