0

Slow connection init to VL6180X on Nvidia Jetson
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Slow connection init to VL6180X on Nvidia Jetson

by yurikleb on Fri Dec 11, 2020 1:36 am

I'm experiencing quite slow initial connection time (above 10 sec) with the VL6180X TOF sensor on the Nvidia Jetson Dev Kits (both Nano and Xavier NX).
Once connected everything works fine, but sensor = adafruit_vl6180x.VL6180X(i2c) takes above 10 seconds to execute.

I have installed the library via:
sudo pip3 install adafruit-circuitpython-vl6180x

Running i2cdetect works quite fast.

What could be causing this such slow sensor init?

yurikleb
 
Posts: 7
Joined: Sun Mar 19, 2017 9:40 pm

Re: Slow connection init to VL6180X on Nvidia Jetson

by siddacious on Mon Dec 14, 2020 9:48 pm

It looks like the VL6180X library does a fair amount of writing to the sensor on init:
https://github.com/adafruit/Adafruit_Ci ... 0x.py#L203

That said, I just tested on a PyBadge and the init time was negligible, so it's likely a difference with how I2C is working with Blinka on the Jetson. I'll page our resident Jetson expert.

Hold tight!

siddacious
 
Posts: 406
Joined: Fri Apr 21, 2017 3:09 pm

Re: Slow connection init to VL6180X on Nvidia Jetson

by siddacious on Mon Dec 14, 2020 9:49 pm

In the meanwhile, pictures showing the wiring will allow us to rule out any hardware issues. Thanks!

siddacious
 
Posts: 406
Joined: Fri Apr 21, 2017 3:09 pm

Re: Slow connection init to VL6180X on Nvidia Jetson

by yurikleb on Tue Dec 15, 2020 7:27 am

Thanks for the quick response.
Here is a picture of my setup:
PXL_20201215_110624283.jpg
sensor connection
PXL_20201215_110624283.jpg (128.66 KiB) Viewed 96 times


I tested the same setup on two different Jetson Xavier NX Dev Kits and a Jetson Nano Dev Kit.
I have several vl6180x sensors on various breakouts variations and all work well with an Arduino and a Raspberry Pi. The init takes few milliseconds on an Arduino and the Pi, so the sensors seem to be fine.

Here is my test code:
Code: Select all | TOGGLE FULL SIZE
import time
import board
import busio
import adafruit_vl6180x # TOF Sensor

class SensorsFeed:

    def __init__(self):
        self.i2c = busio.I2C(board.SCL, board.SDA, frequency=100000)       
        print("connecting to range sensor...")
        self.rng_sensor = adafruit_vl6180x.VL6180X(self.i2c)

        print("Sensor online!")

    def get_range(self):
        sensorVal = self.rng_sensor.range
        return sensorVal

if __name__ == "__main__":
   
    start_time = time.time()
    sensors = SensorsFeed()
    print(f"Took: {time.time() - start_time} sec.")

    start_time = time.time()
    print("getting measurements")
    for i in range(10):
        print(sensors.get_range())
    print(f"Took: {time.time() - start_time} sec.")


And here is the output on an NVIDIA Jetson - the connection init takes 10 sec:
Code: Select all | TOGGLE FULL SIZE
connecting to range sensor...
Sensor online!
Took: 10.185436964035034 sec.
getting measurements
72
72
73
73
73
70
72
73
69
73
Took: 0.16100001335144043 sec.
Exiting...
Cleaning up pins


Same code running on a RaspberryPi - the connection init takes 0.025s:
Code: Select all | TOGGLE FULL SIZE
connectnig to range sensor...
Sensor online!
Took: 0.025896072387695312 sec.
getting measurements
51
51
52
53
54
54
53
54
54
53
Took: 0.11930608749389648 sec.


When running an i2c scan on the Jetson ('sudo i2cdetect -y -r 8' on the Xavier NX or 'sudo i2cdetect -y -r 1' on the Nano ) it takes ~1 second to preform the scan and it finds the sensor on address 0x29 with no problems or delays.

So my guess is it might have something to do with the library.

Another thing I noticed is, the jetson is printing some "Timeout" errors in the background during the connection init. Those are only visible if booting the Jetson in command line mode (' sudo systemctl set-default multi-user.target'). However, the connection is being established in the end (after ~10 sec) and data from the sensor is coming thru. More info and screenshots in my post on NVIDIA forums: https://forums.developer.nvidia.com/t/s ... n/161657/6

yurikleb
 
Posts: 7
Joined: Sun Mar 19, 2017 9:40 pm

Re: Slow connection init to VL6180X on Nvidia Jetson

by MakerMelissa on Fri Dec 18, 2020 1:52 pm

Hi, I'm assuming you followed the setup instructions in https://learn.adafruit.com/circuitpytho ... rs-devices

I have a Jetson Nano, but do not have a VL6180X on hand at the moment, but have one on order so I can see if it gives me the same issues and what the cause of the delay might be.

Thanks,
Melissa

MakerMelissa
 
Posts: 223
Joined: Wed Jun 05, 2013 2:10 am

Re: Slow connection init to VL6180X on Nvidia Jetson

by yurikleb on Sat Dec 19, 2020 4:19 am

MakerMelissa wrote:Hi, I'm assuming you followed the setup instructions in https://learn.adafruit.com/circuitpytho ... rs-devices

I have a Jetson Nano, but do not have a VL6180X on hand at the moment, but have one on order so I can see if it gives me the same issues and what the cause of the delay might be.

Thanks,
Melissa


That would be great! thank you!

yurikleb
 
Posts: 7
Joined: Sun Mar 19, 2017 9:40 pm

Re: Slow connection init to VL6180X on Nvidia Jetson

by MakerMelissa on Thu Dec 24, 2020 5:42 pm

Hi I finally got around to testing it. Here are some of my observations.

  • After a fresh reboot, the init time is quite fast on the first run.
  • With subsequent runs it takes around 10 seconds as you stated.
  • I noticed the same thing on the demo code for the guide.
So it looks like using I2C puts it in some kind of state that has a 10 second timeout when it is reused (about 10 seconds plus the quarter second init time). The question then becomes, does this affect other I2C devices on the Jetson? If so, I'm wondering if this is related to the Jetson Driver for I2C since it doesn't affect other boards such as the Raspberry Pi.

I'll have to do some more testing with other sensors so we can address the problem in the correct place.

Melissa

MakerMelissa
 
Posts: 223
Joined: Wed Jun 05, 2013 2:10 am

Re: Slow connection init to VL6180X on Nvidia Jetson

by MakerMelissa on Thu Dec 24, 2020 6:13 pm

Ok, after some more testing, this gets interesting. I tested the BMP390 and it does not have the same issue in that I can run it over and over. If I run the VL6180X code and then run the BMP390, it has the 10 second delay and then with subsequent runs it starts up right away. So I now suspect the issue lies in the VL6180X driver itself. I'm going to look and see if there's any obvious reasons it may be behaving this way and if not, I'll open up an issue.

MakerMelissa
 
Posts: 223
Joined: Wed Jun 05, 2013 2:10 am

Re: Slow connection init to VL6180X on Nvidia Jetson

by yurikleb on Thu Dec 24, 2020 10:01 pm

Interesting!

The jetsons do seem to play better with some i2c devices than others. for example, they don't even detect the MLX90614 IR Temperature sensor: https://forums.developer.nvidia.com/t/i ... o/76376/50

looking forward to more updates.

yurikleb
 
Posts: 7
Joined: Sun Mar 19, 2017 9:40 pm

Please be positive and constructive with your questions and comments.