Electrical – Read a 6DOF IMU (Gyro + Accelerometer) using PRU – Beaglebone black

beaglebone blacki2csensor

I plan to use an I2C interface in order to read the IMU (SparkFun 6 Degrees of Freedom IMU Digital Combo Board – ITG3200/ADXL345). Since the communication rate using I2C is 400kHz, I thought I should use the PRU in order to read the sensor as fast as possible, as it is 40 times faster in reading GPIOs compared to the Linux host kernel.

Now my question is how do I use I2C to read the sensor using PRU?
If I2C implementation in PRU is complicated , then what are my other options?

Thanks

Best Answer

I would highly recommend simply using the beagle bone's I2C library's to do this. The library should allow you to set the I2C speed up to 400kHz, which is also known as "fast mode".

One of the things to consider when determining the I2C bus speed is how much data you actually need to move across it. If you are only going to be looking at two sensors like the ones you linked, chances are having a really high I2C bus speed will not make difference anyways. I can't seem to clearly find the data rate for the gyro but it appears that the accelerometer only produces new data at a rate of 3.2kHz. Using a multi-byte read for the device even at the normal 100kHz you will most likely be able to read data faster then the device can measure a new value. Running at higher speeds starts to show benefits when you have many devices communicating on the bus or devices that operate at a high speed themselves.