Jump to content
I2Cdevlib Forums

Burney

Members
  • Posts

    1
  • Joined

  • Last visited

Burney's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. Hi, I also tried to use the MP 6050 without the use of interrupts. I have some quite demanding interrupts going on in my project already and merely require the MPU data at roughly 20 Hz. I basically adapted the code from the MPU6050_DMP6 example, which runs fine on my Arduino Mini Pro. However, when I run my code, the output does not change with MPU movement (Euler for example always returns 180, 0, 180). I then found out, that the fifoPacket does not contain any values by using this code (which again runs fine in the example). Did I forget something? Do I have to change some MPU settings, when using it without interrupts? I would really appreciate your feedback! #include "I2Cdev.h" #if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE #include "Wire.h" #endif #include <MPU6050_6Axis_MotionApps20.h> uint16_t fifoCount; uint16_t packetSize; // expected DMP packet size (default is 42 bytes) float euler[3]; uint8_t fifoBuffer[64]; // FIFO storage buffer Quaternion q; MPU6050 mpu; void setup() { #if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE Wire.begin(); TWBR = 24; // 400kHz I2C clock (200kHz if CPU is 8MHz) #elif I2CDEV_IMPLEMENTATION == I2CDEV_BUILTIN_FASTWIRE Fastwire::setup(400, true); #endif Serial.begin(38400); mpu.initialize(); mpu.setDMPEnabled(true); packetSize = mpu.dmpGetFIFOPacketSize(); } void loop() { while (fifoCount < packetSize) { //do stuff Serial.println("nix"); } fifoCount = mpu.getFIFOCount(); if (fifoCount == 1024) { mpu.resetFIFO(); } else { while (fifoCount < packetSize) fifoCount = mpu.getFIFOCount(); mpu.getFIFOBytes(fifoBuffer, packetSize); //fifoCount -= packetSize; //mpu.dmpGetQuaternion(&q, fifoBuffer); //mpu.dmpGetEuler(euler, &q); for (int i = 1; i < 64; i++) { Serial.print(fifoBuffer[i]); Serial.print(" "); } } Serial.print(packetSize); Serial.println(" "); //delay(20); }
×
×
  • Create New...