Thread: LIDAR
View Single Post
  #3   Spotlight this post!  
Unread 02-03-2015, 22:21
FlyOldPlanes FlyOldPlanes is offline
Registered User
FRC #1592
 
Join Date: Feb 2015
Location: Titusville, FL
Posts: 6
FlyOldPlanes is an unknown quantity at this point
Re: LIDAR

Wire up a 5v I2C device by connecting the SCL and SCA pins to the SCL and SDA pins on the MXP connector. Take power and ground from any 5v power and ground on the roborio.

To get I2C working, we worked our way up by first blinking an led with the digital IO, that was a good confidence builder that we could turn a pin on and off.

Next we hooked up an old kit of parts accel to work out the I2C communications. It worked with the built in Java class in WPILIB. Knowing that it indeed worked, we next wrote an accel class similar to the attached Lidar class. This helped us get confident that we could write our own code to talk over I2C. The accel actually requires more steps since you have to do I2C writes to turn the accel on and set the range. That worked fine also.

Next we tried the Lidar. It was very frustrating that it didn't work. Having more confidence in our I2C from our accel example, we worked more on the Lidar side. We tried several things. Checking connections, mashing wires, a logic level converter, and finally happened on the fact that we needed a pull up resistor, and only on the SCL wire. We actually crimped it right in to our wiring.

For the code steps to get I2C working, see the attached files from the first post. That method should work with any I2C device. Just use the addresses from the datasheet for your device. Use 7bit address, just like you are using arduino. For the Lidar in particular, if you store the variables as type byte, you will get an error doing the multi byte read to 0x8f. It does not fit in a byte, use an int or just write it in like the Lidar example.

I can't stress enough the value of working with the kop ADXL345 external accel first. It really helped build confidence that we were doing I2C right. We wasted a bunch of time fiddling with this and that in the code, while wondering if we were connecting to the right pins, while also working with an untested and poorly documented (for Roborio) sensor. We were better off getting good code with a tested sensor first, then moving to the Lidar.

Lennie

Always read the datasheet
Reply With Quote