0

Accuracy VL6180x - PID 3316
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Accuracy VL6180x - PID 3316

by buttlumpy on Wed Jun 14, 2017 5:36 pm

Been having real issues with the accuracy of the VL6180x. Reading directly. Tried about everything. I have two sensors. App notes pg 11 shows 1:1 measurement.

I get a nonlinear curve, different for each sensor

Actual (in) Sensor 1 Sensor 2
0.5 0.55 0.31
1 1.06 0.94
1.5 1.54 1.5
2 1.97 2.05
2.5 2.44 2.54
3 2.83 2.99
3.5 3.2 3.46
4 3.5 3.9

consistently. Table figures have variance +/- 0.05 in. Same one day to the next. Tried writing 0xFF to the averaging sample period register.

This is killing me! I've pored over the data sheet and app notes. Performance specs on pg 35 of data sheet state noise 2.0 mm. Drift/offset not the problem here.

Help!

Thanks,
Jeff
buttlumpy
 
Posts: 7
Joined: Thu Nov 01, 2012 1:59 pm

Re: Accuracy VL6180x - PID 3316

by adafruit_support_carter on Thu Jun 15, 2017 1:09 pm

Can you post a photo of your setup showing how these are being used.

adafruit_support_carter
 
Posts: 3157
Joined: Tue Nov 29, 2016 2:45 pm

Re: Accuracy VL6180x - PID 3316

by buttlumpy on Thu Jun 15, 2017 1:29 pm

Reflectance of target shown is 0.6. I've also tried another ~0.8

I'm reading the RESULT_RANGE_VAL register directly -- in mm (then converting to in). Offset is not the problem as I am getting nonlinear results.

Thank you so much for the help.
Attachments
20170615_121906.jpg
20170615_121906.jpg (896.5 KiB) Viewed 221 times
buttlumpy
 
Posts: 7
Joined: Thu Nov 01, 2012 1:59 pm

Re: Accuracy VL6180x - PID 3316

by buttlumpy on Thu Jun 15, 2017 1:37 pm

skew2.jpg
skew2.jpg (39.95 KiB) Viewed 219 times
skew1.jpg
skew1.jpg (34.66 KiB) Viewed 219 times
I know the mounting of one of them seems a bit crooked, but the tilt is less than 5 degrees, which should give a linear skew of about only 0.4%

I'm not just using the grid to calibrate, also using a caliper to confirm.

Results are consistent from trial to trial.

Error is different (but repeatable) for each of the two sensors.

In figures, one chart is for sensor1 and the other is for sensor2. Repeatable results.
buttlumpy
 
Posts: 7
Joined: Thu Nov 01, 2012 1:59 pm

Re: Accuracy VL6180x - PID 3316

by adafruit_support_carter on Thu Jun 15, 2017 2:02 pm

I'm reading the RESULT_RANGE_VAL register directly

Why this vs. using the library function readRange() ?

adafruit_support_carter
 
Posts: 3157
Joined: Tue Nov 29, 2016 2:45 pm

Re: Accuracy VL6180x - PID 3316

by buttlumpy on Thu Jun 15, 2017 2:39 pm

That's exactly what the readRange() function in Adafruit_VL6180X.cpp does:

>> read range in mm
>> uint8_t range = read8(VL6180X_REG_RESULT_RANGE_VAL);

I included that in the post just to confirm that I'm reading the VL6180x's calibrated result, not the raw result.

I've tried two different libraries for this chip, and both have the exact same skewed results.
both libraries read the same RESULT_RANGE_VAL register from the VL6180x
so it isn't that. The chip itself is sending back wrong range data. Datasheets claim that the result should be linear with possible offset.

This can't be an Adafruit thing... the chip itself is sending back this data. (On both boards)
buttlumpy
 
Posts: 7
Joined: Thu Nov 01, 2012 1:59 pm

Re: Accuracy VL6180x - PID 3316

by adafruit_support_carter on Thu Jun 15, 2017 2:54 pm

The readRange() function does a little more than just returning the register value:
https://github.com/adafruit/Adafruit_VL ... X.cpp#L128
Don't know for sure, but wondering if just reading register directly might be causing the issue. I'm guessing this isn't it, but just for the sake of testing, what do you get if you use readRange()?

adafruit_support_carter
 
Posts: 3157
Joined: Tue Nov 29, 2016 2:45 pm

Re: Accuracy VL6180x - PID 3316

by buttlumpy on Thu Jun 15, 2017 3:13 pm

I have tried readRange() from the Adafruit library. This is what I was using at first when I saw the problem. readRange() gives the results I listed.

I tried another library out there for this chip... got the same numbers/values.

I tried doing it manually myself reading that register. Yes, there was more to it than that. I sent a read request, checked the interrupt, etc... then read the register.

