6180x TOF sensor stability/drift

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
venkys
 
Posts: 2
Joined: Thu Oct 25, 2012 5:29 pm

6180x TOF sensor stability/drift

Post by venkys »

chart of average (1000 samples) readings varying with time.
chart of average (1000 samples) readings varying with time.
6180xgraph.jpg (164.99 KiB) Viewed 158 times
Hello,

I am using an adafruit 6180x TOF sensor with the basic Adafruit sketch. The sensor is mounted on a firm aluminum base and pointed at a stationary object about 10mm away -
I ran the sensor for about 30 minutes, and plotted 1000 point averages (i.e. each output is an average of 1000 consecutive readings), and it appears that the sensor drifts slowly from a reading of 10.03 to 12.15mm over 100 readings - i.e. 100,000 samples.

I'm trying to control for distance between 0-10mm and this produces over 30% error (readings move around 3-4mm) for a stationary object. Is there a way to improve stability and/or precision. The exact number doesn't matter, but it is important that the readings are repeatable. I don't believe that the distance is changing due to environmental conditions e.g. heat.

STMicro's datasheet appears to suggest a way to adjust the SNR for more accuracy; Can you give me some pointers on how to enable that in the Adafruit 6180x library?

Thank you

Entire code for the sketch attached below.

Code: Select all

#include <Wire.h>
#include "Adafruit_VL6180X.h"

Adafruit_VL6180X vl = Adafruit_VL6180X();

void setup() {
  Serial.begin(115200);


  // wait for serial port to open on native usb devices
  while (!Serial) {
    delay(1);
  }
  
  Serial.println("Adafruit VL6180x test!");
  if (! vl.begin()) {
    Serial.println("Failed to find sensor");
    while (1);
  }
  Serial.println("Sensor found!");
}

void loop() {
//  float lux = vl.readLux(VL6180X_ALS_GAIN_5);

//  Serial.print("Lux: "); Serial.println(lux);
  
  uint8_t range = vl.readRange();
  uint8_t status = vl.readRangeStatus();
  float myrange=0.0;
for (int i=0;i<1000;i++){
  if (status == VL6180X_ERROR_NONE) {
     range = vl.readRange();
     myrange +=range;
   }
}
    //Serial.print("Range avg: "); Serial.println (myrange);  
    Serial.println (myrange/1000.0);

  // Some error occurred, print it out!
  
  if  ((status >= VL6180X_ERROR_SYSERR_1) && (status <= VL6180X_ERROR_SYSERR_5)) {
    Serial.println("System error");
  }
  else if (status == VL6180X_ERROR_ECEFAIL) {
    Serial.println("ECE failure");
  }
  else if (status == VL6180X_ERROR_NOCONVERGE) {
    Serial.println("No convergence");
  }
  else if (status == VL6180X_ERROR_RANGEIGNORE) {
    Serial.println("Ignoring range");
  }
  else if (status == VL6180X_ERROR_SNR) {
    Serial.println("Signal/Noise error");
  }
  else if (status == VL6180X_ERROR_RAWUFLOW) {
    Serial.println("Raw reading underflow");
  }
  else if (status == VL6180X_ERROR_RAWOFLOW) {
    Serial.println("Raw reading overflow");
  }
  else if (status == VL6180X_ERROR_RANGEUFLOW) {
    Serial.println("Range reading underflow");
  }
  else if (status == VL6180X_ERROR_RANGEOFLOW) {
    Serial.println("Range reading overflow");
  }
  delay(50);
}

User avatar
mikeysklar
 
Posts: 13936
Joined: Mon Aug 01, 2016 8:10 pm

Re: 6180x TOF sensor stability/drift

Post by mikeysklar »

The code example you are running is doing error checking with the SNR register.

Code: Select all

  }
  else if (status == VL6180X_ERROR_SNR) {
    Serial.print("Signal/Noise error");
  }
That is all that shows up in the library for SNR specifically.

Have you explored the GAIN settings?

Example:

https://github.com/adafruit/Adafruit_VL ... 0x.ino#L23

Code: Select all

 float lux = vl.readLux(VL6180X_ALS_GAIN_5);
Different GAIN presets:

Code: Select all

 VL6180X_ALS_GAIN_1 : Adafruit_VL6180X.h
VL6180X_ALS_GAIN_10 : Adafruit_VL6180X.h
VL6180X_ALS_GAIN_1_25 : Adafruit_VL6180X.h
VL6180X_ALS_GAIN_1_67 : Adafruit_VL6180X.h
VL6180X_ALS_GAIN_20 : Adafruit_VL6180X.h
VL6180X_ALS_GAIN_2_5 : Adafruit_VL6180X.h
VL6180X_ALS_GAIN_40 : Adafruit_VL6180X.h
VL6180X_ALS_GAIN_5 : Adafruit_VL6180X.h
https://adafruit.github.io/Adafruit_VL6 ... ml#index_s

User avatar
venkys
 
Posts: 2
Joined: Thu Oct 25, 2012 5:29 pm

Re: 6180x TOF sensor stability/drift

Post by venkys »

I ignored those thinking they were related to the ambient light sensor, but perhaps they are connected.

I'll test and post back..

User avatar
mikeysklar
 
Posts: 13936
Joined: Mon Aug 01, 2016 8:10 pm

Re: 6180x TOF sensor stability/drift

Post by mikeysklar »

Actually I think you are right. The GAIN sensors are ALS (ambient light sensor specific).

https://learn.adafruit.com/adafruit-vl6 ... 2118587-24

Maybe look into range_status?

Code: Select all

print('Range status: {0}'.format(sensor.range_status))
range_status Property - This property returns any error or issues that was encountered while reading the range. You can compare against a few global values to see what might have occured. Check the datasheet for more details about these error cases and how to resolve them:
adafruit_vl6180x.ERROR_NONE
adafruit_vl6180x.ERROR_SYSERR_1
adafruit_vl6180x.ERROR_SYSERR_5
adafruit_vl6180x.ERROR_ECEFAIL
adafruit_vl6180x.ERROR_NOCONVERGE
adafruit_vl6180x.ERROR_RANGEIGNORE
adafruit_vl6180x.ERROR_SNR
adafruit_vl6180x.ERROR_RAWUFLOW
adafruit_vl6180x.ERROR_RAWOFLOW
adafruit_vl6180x.ERROR_RANGEUFLOW
adafruit_vl6180x.ERROR_RANGEOFLOW

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”