cancel
Showing results for 
Search instead for 
Did you mean: 

Why are the ranging results of different VL6180X-Sensors so extremely deviating?

Hanja_Frd
Associate II

Hi, I've testet four Time-of-Flight-Sensors of the type VL6180. The results were all different, for a distance of eg 30mm I got 23mm (Sensor1), 21mm (Sensor2), 16mm (Sensor3) and 32mm (Sensor4). The measurements all took place under the same conditions. I'm very interested in the reason of the results.

(Could it be, that the soldering of the pins and the causing higher temperature are the reason for that or is it because of the manufacting tolerance?)

9 REPLIES 9
AGreen
Associate II

Have you tried using the VL6180x_SetOffsetCalibrationData() function?

You should always calibrate the sensors before ranging.

Hanja_Frd
Associate II

Thanks for your reply! I haven't done the calibration, because I didn't know how to do it with a Raspberry Pi in Python. I think the VL6180x_SetOffsetCalibrationData() function is not in the adafruit_vl6180x-library.

My next try would be this with a calibration range of 50mm:

measurements = []

for msmt in range(10):

range_mm = sensor.range

measurements.append(range_mm)

time.sleep(1.0)

average_msmt = sum(measurements) / 10

calibration_offset = 50 - average_msmt

sensor.offset = calibration_offset

But I guess, I have to do the calibration for every material, right? I need the sensors for collision-avoidance of a CNC-machine, so I actually don't now what the obstacle's material is.

Hanja_Frd
Associate II

But actually I'm not looking for a solution to this problem, I'm looking for the reason for the deviating results.

AGreen
Associate II

I'm not an expert at these sensors as I'm figuring them out myself. Calibrating them will help, but I did read somewhere that the V6180X's have around +/-4mm deviation.

I know that even with a calibration there can be offset due to temperature as you mentioned. They need a temp cal at least every 8deg difference according to the datasheet.

You may want to convert some of the C api functions from https://www.st.com/content/st_com/en/products/embedded-software/imaging-software/stsw-img003.html to Python for more control too.. like the offset, timing budget, and xtalk.

For something like a CNC it may be hard to hit very accurate results with a variable speed moving head and different materials like you said too. Don't most 3D printers or CNC's use current spike detection with a shut off threshold in the servos for collision detection (not avoidance)? I may be wrong.

Hanja_Frd
Associate II

Thank you very much!

Julien NGUYEN
ST Employee

Thanks AGreen ! It is exactly that I would suggest to Hanja: convert the offsetCalibration C code into Python method to be called at the beginning at ToF sensor Init. Julien


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.
Hanja_Frd
Associate II

But does the offsetCalibration do anything other than give me the offset of the sensor? Because now I know the offsets of my sensors, but the problem is, that I can't measure shorter than the offset. One sensor has an offset of 20mm and I want to measure to within 5mm.

AGreen
Associate II

20mm seems really high. I would think +/-10 would be the absolute maximums which is probably a stretch as well.

The offset cal works by setting an object with a flat face in front of each sensor at a known distance. Then use VL6180x_SetOffsetCalibrationData(delta distance) to apply it.

You will need to store each of the offset values to persistent storage and reapply them every time a sensor boots up since they do not retain that information.

NOTE: That most of these sensors do not read accurately below 10mm. The readings will jump around and that's why you may be seeing 20mm at < 10mm. You can see this in the VL6180X datasheet Figure 6. Typical ranging performance.

John E KVAM
ST Employee

The Offset calibration code is pretty simple. Range a lot and get the average answer. The offset is the delta between the the average answer and the known value. You can put that offest in the sensor at startup or you can apply the offset yourself. But you need to do it.

An offset can be off by 2cm. It has to do with the phase of the clock and if we lock onto the wrong phase 2cm is not unheard of.

The good news is it will work the same way every time. So the calibration only needs to be done once.

AGreen is correct about the small distance accuracy. Photons take several bounces at the short distances and the result 'reflects' that. Best thing to do is back the sensor up into your machine if you can. If you can range 1cm when your machine is at the 'zero' distance, you will be better off.


If this or any post solves your issue, please mark them as 'Accept as Solution' It really helps. And if you notice anything wrong do not hesitate to 'Report Inappropriate Content'. Someone will review it.