Log in

View Full Version : Help using I2C Gyro


ProgrammerMatt
04-03-2015, 14:09
Our team wants to use this sensor: https://www.sparkfun.com/products/11977 (https://www.sparkfun.com/products/11977)
but i have no clue where to start on the code side, i know it uses I2C which is easy on an arduino but it seems more difficult for the Roborio.

could anyone please make a quick mockup of how the code would look it would be greatly appreciated.

Thanks,
Matt

Ben Wolsieffer
04-03-2015, 15:00
I don't what language you are using, but here (https://gist.github.com/lopsided98/ef6c0f8cacacad9d398b) is a mostly working driver that I wrote for it in Java. It should be easy to translate to C++, and at least give a little help if you use LabView. It requires some specific code form our libraries, but that should be pretty easy to get rid of. Feel free to ask if you want more explanation of how it works.

I never got it working perfectly, it seemed to filter out many of the small samples, but since we ended up not using it, I stopped working on it.

MikeF1617
04-03-2015, 15:50
I'm not sure if this is much help, but here is what I found and put together.

This is someone trying to do it in Java, and I took some information from there:

http://forums.usfirst.org/showthread.php?24097-Using-I2C-on-the-roborio-for-sensors&p=93340#post93340

It seems that there needs to be an initial command of 0x00 (same as 0) to set it to continuous measurement mode, then just read the data 6 bytes at a time (what the java code does, might need changing). But maybe this is not needed and just managed by the LabVIEW I2C code by itself, so it probably does not need to be included.

I put together a VI with the different parts of code needed, hope this is of some help.

Another option is to go with the gyro that your team probably has that looks like this:

Product:
http://www.andymark.com/product-p/am-2067.htm
Datasheet:
http://www.usfirst.org/sites/default/files/uploadedFiles/Robotics_Programs/FRC/Game_and_Season__Info/2012_Assets/Accelerometer-Gyro.pdf

which should have come in previous year's kit of parts, I believe. My team is using this gyro this year, it is much easier since you can open it on an analog port with the gyro VIs in the WPI library.

ProgrammerMatt
05-03-2015, 16:59
Ill try using the java code as a reference, we are trying to do this in labview if that helps anyone trying to explain it, thanks

Matt