VL6180X NOISE ISSUE

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
BenCCFC27
 
Posts: 6
Joined: Thu Feb 15, 2018 3:53 am

VL6180X NOISE ISSUE

Post by BenCCFC27 »

Hello,

I am experiencing some issues with noise on the output from my VL6180X set up. The current set up I have is the VL6180X sensor connected into the Feather 32u4 Basic Proto and Featherwing OLED display. The code i have uploaded is the vl6180x_oled example that is supplied in the software and recommended in the set up notes.

The issue i am having is that when i set the distance to a set point, say 60mm, i'm seeing noise ranging from 57mm to 63mm. I have tried many variations in target colour and material and it doesn't seem to have any effect. I believe this issue could be resolved if i was able to take an average of these points during my measurements. I will add that i have no previous experience of using or modifying C code, only what i have done to get this board working and what i have read in your tutorials.

My question is, is there any code available or a modification that can be made to the code i'm currently using that will allow me to average these values or apply some smoothing to my output signal? Or anything else you could suggest?

Thank you in advance for any help you can provide.

User avatar
adafruit_support_carter
 
Posts: 29168
Joined: Tue Nov 29, 2016 2:45 pm

Re: VL6180X NOISE ISSUE

Post by adafruit_support_carter »

Here's an example of simple averaging. Change this line:

Code: Select all

uint8_t range = vl.readRange();
to this:

Code: Select all

int avg_count = 10   // number of samples to average
int avg_range = 0
for (int i=0; i<avg_count; i++) {
  avg_range += vl.readRange();
  // might want to add some delay here
}
avg_range /= avg_count;
uint8_t range = avg_range;

User avatar
BenCCFC27
 
Posts: 6
Joined: Thu Feb 15, 2018 3:53 am

Re: VL6180X NOISE ISSUE

Post by BenCCFC27 »

That's brilliant. Just what i needed!

Thank you for your help

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

Return to “Arduino”