Skip to main content
Kurt-123
Associate II
November 8, 2022
Solved

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

  • November 8, 2022
  • 1 reply
  • 2656 views

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?

This topic has been closed for replies.
Best answer by John E KVAM

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.

1 reply

John E KVAM
John E KVAMBest answer
ST Employee
November 8, 2022

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.

Kurt-123
Kurt-123Author
Associate II
November 14, 2022

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