Help with I2C protocol for connecting two Lidars to roboRIO

Hi all,

My team is planning on having two distance sensors on the front of the robot to help with lining up the approach to the cargo and rocket smoothly. One of the options we’re considering is the Garmin LIDAR-Lite v3 (datasheet, example code for arduino). We used this last year and it worked great… when we only had one of them. I’m very unsure about how the I2C protocol and the connections here should/do work when there’s more than one device.

One question: how to get data from two of these sensors through the one I2C port available on the roboRIO. The LIDAR-Lite v3 does have a programmable address (see page 5 of the datasheet), but I don’t understand how I can target a specific one to change it’s address while they still have the same address.

Last year we used this Lidar class, which I think we got from Garmin, but I’m not sure. I’m curious specifically about lines 35-41, especially line 38: how can reading happen if the register we’re reading from isn’t specified? Is there only ever one ‘place’ to read from, so frc::I2C only needs the number of bytes and the array to read them to?

Also: I’m fairly sure the // Read() does not work on line 34 was not written by my team. Would I2C::Read work here, and if not, why doesn’t it?

I’m also unsure about how to connect the system together physically. Unlike our CAN devices, these don’t have a place to connect the next one in the chain. Right now we have the 6 wires coming off the LIDAR-Lite v3 spliced (somehow – it’s hidden behind electrical tape and I didn’t think to look today) into a four-female-pin cable that plugs into the I2C port on the roboRIO. Would it be enough to peel back that tape and connect the second LIDAR-Lite in at the same places (we were considering soldering), so that the whole contraption makes a ‘Y’ shape?

Last question: the section in the datasheet about changing the address says this:

Read the two byte serial number from 0x96 (High byte 0x16 and low byte
0x17)

What is a high byte and a low byte (just the first one and the second one?) and why does it give separate addresses there – how are they different from 0x96? Why are there three numbers here when reading the distance – also a two-byte value – only required the one register? (Or: did it not, and I understand that code even less than I thought?)

Thank you so much for any help you can give, I know it’s a lot of questions. Hope everyone’s season is going well!

Look into using CTRE CANifier. You’ll connect your Lidars to the CANifier and be part of your CAN bus. The CANifier can operate both I2C or PWM protocals to get data from the Lidars.

Hope this helps.