android + mpu9150 communication errors

By pinideri1 , 23 June 2013

Hi! I am trying to read data from an MPU9150 using an Android phone. I modified an official Android example (Bluetooth Chat) and I can now read data and send commands to the MPU. I ported the code and functions from the Python example (where a cube is rotated) to Java in order to use them with Android. I know these functions(

four_bytes, two_bytes
) work properly because I have used the same input values in both Java and Python and they return the same values. However, when I compare the values of the packets in the Java and Python codes, the values differ by a small amount. And every once in a while (say, every 4th or 5th packet, maybe less, maybe more often) a completely irrational value appears in the Java values(e.g. -16530 for an accelerometer value when it is not moving). I can see that this value comes from what is read directly from the serial. For this testing I am leaving the MPU in the same position as it was for the Python code, and not moving it and in Python a more reasonable value is displayed.

My question is, does anyone have any idea what might be going on here? It sounds to me like the communication part in Java is problematic, but I have the same as the Android example and I am sending commands properly and somewhat correctly receiving. Or does anyone know a better way to initialize the communication part in Android to work with the MPU. I appreciate this, since I need to finish this for my school project. Thanks.
phpbb Topic ID
15387