I did it these three different ways to try to eliminate any error on the programming side. But no -- the numbers the chip sends back are skewed and repeatable.

I just wanted to know if there was anyone out there who has used this chip/board and gotten either skewed or good results. Maybe there is something I'm missing. But I've pored over the datasheets and tried everything I could.

Has anyone at Adafruit tried out this sensor and calibrated it? Not a hard test. Just put the object at 1 in, 2 in, 3 in, etc and see what the results are.

I've gotta be doing something wrong and this is driving me crazy.

Thanks so much for your help.

Jeff
buttlumpy
 
Posts: 7
Joined: Thu Nov 01, 2012 1:59 pm

Re: Accuracy VL6180x - PID 3316

by adafruit_support_carter on Thu Jun 15, 2017 8:41 pm

Just ran a quick test. See photo for general setup. Lighting during readings was generally as you see in photo. I got very linear results:
ACTUAL (mm) READING (mm)
10 13
20 23
30 33
40 43
50 53
60 63
70 73
80 83
90 93
100 103

The 3mm offset could be from crudeness of setup. I did note a variance of several mm in the reading. Could've been because target was hand held or something else. But the average reading ended being as shown.

Here's my test code:
Code: Select all | TOGGLE FULL SIZE
#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_mm = vl.readRange();
  uint8_t status = vl.readRangeStatus();

  // convert to inches
  float range_in = range_mm / 25.4;

  if (status == VL6180X_ERROR_NONE) {
    //Serial.print("Range: "); Serial.println(range);
    Serial.print(range_in); Serial.print("in    ");
    Serial.print(range_mm); Serial.print("mm");
    Serial.println();   
  }

  // 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(1000);
}


vl6180x_test.jpg
vl6180x_test.jpg (269.68 KiB) Viewed 165 times

adafruit_support_carter
 
Posts: 3157
Joined: Tue Nov 29, 2016 2:45 pm

Re: Accuracy VL6180x - PID 3316

by buttlumpy on Thu Jun 15, 2017 8:57 pm

Carter,

Thanks so much. I really appreciate you setting up your own test. That's great service!

I'm just going to re-do the whole thing, try your code, etc. I don't know what I'm doing wrong. Going to try different ambient light conditions.

Thanks again for the help. I'm just glad the sensor can work for someone. Just not me for the time being :(

That 3 mm displacement is to be expected and can be calibrated out. As long as it is consistent, no problem.

Thank you again.

Jeff
buttlumpy
 
Posts: 7
Joined: Thu Nov 01, 2012 1:59 pm

Re: Accuracy VL6180x - PID 3316

by buttlumpy on Tue Jul 18, 2017 1:42 pm

As an update to all this, I just wanted to put this out to the community.

I've worked with these sensors for a while. They are great for some things. But don't expect accuracy of better than 2-3 mm. The resolution is 1 mm, but the output, even when stationary, as a standard deviation of ~3 mm.

I don't know how Carter got such great results, but after 12 hours of messing with 3 different ones of these, I still got the fluctuations and worse accuracy. I watched several YouTube videos and others are getting the same fluctuations as me.

One suggestion -- these are dependent on the object detected and the geometry. Early on I was getting worse results because the sensor was low to the surface. When I brought the sensor up about 1 cm from the surface, it performed better (but not great). I also found that larger targets work better than small. So those are my only two suggestions if you are having trouble.

If someone out there gets reliable, accurate measurements (standard offset ok), please let me know. I'm developing a product and we had to go with a $150 sensor instead.

So -- these are great, great, great if 3 mm accuracy is ok... but just because the resolution is 1 mm, don't think that you'll get that accuracy. There are tons of applications for which this chip is awesome. It is just that I was trying to make a measurement device, and it didn't have the tolerance I needed.

I'm not knocking the product -- great for many things.

Thanks to Carter for all the help with this. I just couldn't get the same results no matter what I tried.
buttlumpy
 
Posts: 7
Joined: Thu Nov 01, 2012 1:59 pm

Re: Accuracy VL6180x - PID 3316

by adafruit_support_carter on Tue Jul 18, 2017 2:02 pm

I don't know how Carter got such great results,

OK. I maybe cheated a little. I also mentioned seeing some fluctuations in the readings when I did my experiment and ended up taking what I considered an average value. I just did this on the fly for the experiment I ran in this thread, but implementing something like that in code could possibly provide better results.

these are dependent on the object detected and the geometry.

Yep, makes sense given how they work. There's a diagram in the datasheet that shows the sensing "cone". It's not just a laser thin straight line.

Thanks for sharing your info!

adafruit_support_carter
 
Posts: 3157
Joined: Tue Nov 29, 2016 2:45 pm

Please be positive and constructive with your questions and comments.