Jump to content
I2Cdevlib Forums

georgelue321

Members
  • Posts

    2
  • Joined

  • Last visited

  • Days Won

    1

georgelue321 last won the day on August 25 2016

georgelue321 had the most liked content!

georgelue321's Achievements

Newbie

Newbie (1/14)

1

Reputation

  1. Hello! I have modified the DMP example code to also print the acceleration readings from the FIFO buffer. Arduino Modified Code: #ifdef OUTPUT_TEAPOT // display quaternion values in InvenSense Teapot demo format: teapotPacket[2] = fifoBuffer[0]; teapotPacket[3] = fifoBuffer[1]; teapotPacket[4] = fifoBuffer[4]; teapotPacket[5] = fifoBuffer[5]; teapotPacket[6] = fifoBuffer[8]; teapotPacket[7] = fifoBuffer[9]; teapotPacket[8] = fifoBuffer[12]; teapotPacket[9] = fifoBuffer[13]; // Added ACCEL teapotPacket[10] = fifoBuffer[28]; teapotPacket[11] = fifoBuffer[29]; teapotPacket[12] = fifoBuffer[32]; teapotPacket[13] = fifoBuffer[33]; teapotPacket[14] = fifoBuffer[36]; teapotPacket[15] = fifoBuffer[37]; Serial.write(teapotPacket, 20); teapotPacket[17]++; // packetCount, loops at 0xFF on purpose #endif The Processing Code: q[0] = ((teapotPacket[2] << 8) | teapotPacket[3]) / 16384.0f; q[1] = ((teapotPacket[4] << 8) | teapotPacket[5]) / 16384.0f; q[2] = ((teapotPacket[6] << 8) | teapotPacket[7]) / 16384.0f; q[3] = ((teapotPacket[8] << 8) | teapotPacket[9]) / 16384.0f; accel[0] = ((teapotPacket[10] << 8) | teapotPacket[11]); accel[1] = ((teapotPacket[12] << 8) | teapotPacket[13]); accel[2] = ((teapotPacket[14] << 8) | teapotPacket[15]); However, the raw acceleration readings in Processing are always 65522.0 64328.0 7593.0 What exactly am I doing wrong? Thanks. -George
  2. Hello! I have installed Jeff Rowberg's i2cdevlib library which I can use for my MPU-6050 to make it interact with Arduino. However, I have an odd problem with one of its functions. It's got a function to turn the accelerometer & gyroscope readings into linear acceleration. This is the definition of the function: uint8_t MPU6050::dmpGetLinearAccel(VectorInt16 *v, VectorInt16 *vRaw, VectorFloat *gravity) { // get rid of the gravity component (+1g = +8192 in standard DMP FIFO packet, sensitivity is 2g) v -> x = vRaw -> x - gravity -> x*8192; v -> y = vRaw -> y - gravity -> y*8192; v -> z = vRaw -> z - gravity -> z*8192; return 0; } However, whenever the function is called in the example code: // display real acceleration, adjusted to remove gravity mpu.dmpGetQuaternion(&q, fifoBuffer); mpu.dmpGetAccel(&aa, fifoBuffer); mpu.dmpGetGravity(&gravity, &q); mpu.dmpGetLinearAccel(&aaReal, &aa, &gravity); Serial.print("areal\t"); Serial.print(aaReal.x); Serial.print("\t"); Serial.print(aaReal.y); Serial.print("\t"); Serial.println(aaReal.z); I get values way off, when I'm not even moving my MPU-6050! These are a few of the values I get: areal -473 423 -425 areal -460 400 -450 areal -471 522 -458 areal -322 276 -582 Do you know how I can fix this? Thanks! -George
×
×
  • Create New...