cancel
Showing results for 
Search instead for 
Did you mean: 

VL6180X -- How to achieve a 100 Hz sample rate?

Kurt-123
Associate II

I have a VL6180X that I am running in continuous measurement mode and read from when a hardware interrupt is triggered by the senor. My issue is that I cannot get the sensor to signal at a rate of 100 Hz. Currently, the best I can achieve is 50 Hz.

Has anyone had success with this?

I have read that tweaking the inter-measurement and max convergence times can help, but I am not sure where to start with those values. Any advice would be greatly appreciated 🙂

Also, within the VL6 API, I noticed that the `VL6180x_RangeSetInterMeasPeriod()` function has the following code block:

/* doc in not 100% clear and confusing about the limit practically all value are OK but 0
 * that can hang device in continuous mode */
 
if (InterMeasTime_msec < 10) {
    InterMeasTime_msec = 10;
}

This block appears to hard limit the inter-measurement time. Commenting out this check and setting `InterMeasTime_msec=0` helps with reaching 100 Hz, but makes the sensor prone to crashing. Does anyone know why this check exists?

1 ACCEPTED SOLUTION

Accepted Solutions
John E KVAM
ST Employee

Try changing those 10's to 5's as in

if (InterMeasTime_msec < 5) {
    InterMeasTime_msec = 5;

There is also an 'averaging' register - put that at mimium.

VL6180_WrByte(dev, 0x010a, 0x30); /* Set the averaging sample period (compromise between lower noise and increased execution time) */

6.2.44 READOUT__AVERAGING_SAMPLE_PERIOD

 readout__averaging_sample_period: The internal readout averaging sample period can be adjusted from 0 to 255. Increasing the sampling period decreases noise but also reduces the effective max convergence time and increases power consumption: Effective max convergence time = max convergence time - readout averaging period (see Section 2.6: Range timing). Each unit sample period corresponds to around 64.5 µs additional processing time. The recommended setting is 48 which equates to around 4.3 ms.

So you are spend 4.3ms averaging - which is killing your rate. Cut that in half.


In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question. It helps the next guy.

View solution in original post

3 REPLIES 3
John E KVAM
ST Employee

Try changing those 10's to 5's as in

if (InterMeasTime_msec < 5) {
    InterMeasTime_msec = 5;

There is also an 'averaging' register - put that at mimium.

VL6180_WrByte(dev, 0x010a, 0x30); /* Set the averaging sample period (compromise between lower noise and increased execution time) */

6.2.44 READOUT__AVERAGING_SAMPLE_PERIOD

 readout__averaging_sample_period: The internal readout averaging sample period can be adjusted from 0 to 255. Increasing the sampling period decreases noise but also reduces the effective max convergence time and increases power consumption: Effective max convergence time = max convergence time - readout averaging period (see Section 2.6: Range timing). Each unit sample period corresponds to around 64.5 µs additional processing time. The recommended setting is 48 which equates to around 4.3 ms.

So you are spend 4.3ms averaging - which is killing your rate. Cut that in half.


In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question. It helps the next guy.

Hi John! Thanks for your reply! I will test it out and report back ASAP.

Hi John, thanks again for your advice! I am able to hit 100 Hz! You've helped me solve my sampling rate issue.

However, this has led me to follow up issue that I would really appreciate your thoughts on, too.

I am having an issue where my VL6180x appears to "crash" occasionally. For context, I am running the VL6 in continuous mode and use interrupts to inform my firmware that a new reading is ready. Each time I read, I clear the VL6 interrupt using `VL6180x_ClearAllInterrupt()`. Yet, after a seemingly random period, the VL6 fails to generate another interrupt. After a timeout delay (configured by me), my firmware re-initializes the VL6 completely and capturing continues until the next random "crash".

Do you have any thoughts as to what might be happening here?