cancel
Showing results for 
Search instead for 
Did you mean: 

VL6180X -- Unstable inter-measurement period in continuous mode

Kurt-123
Associate II

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

3 REPLIES 3
John E KVAM
ST Employee

The VL6180 works differently from our other sensors. It collects photons until it has enough and then returns an answer. (The other sensors use as much time as you allow.)

So if one is looking at a bright target it won't take long, but if one is looking at a dull target it might take up to 10ms to get an answer.

The intermeasurement period was an attempt to slow the senor down and get results in a more even clock.

I would try an experiment - simply don't set the IM. See if that works for you.

And I do like your reduction of the averaging period.

  • john


Our community relies on fruitful exchanges and good quality content. You can thank and reward helpful and positive contributions by marking them as 'Accept as Solution'. When marking a solution, make sure it answers your original question or issue that you raised.

ST Employees that act as moderators have the right to accept the solution, judging by their expertise. This helps other community members identify useful discussions and refrain from raising the same question. If you notice any false behavior or abuse of the action, do not hesitate to 'Report Inappropriate Content'
Kurt-123
Associate II

Thanks for the insight, John!

So, to check my understanding, does the VL6180 hang if the intermeasurement period expires before the sensor can collect enough photons to perform a measurement?

John E KVAM
ST Employee

Kurt -

The sensor should never hang. But clearly someone noticed it did and provided a work-around.

If you have a 10ms timing budget the sensor will return after 10ms - and if it did not get enough photons, you will get a 'no target' status return. If it gets lots of photons, it might return a distance in 5ms.

and then immediately start another range.

The setting of the intermeasurement period was to say - don't start again until after 10ms since the last start.

But somehow there is a hole - and you say it hangs.

At this point we are just looking to find solutions to the hang.

Keep in mind that the hang might also occur if there is a glitch on the XShut line. Make sure that line is well protected from noise.


Our community relies on fruitful exchanges and good quality content. You can thank and reward helpful and positive contributions by marking them as 'Accept as Solution'. When marking a solution, make sure it answers your original question or issue that you raised.

ST Employees that act as moderators have the right to accept the solution, judging by their expertise. This helps other community members identify useful discussions and refrain from raising the same question. If you notice any false behavior or abuse of the action, do not hesitate to 'Report Inappropriate Content'