Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   NI LabVIEW (http://www.chiefdelphi.com/forums/forumdisplay.php?f=182)
-   -   Programing VL6180 I2c Sensor I2c (http://www.chiefdelphi.com/forums/showthread.php?t=135134)

jman4747 24-02-2015 16:13

Programing VL6180 I2c Sensor I2c
 
2 Attachment(s)
I have been working on building 2 VI's for initializing and getting the range from the VL6180 sensor via I2c. I haven't used I2c before so I'm trying to see if I've done this right. Specifically the initialization (App note pages 24-25) and checking if a bit in a byte read from a register (0x4f) is 1 or 0 (App note page 7).

Data Sheet:
https://cdn.sparkfun.com/datasheets/...DM00112632.pdf

Application Note:
https://cdn.sparkfun.com/datasheets/...cationNote.pdf

Product Page: https://www.sparkfun.com/products/12784

jman4747 26-02-2015 20:33

Re: Programing VL6180 I2c Sensor I2c
 
1 Attachment(s)
So...

It seems that some of the registers have 16bit addresses and the I2c VI only supports 8 bits (right?). To get around this I changed the initialization VI slightly so that the U-16 bit register addresses are split into two U-8 bytes with the lower 8 bits wired in to element zero of the data array and the upper 8 wired to the address input.

zstreet 11-03-2015 10:55

Re: Programing VL6180 I2c Sensor I2c
 
Quote:

Originally Posted by jman4747 (Post 1450406)
So...

It seems that some of the registers have 16bit addresses and the I2c VI only supports 8 bits (right?). To get around this I changed the initialization VI slightly so that the U-16 bit register addresses are split into two U-8 bytes with the lower 8 bits wired in to element zero of the data array and the upper 8 wired to the address input.

I am also trying to establish communication to a VL6180X through LabVIEW.

I am using LabVIEW 2013 so I cannot open your 2014 snippets to look at the subVIs. You are using a different set of I2C subVIs than me.

I also have a different breakout board:
https://www.tindie.com/products/oneh...range-finding/

Putting a scope on my SDA and SCL lines I have not gotten an acknowledge from the VL6180X yet. Currently I think I might have fried the regulator on my board.

Concerning your issues: the split number takes the high 8 bits and separates it from the low 8 bits but both are in the original format of U16. After the split number subVI you need to convert them to U8 also. Without downloading the I2C VIs I cannot be certain but it should be set up so that the Slave Address that you are putting in as 0x29 needs to be shifted 1 bit to 0x52.

Richard100 11-03-2015 15:11

Re: Programing VL6180 I2c Sensor I2c
 
With the advent of the new WPI I2C vi's for LabVIEW 2014, you no longer need to left-shift the slave (device) address by one bit. Simply use the sensor spec sheet I2C address within Labview.

jman4747 11-03-2015 18:06

Re: Programing VL6180 I2c Sensor I2c
 
1 Attachment(s)
Quote:

Originally Posted by zstreet (Post 1456453)
Putting a scope on my SDA and SCL lines I have not gotten an acknowledge from the VL6180X yet. Currently I think I might have fried the regulator on my board.

Concerning your issues: the split number takes the high 8 bits and separates it from the low 8 bits but both are in the original format of U16. After the split number subVI you need to convert them to U8 also. Without downloading the I2C VIs I cannot be certain but it should be set up so that the Slave Address that you are putting in as 0x29 needs to be shifted 1 bit to 0x52.

Don't think you fried it that thing has a crazy complex communications setup that wont respond until after a lot of set up has been preformed. Your breakout has a regulator for use with 3-5.5V so if you are plugging directly into the roboRIO/CRio you will l be fine.

The solution I was working on started with setting up an arduino with the working library and checking function of the sensor, then If it worked figure out what that code was doing and mimic it. By that point I had gotten the RIO to write addresses and data in the correct order. Hint: Have an arduino hooked up to the RIO and have it print what it receives to the serial monitor, I can't imagine trying to debug I2C with a scope. I think for this you will need a bi-directional I2C safe level converter: https://www.sparkfun.com/products/12009

In the end I couldn't figure out exactly all the steps and the order of which the arduino handles the amazing amount of initialization steps by reading the example and source files. The other problem was filtering out steps that set up ALS measurement because I don't need that feature. If I had the time and a bit more C++ experience I could do it.

So after a day of fiddling with it I gave up and focused on using a one of the analog SHARP IR proximity sensors for now. I will go back once I have some time later, this thing is a little tough for someone who hasn't used I2C before.

Post your 2013 code and I can look at it. I can write a 2013 example as well.


All times are GMT -5. The time now is 10:20.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi