GithubHelp home page GithubHelp logo

jrowberg / i2cdevlib Goto Github PK

View Code? Open in Web Editor NEW
3.9K 373.0 7.5K 2.11 MB

I2C device library collection for AVR/Arduino or other C++-based MCUs

Home Page: http://www.i2cdevlib.com

C++ 63.34% Processing 0.59% C 34.95% Makefile 0.85% Shell 0.06% CMake 0.21%

i2cdevlib's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

i2cdevlib's Issues

Maximum sample rate

Hi!

I know this is not a good question to do in this place, but I was a little confused about the maximum sample rate of the MPU6050 and MPU9150...

Data sheet shows that the gyro is 8kHz and the accel is 1kHz... So what is the sample rate used by the code?

thanks in advance!

MPU-6050 & tiva C launch pad tm4c123

i tried to use the library on energia and everything worked fine but when i print the raw values they arenot stable at all it goes up and down strangely with no reason and with no movement however it works fine on arduino ! ..

anyone can help ?

MPU6050 Processing example consumes disk space on Mac

I'm running the unmodified MPU6050 DMP sample on Mac, and running the MPUTeapot Processing sketch. When I run the processing sketch, it immediately consumes disk space (not RAM) on my Mac, using about 2GB in 20 seconds. I've tried commenting out all print lines and this slows but does not stop the memory consumption. When I stop the program this disk space is freed.

As far as I can tell, this isn't happening with any of the built-in Processing examples, making me wonder if this is a I2CDevLib or ToxicLibs problem, or something specific to this example.

I'm running a mid-2011 Mac Book Air with OSX 10.9.3, Processing v 2.2.1.

MPU6050_DMP6 PDE serial alignment

It feels stupid, but I could not get the PDE achieve serial alignment with my Arduino. To fix this I've changed serialEvent to reset the serialCount whenever the aligned was reset to 0 by adding this line right before the print statement:

        if(aligned == 0) serialCount = 0; else  serialCount++;            
        println(aligned + " " + serialCount + " " + ch);

I don't see how serialCount should otherwise become 0 when $ is received. Not sure if I caused this by some changes to the Arduino example, but this way the alignment really works for me ;)

ARM support

Hi,

When using your MPU6050 DMP6 example with a Digistump DigiX (essentially an enhanced Arduino Due) , I came across three problems.

  1. Firstly, the TWBR does not exist on the ARM platform, so to continue to use that register to set the bus speed, perhaps you should use something like the code below (unless the Arduino guys incorporate a legacy patch themselves). I included it in the I2Cdev.h file and it compiles and works ok on Arduino 1.5.4 on my setup.

  2. Arduino Dues have two I2C buses, and the second one is accessible via the dedicated SDA/SCL pins, and is accessed via Wire1, not Wire. Can you add some sort of flag so the I2Cdev knows to use Wire1 instead of Wire?

  3. the attachInterrupts command doesn't work the same way, you specify the pin not the interrupt, so something like the below snippet fixes that.

Sorry to be wordy, hope this of use to you. :)

Interrupts fix:

// Attach to interrupt 0 (pin 2) on AVR, or pin 2 on ARM
#ifdef __arm__
    attachInterrupt(2, dmpDataReady, RISING);
#else
    attachInterrupt(0, dmpDataReady, RISING);
#endif

TWBR fix:

// Paul Stoffregen AVR TWBR emulation for ARM
// http://forum.pjrc.com/threads/23798-Sabernetics-I2C-OLED-display-Adafruit-SSD1306-library-problem?p=32988&viewfull=1#post32988
#if defined(__arm__)
class TWBRemulation
{
public:
    inline TWBRemulation & operator = (int val) __attribute__((always_inline)) {
    if (val == 12 || val == ((F_CPU / 400000) - 16) / 2) {
        #if F_BUS == 48000000
        I2C0_F = 0x1A; // 400 kHz
        #elif F_BUS == 24000000
        I2C0_F = 0x45; // 400 kHz
        #endif
    }
    return *this;
}
};
extern TWBRemulation TWBR;
#endif

L3G4200D Gyro outputting strange values

I'm using an L3G4200D on a Gy-80 sensor board with an Arduino Due.

The raw values obtained when running the L3G4200D_raw.ino code range from 0 to 255, there is no difference between clockwise and counter clockwise rotations.

The issue doesn't happen when using the L3G.h library (https://github.com/pololu/L3G) so it doesn't seem to be a hardware issue.

Connection not successful. both raw and DMP.

I am new to I2C and thus only have basic understanding. The device is not able to connect successfully with Arduino and thus am getting only zeroes. Please help as soon as possible.

compiler error

get a very long list of error messages by compiling MPU6000_DMP6.ino.
use Arduino 1.0.5 (tried also 1.5.2, same list), selected board is Mega 2560
I uploaded the i2cdevlib-master today and copied all necessary files in the libraries folder. Do I use an old file or wrong Arduino version?

list starts with
C:\Program Files\Arduino\libraries\MPU60X0\MPU60X0.cpp: In member function 'void MPU60X0::initialize()':
C:\Program Files\Arduino\libraries\MPU60X0\MPU60X0.cpp:69: error: 'SPI' was not declared in this scope
C:\Program Files\Arduino\libraries\MPU60X0\MPU60X0.cpp: In member function 'uint8_t MPU60X0::getAuxVDDIOLevel()':
C:\Program Files\Arduino\libraries\MPU60X0\MPU60X0.cpp:100: error: invalid conversion from 'int' to 'uint8_t_'
C:\Program Files\Arduino\libraries\MPU60X0\MPU60X0.cpp:100: error: initializing argument 4 of 'static int8_t I2Cdev::readBit(uint8_t, uint8_t, uint8_t, uint8_t_, uint16_t)'
C:\Program Files\Arduino\libraries\MPU60X0\MPU60X0.cpp:100: error: invalid conversion from 'uint8_t*' to 'uint16_t'
C:\Program Files\Arduino\libraries\MPU60X0\MPU60X0.cpp:100: error: initializing argument 5 of 'static int8_t

Touchstatus not read properly

I have included this library in my project but found that the second register for the touch status is not read properly. Instead, I receive the data of the first register which is bit shifted to the second register.

So, a touch on pin 0 will show up as pin 0 and pin 8.

Error compelling using GY521 and example under Arduino/M6050

I am using Arduino IDE 1.0.5 -r2 and Arduino UNO.
When I am trying to compel the example under folder Arduino/M6050, I get a long list of error information.
Anyone Can help me? Thanks.

The code:

// I2C device class (I2Cdev) demonstration Arduino sketch for MPU6050 class using DMP (MotionApps v2.0)
// 6/21/2012 by Jeff Rowberg <[email protected]>
// Updates should (hopefully) always be available at https://github.com/jrowberg/i2cdevlib
//
// Changelog:
//      2013-05-08 - added seamless Fastwire support
//                 - added note about gyro calibration
//      2012-06-21 - added note about Arduino 1.0.1 + Leonardo compatibility error
//      2012-06-20 - improved FIFO overflow handling and simplified read process
//      2012-06-19 - completely rearranged DMP initialization code and simplification
//      2012-06-13 - pull gyro and accel data from FIFO packet instead of reading directly
//      2012-06-09 - fix broken FIFO read sequence and change interrupt detection to RISING
//      2012-06-05 - add gravity-compensated initial reference frame acceleration output
//                 - add 3D math helper file to DMP6 example sketch
//                 - add Euler output and Yaw/Pitch/Roll output formats
//      2012-06-04 - remove accel offset clearing for better results (thanks Sungon Lee)
//      2012-06-01 - fixed gyro sensitivity to be 2000 deg/sec instead of 250
//      2012-05-30 - basic DMP initialization working

/* ============================================
I2Cdev device library code is placed under the MIT license
Copyright (c) 2012 Jeff Rowberg

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
===============================================
*/

// I2Cdev and MPU6050 must be installed as libraries, or else the .cpp/.h files
// for both classes must be in the include path of your project
#include "I2Cdev.h"

#include "MPU6050_6Axis_MotionApps20.h"
//#include "MPU6050.h" // not necessary if using MotionApps include file

// Arduino Wire library is required if I2Cdev I2CDEV_ARDUINO_WIRE implementation
// is used in I2Cdev.h
#if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
    #include "Wire.h"
#endif

// class default I2C address is 0x68
// specific I2C addresses may be passed as a parameter here
// AD0 low = 0x68 (default for SparkFun breakout and InvenSense evaluation board)
// AD0 high = 0x69
MPU6050 mpu;
//MPU6050 mpu(0x69); // <-- use for AD0 high

/* =========================================================================
   NOTE: In addition to connection 3.3v, GND, SDA, and SCL, this sketch
   depends on the MPU-6050's INT pin being connected to the Arduino's
   external interrupt #0 pin. On the Arduino Uno and Mega 2560, this is
   digital I/O pin 2.
 * ========================================================================= */

/* =========================================================================
   NOTE: Arduino v1.0.1 with the Leonardo board generates a compile error
   when using Serial.write(buf, len). The Teapot output uses this method.
   The solution requires a modification to the Arduino USBAPI.h file, which
   is fortunately simple, but annoying. This will be fixed in the next IDE
   release. For more info, see these links:

   http://arduino.cc/forum/index.php/topic,109987.0.html
   http://code.google.com/p/arduino/issues/detail?id=958
 * ========================================================================= */



// uncomment "OUTPUT_READABLE_QUATERNION" if you want to see the actual
// quaternion components in a [w, x, y, z] format (not best for parsing
// on a remote host such as Processing or something though)
//#define OUTPUT_READABLE_QUATERNION

// uncomment "OUTPUT_READABLE_EULER" if you want to see Euler angles
// (in degrees) calculated from the quaternions coming from the FIFO.
// Note that Euler angles suffer from gimbal lock (for more info, see
// http://en.wikipedia.org/wiki/Gimbal_lock)
//#define OUTPUT_READABLE_EULER

// uncomment "OUTPUT_READABLE_YAWPITCHROLL" if you want to see the yaw/
// pitch/roll angles (in degrees) calculated from the quaternions coming
// from the FIFO. Note this also requires gravity vector calculations.
// Also note that yaw/pitch/roll angles suffer from gimbal lock (for
// more info, see: http://en.wikipedia.org/wiki/Gimbal_lock)
#define OUTPUT_READABLE_YAWPITCHROLL

// uncomment "OUTPUT_READABLE_REALACCEL" if you want to see acceleration
// components with gravity removed. This acceleration reference frame is
// not compensated for orientation, so +X is always +X according to the
// sensor, just without the effects of gravity. If you want acceleration
// compensated for orientation, us OUTPUT_READABLE_WORLDACCEL instead.
//#define OUTPUT_READABLE_REALACCEL

// uncomment "OUTPUT_READABLE_WORLDACCEL" if you want to see acceleration
// components with gravity removed and adjusted for the world frame of
// reference (yaw is relative to initial orientation, since no magnetometer
// is present in this case). Could be quite handy in some cases.
//#define OUTPUT_READABLE_WORLDACCEL

// uncomment "OUTPUT_TEAPOT" if you want output that matches the
// format used for the InvenSense teapot demo
//#define OUTPUT_TEAPOT



#define LED_PIN 13 // (Arduino is 13, Teensy is 11, Teensy++ is 6)
bool blinkState = false;

// MPU control/status vars
bool dmpReady = false;  // set true if DMP init was successful
uint8_t mpuIntStatus;   // holds actual interrupt status byte from MPU
uint8_t devStatus;      // return status after each device operation (0 = success, !0 = error)
uint16_t packetSize;    // expected DMP packet size (default is 42 bytes)
uint16_t fifoCount;     // count of all bytes currently in FIFO
uint8_t fifoBuffer[64]; // FIFO storage buffer

// orientation/motion vars
Quaternion q;           // [w, x, y, z]         quaternion container
VectorInt16 aa;         // [x, y, z]            accel sensor measurements
VectorInt16 aaReal;     // [x, y, z]            gravity-free accel sensor measurements
VectorInt16 aaWorld;    // [x, y, z]            world-frame accel sensor measurements
VectorFloat gravity;    // [x, y, z]            gravity vector
float euler[3];         // [psi, theta, phi]    Euler angle container
float ypr[3];           // [yaw, pitch, roll]   yaw/pitch/roll container and gravity vector

// packet structure for InvenSense teapot demo
uint8_t teapotPacket[14] = { '$', 0x02, 0,0, 0,0, 0,0, 0,0, 0x00, 0x00, '\r', '\n' };



// ================================================================
// ===               INTERRUPT DETECTION ROUTINE                ===
// ================================================================

volatile bool mpuInterrupt = false;     // indicates whether MPU interrupt pin has gone high
void dmpDataReady() {
    mpuInterrupt = true;
}



// ================================================================
// ===                      INITIAL SETUP                       ===
// ================================================================

void setup() {
    // join I2C bus (I2Cdev library doesn't do this automatically)
    #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

    // initialize serial communication
    // (115200 chosen because it is required for Teapot Demo output, but it's
    // really up to you depending on your project)
    Serial.begin(115200);
    while (!Serial); // wait for Leonardo enumeration, others continue immediately

    // NOTE: 8MHz or slower host processors, like the Teensy @ 3.3v or Ardunio
    // Pro Mini running at 3.3v, cannot handle this baud rate reliably due to
    // the baud timing being too misaligned with processor ticks. You must use
    // 38400 or slower in these cases, or use some kind of external separate
    // crystal solution for the UART timer.

    // initialize device
    Serial.println(F("Initializing I2C devices..."));
    mpu.initialize();

    // verify connection
    Serial.println(F("Testing device connections..."));
    Serial.println(mpu.testConnection() ? F("MPU6050 connection successful") : F("MPU6050 connection failed"));

    // wait for ready
    Serial.println(F("\nSend any character to begin DMP programming and demo: "));
    while (Serial.available() && Serial.read()); // empty buffer
    while (!Serial.available());                 // wait for data
    while (Serial.available() && Serial.read()); // empty buffer again

    // load and configure the DMP
    Serial.println(F("Initializing DMP..."));
    devStatus = mpu.dmpInitialize();

    // supply your own gyro offsets here, scaled for min sensitivity
    mpu.setXGyroOffset(220);
    mpu.setYGyroOffset(76);
    mpu.setZGyroOffset(-85);
    mpu.setZAccelOffset(1788); // 1688 factory default for my test chip

    // make sure it worked (returns 0 if so)
    if (devStatus == 0) {
        // turn on the DMP, now that it's ready
        Serial.println(F("Enabling DMP..."));
        mpu.setDMPEnabled(true);

        // enable Arduino interrupt detection
        Serial.println(F("Enabling interrupt detection (Arduino external interrupt 0)..."));
        attachInterrupt(0, dmpDataReady, RISING);
        mpuIntStatus = mpu.getIntStatus();

        // set our DMP Ready flag so the main loop() function knows it's okay to use it
        Serial.println(F("DMP ready! Waiting for first interrupt..."));
        dmpReady = true;

        // get expected DMP packet size for later comparison
        packetSize = mpu.dmpGetFIFOPacketSize();
    } else {
        // ERROR!
        // 1 = initial memory load failed
        // 2 = DMP configuration updates failed
        // (if it's going to break, usually the code will be 1)
        Serial.print(F("DMP Initialization failed (code "));
        Serial.print(devStatus);
        Serial.println(F(")"));
    }

    // configure LED for output
    pinMode(LED_PIN, OUTPUT);
}



// ================================================================
// ===                    MAIN PROGRAM LOOP                     ===
// ================================================================

void loop() {
    // if programming failed, don't try to do anything
    if (!dmpReady) return;

    // wait for MPU interrupt or extra packet(s) available
    while (!mpuInterrupt && fifoCount < packetSize) {
        // other program behavior stuff here
        // .
        // .
        // .
        // if you are really paranoid you can frequently test in between other
        // stuff to see if mpuInterrupt is true, and if so, "break;" from the
        // while() loop to immediately process the MPU data
        // .
        // .
        // .
    }

    // reset interrupt flag and get INT_STATUS byte
    mpuInterrupt = false;
    mpuIntStatus = mpu.getIntStatus();

    // get current FIFO count
    fifoCount = mpu.getFIFOCount();

    // check for overflow (this should never happen unless our code is too inefficient)
    if ((mpuIntStatus & 0x10) || fifoCount == 1024) {
        // reset so we can continue cleanly
        mpu.resetFIFO();
        Serial.println(F("FIFO overflow!"));

    // otherwise, check for DMP data ready interrupt (this should happen frequently)
    } else if (mpuIntStatus & 0x02) {
        // wait for correct available data length, should be a VERY short wait
        while (fifoCount < packetSize) fifoCount = mpu.getFIFOCount();

        // read a packet from FIFO
        mpu.getFIFOBytes(fifoBuffer, packetSize);

        // track FIFO count here in case there is > 1 packet available
        // (this lets us immediately read more without waiting for an interrupt)
        fifoCount -= packetSize;

        #ifdef OUTPUT_READABLE_QUATERNION
            // display quaternion values in easy matrix form: w x y z
            mpu.dmpGetQuaternion(&q, fifoBuffer);
            Serial.print("quat\t");
            Serial.print(q.w);
            Serial.print("\t");
            Serial.print(q.x);
            Serial.print("\t");
            Serial.print(q.y);
            Serial.print("\t");
            Serial.println(q.z);
        #endif

        #ifdef OUTPUT_READABLE_EULER
            // display Euler angles in degrees
            mpu.dmpGetQuaternion(&q, fifoBuffer);
            mpu.dmpGetEuler(euler, &q);
            Serial.print("euler\t");
            Serial.print(euler[0] * 180/M_PI);
            Serial.print("\t");
            Serial.print(euler[1] * 180/M_PI);
            Serial.print("\t");
            Serial.println(euler[2] * 180/M_PI);
        #endif

        #ifdef OUTPUT_READABLE_YAWPITCHROLL
            // display Euler angles in degrees
            mpu.dmpGetQuaternion(&q, fifoBuffer);
            mpu.dmpGetGravity(&gravity, &q);
            mpu.dmpGetYawPitchRoll(ypr, &q, &gravity);
            Serial.print("ypr\t");
            Serial.print(ypr[0] * 180/M_PI);
            Serial.print("\t");
            Serial.print(ypr[1] * 180/M_PI);
            Serial.print("\t");
            Serial.println(ypr[2] * 180/M_PI);
        #endif

        #ifdef OUTPUT_READABLE_REALACCEL
            // 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);
        #endif

        #ifdef OUTPUT_READABLE_WORLDACCEL
            // display initial world-frame acceleration, adjusted to remove gravity
            // and rotated based on known orientation from quaternion
            mpu.dmpGetQuaternion(&q, fifoBuffer);
            mpu.dmpGetAccel(&aa, fifoBuffer);
            mpu.dmpGetGravity(&gravity, &q);
            mpu.dmpGetLinearAccel(&aaReal, &aa, &gravity);
            mpu.dmpGetLinearAccelInWorld(&aaWorld, &aaReal, &q);
            Serial.print("aworld\t");
            Serial.print(aaWorld.x);
            Serial.print("\t");
            Serial.print(aaWorld.y);
            Serial.print("\t");
            Serial.println(aaWorld.z);
        #endif

        #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];
            Serial.write(teapotPacket, 14);
            teapotPacket[11]++; // packetCount, loops at 0xFF on purpose
        #endif

        // blink LED to indicate activity
        blinkState = !blinkState;
        digitalWrite(LED_PIN, blinkState);
    }
}

error massage:






C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:14:17: error: i2c.h: No such file or directory
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c: In function 'I2C_masterInit':
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:50: error: 'I2C_PxSEL' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:50: error: (Each undeclared identifier is reported only once
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:50: error: for each function it appears in.)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:50: error: 'SDA_PIN' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:50: error: 'SCL_PIN' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:51: error: 'UCB1CTL1' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:51: error: 'UCSWRST' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:52: error: 'UCB1CTL0' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:52: error: 'UCMST' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:52: error: 'UCMODE_3' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:52: error: 'UCSYNC' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:53: error: 'UCSSEL_2' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:54: error: 'UCB1BR0' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:54: error: 'I2C_PRESCALE' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:55: error: 'UCB1BR1' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c: In function 'I2C_enable':
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:73: error: 'UCB1CTL1' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:73: error: 'UCSWRST' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c: In function 'I2C_disable':
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:91: error: 'UCB1CTL1' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:91: error: 'UCSWRST' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c: In function 'I2C_setSlaveAddress':
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:113: error: 'UCB1I2CSA' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c: In function 'I2C_setMode':
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:133: error: 'UCB1CTL1' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:133: error: 'I2C_TRANSMIT_MODE' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c: In function 'I2C_isBusBusy':
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:153: error: 'UCB1STAT' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:153: error: 'UCBBUSY' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c: In function 'I2C_enableInterrupt':
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:181: error: 'UC1IFG' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:184: error: 'UC1IE' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c: In function 'I2C_disableInterrupt':
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:211: error: 'UC1IE' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c: In function 'I2C_clearInterruptFlag':
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:235: error: 'UC1IFG' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c: In function 'I2C_masterSendSingleByte':
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:260: error: 'UC1IE' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:260: error: 'UCB1TXIE' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:266: error: 'UCB1CTL1' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:266: error: 'UCTR' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:266: error: 'UCTXSTT' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:269: error: 'UC1IFG' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:269: error: 'UCB1TXIFG' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:272: error: 'UCB1TXBUF' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:278: error: 'UCTXSTP' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c: In function 'I2C_masterMultiByteSendStart':
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:308: error: 'UC1IE' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:308: error: 'UCB1TXIE' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:314: error: 'UCB1CTL1' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:314: error: 'UCTR' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:314: error: 'UCTXSTT' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:317: error: 'UC1IFG' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:317: error: 'UCB1TXIFG' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:320: error: 'UCB1TXBUF' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c: In function 'I2C_masterMultiByteSendNext':
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:345: error: 'UC1IE' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:345: error: 'UCB1TXIE' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:347: error: 'UC1IFG' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:347: error: 'UCB1TXIFG' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:351: error: 'UCB1TXBUF' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c: In function 'I2C_masterMultiByteSendFinish':
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:375: error: 'UC1IE' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:375: error: 'UCB1TXIE' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:377: error: 'UC1IFG' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:377: error: 'UCB1TXIFG' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:381: error: 'UCB1TXBUF' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:387: error: 'UCB1CTL1' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:387: error: 'UCTXSTP' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c: In function 'I2C_masterMultiByteSendStop':
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:409: error: 'UC1IE' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:409: error: 'UCB1TXIE' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:411: error: 'UC1IFG' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:411: error: 'UCB1TXIFG' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:415: error: 'UCB1CTL1' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:415: error: 'UCTXSTP' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c: In function 'I2C_masterMultiByteReceiveStart':
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:435: error: 'UCB1CTL1' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:435: error: 'UCTR' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:437: error: 'UCTXSTT' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c: In function 'I2C_masterMultiByteReceiveNext':
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:456: error: 'UCB1RXBUF' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c: In function 'I2C_masterMultiByteReceiveFinish':
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:478: error: 'UCB1CTL1' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:478: error: 'UCTXSTP' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:484: error: 'UC1IFG' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:484: error: 'UCB1RXIFG' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:488: error: 'UCB1RXBUF' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c: In function 'I2C_masterMultiByteReceiveStop':
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:508: error: 'UCB1CTL1' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:508: error: 'UCTXSTP' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c: In function 'I2C_masterSingleReceiveStart':
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:530: error: 'GIE' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:536: error: 'UCB1CTL1' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:536: error: 'UCTR' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:539: error: 'UCTXSTT' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:545: error: 'UCTXSTP' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c: In function 'I2C_masterSingleReceive':
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:568: error: 'UCB1RXBUF' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c: In function 'I2C_readBytesFromAddress':
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:679: error: 'I2C_TRANSMIT_MODE' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:705: error: 'I2C_RECEIVE_MODE' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:709: error: 'I2C_RECEIVE_INTERRUPT' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c: In function 'I2C_writeBytesToAddress':
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:740: error: 'I2C_TRANSMIT_MODE' undeclared (first use in this function)
C:\Users\Zhang Lutong\Documents\Arduino\libraries\I2Cdev\msp430_i2c.c:746: error: 'I2C_TRANSMIT_INTERRUPT' undeclared (first use in this function)

new verison of MPU6050_DMP6 hangs

I made the recent changes to MPU6050_DMP6.ino, change 3af4d4a specifically changing the interrupt to

attachInterrupt(0, dmpDataReady, RISING);

Now it will hang in this line..

while ((fifoCount = accelgyro.getFIFOCount()) < 42);

I put a timeout in this loop and reset the fifo on timeout and it will timeout after several hundred readings very repeatably.

   int cnt= 0;
    while ((fifoCount = accelgyro.getFIFOCount()) < 42){
            if(cnt++ > 100) {
                    Serial.println("Fifo timeout");
                    accelgyro.resetFIFO();
                    return;
            }
            delay(10);
    }

Also the data returned prior (and post) to the timeout is incorrect, the yaw pitch roll are changing randomly are not correct.

Reverting to the older version all works well although I notice that quite frequently fifo < 42 when tested but that does not seem to hurt anything as it just waits for the next interrupt and gets it ok.

Will DMP help with my camera gimbal

Hi Jeff, I'm working on a 3 axis self-balancing camera gimbal. Most of the projects that are out there are just 2 axis, and use arduino and a 6050IMU. I believe they are doing the fusion on the arduino side, and thus the update rate on the motors that balance the camera isn't as high as possible, and there is also the occasional drift that happens. I'm wondering if implementing your DMP code will help this problem?

Please excuse my ignorance, but will the addition of a magnetometer also make a difference for this application?

Gimbal would be mounted on a vehicle, cablecam, RC helicopter or hand held.

Thanks,

-Tom

msp430_i2c.c: cannot open source file "i2c.h"

Hi,
I download the lib for MP430,
when I compile it, there is an error as following:

Description Resource Path Location Type
#1965 cannot open source file "i2c.h" msp430_i2c.c /MPU9150 line 14 C/C++ Problem

Line 14: #include "i2c.h"

did I do something wrong? i cannot find the file anywhere.
sorry, I am quite new in this.

Thanks.

Cant find mydevstub

Trying out this lib I got the following error, I can seem to find mydevstub.h anywhere in the repo

lib/i2cdevlib/Arduino/_Stub/_Stub.cpp:34:23: fatal error: MYDEVSTUB.h: No such file or directory
compilation terminated.
make: *** [.build/micro/i2cdevlib/Arduino/_Stub/_Stub.d] Error 1

return status missing

Their is no way to know if a function was successful or not !
For example, when using
void MPU6050::getMotion6(int16_t* ax, int16_t* ay, int16_t* az, int16_t* gx, int16_t* gy, int16_t* gz);

I don't know if the value in a? and g? are valid or not.

The function could return a boolean and/or set an error flag for function that already return a value.

This is useful to detect a disconnect wire when working with a breadboard.

This concern at least MPU6050 and DS1307 and probably all the other classes
I think the easiest way would be to inherit from I2Cdev and setup and error flag after a failed read or write.

Thanks for your work
Alain

some typos in MPU6050_6Axis_MotionApps20.h

Affects only DEBUG runs, haven't look in the history but they may be due some variable renames.

Lines 321, 323 and 325 variables xgOffset, ygOffset and zgOffset need TC added.

Thanks

Gravity Z Component Difference

In the EMBEDDED MOTIONAPPS V2.0 given by the Invensence they derive the Z component of the gravity by the following phrase that is being taken from the mlFIFO.c file

data[2] =
(inv_q29_mult(quat[3], quat[3]) + inv_q29_mult(quat[0], quat[0])) -
1073741824L;
and the
inv_q29_mult(long a, long b)
function just multiply the arguments and divide it by 2^29

But in the code that you have implemented use a different equation like
v -> z = q -> w_q -> w - q -> x_q -> x - q -> y_q -> y + q -> z_q -> z;
can you please justify the reason to this change.
since i'm using your code for my final year project can you please give me a quick reply!

dmpGetYawPitchRoll does not return correct angles when sensor is vertical

It looks like a bug in the way the roll/pitch and yaw and derived from the quaternion. This world for me and produces identical results to the existing code when the sensor is z-axis up.

data[0] = -atan2(2.0 * (q.x * q.y + q.w * q.z), q.w * q.w + q.x * q.x - q.y * q.y - q.z * q.z);
data1] = -asin(-2.0 * (q.x * q.z - q.w * q.y));
data[2] = atan2(2.0 * (q.y * q.z + q.w * q.x), q.w * q.w - q.x * q.x - q.y * q.y + q.z * q.z);

how to connect two mpu6050 to arduino uno

Hi!
I want to connect my arduino uno to two mpu 6050 in order to learn about the relative angles and velocity,
there is some ready program for this?
how to connect the 2 mpu 6050 ?
thank you,
reut :)

MPU6050 - OUTPUT_READABLE_YAWPITCHROLL

Hello, Jeff! Thank you for a great library. Your MPU6050 driver is working fine on my Arduino UNO, but I faced some issues in calculating readable yaw-pitch-roll.

I've noticed two problems:

  1. Event if the chip was not moved even a tiny bit since the the moment the MPU was initialized, the initial values of yaw-pitch-roll are between 1 and 3. It seems to me they must all be 0 right after the initialization if the chip was not moved.
  2. Even if the chip is absolutely fixed on the steady surface the yaw-pitch-roll values continuously change with deltas about 1 degree ( e.g. from 3.000 to 3.999). Is it how the device and the driver are supposed to work or I'm doing something wrong?

Any help or answer is greatly appreciated!

Error in dmpGetLinearAccelInWorld()

memcpy(v, vReal, sizeof(Quaternion)); should read:
memcpy(v, vReal, sizeof(VectorInt16));

On my System, the values of aa and aaReal had the same value after this function was called.
This error only shows up if the member functions dmpGetLinearAccel() and dmpGetRealAccelInWorld() are called subsequently and the return value is used later on.

MPU6050_9Axis_MotionApps41.h

In the MPU6050_6Axis_MotionApps20.h cause the quaternion to initialized in the power up direction. In other words the axis system of the wold frame depends on the power up orientation of the sensor. This is because that it does not have a magnetometer it cant make a fixed axis system. But with MPU6050_9Axis_MotionApps41.h this issue need to be solved since it uses the magnetometer but it does not use the magnetometer reading to correct the 6 -axis quaternion given by the MPU 6050. can you describe a way to correct the quaternion that is given by the MPU to not to depend on the power up direction but to depend on the magnetometer magmatic north.
thank you!

Move MPU Code into Separate Project?

It seems like the MPU code sitting in here is a bit out of place. Shouldn't it be it's own project with a dependency on this one. I only say that because it's a little confusing as it is right now.

Accel and Gyro data seem stranger

Dear Friends,
Thanks for the dmp/lib codes, I was very happy when I saw the codes successfully read out mpu-9150 from the data and stored them into file on my PC .
But I found a problem when I try to process the data:
the data jump up and down but their envelope seems correct.
I thought it is my mpu-9150 not good and tried another one it is same thing.
tried to change rate lower or higher I got same thing.
and I also tried to only read raw data with simple setting up, but still get same thing.it has driven me crazy for weeks.
I wonder how it could happen ? anyone had same problem and how to solve it?

Your help will be highly appreciated.
Below is the signal curves. you can see the value going to near zero then go back to real data the go to near zero again and so on ...................
1.Accel
image
2.Gyro
image

Not working on Arduino 1.0.5

not able to compile the program showing this error \Arduino\hardware\arduino\cores\arduino/Arduino.h:105:26: error: macro "millis" passed 1 arguments, but takes just 0

MPU9150-magnometer

im using MPU9150 and i was wondering if the library has something to correct magnometer drift like for the gyro and accelemetor like mpu.setZGyroOffset(); and mpu.setZAccelOffset(); because i want to calculate the heading using this equation

MAG_X = mx_cos_pitch + my_sin_roll_sin_pitch + mz_cos_roll_sin_pitch;
MAG_Y = my_cos_roll-mz*sin_roll;

heading = atan2(-MAG_Y, MAG_X)* 180.0/3.14159265 + 180 ;

i fixed yaw , roll and pitch drift using the function mpu.setZAccelOffset() and mpu.setZGyroOffset() but i am still having the problem that the raw values of magnometer not stable it keeps floating ..

Any advices or help please ?

MPU6050_DMP6 Example Improvements

Following up on the fixes from issue #13...

In the example as you suggested fifoCount should be converted to uint16_t.
This is important because occasionally, for whatever reason, the fifoCount is more than 42, quite often around 300 which would overflow the 8 bit fifoCount.

Related to this, and something that was causing me grief by corruption, there needs to be a check that when/if fifoCount is bigger than expected we do not overflow the fifoBuffer.. I added this check to protect against that.

   // read FIFO content, make sure we do not overflow our buffer
    if(fifoCount <= sizeof fifoBuffer) {
            accelgyro.getFIFOBytes(fifoBuffer, fifoCount);

    }else{
            Serial.print("Trying to read too much FIFO ");
            Serial.println(fifoCount);
            accelgyro.resetFIFO();
            return;
    }

I think at least one reason for fifoCount being bigger than expected is if something causes the interrupt to be delayed (like a delay(1000)) in the loop.

Maybe the fifo could be read in the interrupt handler itself? That would avoid the fifo filling up.

Thanks

Unable to compile code with included MPU6050 library and I2Cdev library

Here's a sample of the errors for the I2Cdev.h part of the inclusion:

C:\Arduino\arduino-1.5.4-r2-windows\arduino-1.5.4\libraries\I2Cdev/I2Cdev.h:9: error: stray '\302' in program
C:\Arduino\arduino-1.5.4-r2-windows\arduino-1.5.4\libraries\I2Cdev/I2Cdev.h:9: error: stray '\267' in program
C:\Arduino\arduino-1.5.4-r2-windows\arduino-1.5.4\libraries\I2Cdev/I2Cdev.h:242: error: stray '@' in program

The same errors occur for the MPU6050.h part of the inclusion:

C:\Arduino\arduino-1.5.4-r2-windows\arduino-1.5.4\libraries\MPU6050/MPU6050.h:9: error: stray '\302' in program
C:\Arduino\arduino-1.5.4-r2-windows\arduino-1.5.4\libraries\MPU6050/MPU6050.h:9: error: stray '\267' in program
C:\Arduino\arduino-1.5.4-r2-windows\arduino-1.5.4\libraries\MPU6050/MPU6050.h:241: error: stray '@' in program

I did a search through both MPU6050.cpp and MPU6050.h for anything \302, but never found a thing, so I have no idea where these errors are originating from.

I assume this means I've included my libraries into my Arduino 1.5.4 installation incorrectly, but since I just started a month ago, I have no idea what I'm really doing...any help would be appreciated :)

John

MPUTeapot plane idle

I'm trying MPUTeapot with Arduino UNO, a MPU6050.
In processing, when I run the sketch I'm able to see the ypr values but the image of the plane is always idle.
I used the latest version of your sketches, the latest toxiclibs library, Arduino 1.0.5 IDE and Processing 2.1 on several PCs and OS.
The MPU6050 is a GY-521.

Compiling errors

Hi, Im getting a bunch of error when compiling I hope you can help me to solve it.

C:\Program Files (x86)\Arduino\libraries\I2Cdev\I2Cdev.cpp:67: error: prototype for 'int8_t I2Cdev::readBit(bool, uint8_t, uint8_t, uint8_t, uint8_t_, uint16_t)' does not match any in class 'I2Cdev'
C:\Program Files (x86)\Arduino\libraries\I2Cdev/I2Cdev.h:94: error: candidate is: static int8_t I2Cdev::readBit(uint8_t, uint8_t, uint8_t, uint8_t_, uint16_t)
C:\Program Files (x86)\Arduino\libraries\I2Cdev\I2Cdev.cpp:83: error: prototype for 'int8_t I2Cdev::readBitW(bool, uint8_t, uint8_t, uint8_t, uint16_t_, uint16_t)' does not match any in class 'I2Cdev'
C:\Program Files (x86)\Arduino\libraries\I2Cdev/I2Cdev.h:95: error: candidate is: static int8_t I2Cdev::readBitW(uint8_t, uint8_t, uint8_t, uint16_t_, uint16_t)
C:\Program Files (x86)\Arduino\libraries\I2Cdev\I2Cdev.cpp:100: error: prototype for 'int8_t I2Cdev::readBits(bool, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t_, uint16_t)' does not match any in class 'I2Cdev'
C:\Program Files (x86)\Arduino\libraries\I2Cdev/I2Cdev.h:96: error: candidate is: static int8_t I2Cdev::readBits(uint8_t, uint8_t, uint8_t, uint8_t, uint8_t_, uint16_t)
C:\Program Files (x86)\Arduino\libraries\I2Cdev\I2Cdev.cpp:127: error: prototype for 'int8_t I2Cdev::readBitsW(bool, uint8_t, uint8_t, uint8_t, uint8_t, uint16_t_, uint16_t)' does not match any in class 'I2Cdev'
C:\Program Files (x86)\Arduino\libraries\I2Cdev/I2Cdev.h:97: error: candidate is: static int8_t I2Cdev::readBitsW(uint8_t, uint8_t, uint8_t, uint8_t, uint16_t_, uint16_t)
C:\Program Files (x86)\Arduino\libraries\I2Cdev\I2Cdev.cpp:153: error: prototype for 'int8_t I2Cdev::readByte(bool, uint8_t, uint8_t, uint8_t_, uint16_t)' does not match any in class 'I2Cdev'
C:\Program Files (x86)\Arduino\libraries\I2Cdev/I2Cdev.h:98: error: candidate is: static int8_t I2Cdev::readByte(uint8_t, uint8_t, uint8_t_, uint16_t)
C:\Program Files (x86)\Arduino\libraries\I2Cdev\I2Cdev.cpp:165: error: prototype for 'int8_t I2Cdev::readWord(bool, uint8_t, uint8_t, uint16_t_, uint16_t)' does not match any in class 'I2Cdev'
C:\Program Files (x86)\Arduino\libraries\I2Cdev/I2Cdev.h:99: error: candidate is: static int8_t I2Cdev::readWord(uint8_t, uint8_t, uint16_t_, uint16_t)
C:\Program Files (x86)\Arduino\libraries\I2Cdev\I2Cdev.cpp:178: error: prototype for 'int8_t I2Cdev::readBytes(bool, uint8_t, uint8_t, uint8_t, uint8_t_, uint16_t)' does not match any in class 'I2Cdev'
C:\Program Files (x86)\Arduino\libraries\I2Cdev/I2Cdev.h:100: error: candidate is: static int8_t I2Cdev::readBytes(uint8_t, uint8_t, uint8_t, uint8_t_, uint16_t)
C:\Program Files (x86)\Arduino\libraries\I2Cdev\I2Cdev.cpp:242: error: prototype for 'int8_t I2Cdev::readWords(bool, uint8_t, uint8_t, uint8_t, uint16_t_, uint16_t)' does not match any in class 'I2Cdev'
C:\Program Files (x86)\Arduino\libraries\I2Cdev/I2Cdev.h:101: error: candidate is: static int8_t I2Cdev::readWords(uint8_t, uint8_t, uint8_t, uint16_t_, uint16_t)
C:\Program Files (x86)\Arduino\libraries\I2Cdev\I2Cdev.cpp:337: error: prototype for 'bool I2Cdev::writeBit(bool, uint8_t, uint8_t, uint8_t, uint8_t)' does not match any in class 'I2Cdev'
C:\Program Files (x86)\Arduino\libraries\I2Cdev/I2Cdev.h:103: error: candidate is: static bool I2Cdev::writeBit(uint8_t, uint8_t, uint8_t, uint8_t)
C:\Program Files (x86)\Arduino\libraries\I2Cdev\I2Cdev.cpp:352: error: prototype for 'bool I2Cdev::writeBitW(bool, uint8_t, uint8_t, uint8_t, uint16_t)' does not match any in class 'I2Cdev'
C:\Program Files (x86)\Arduino\libraries\I2Cdev/I2Cdev.h:104: error: candidate is: static bool I2Cdev::writeBitW(uint8_t, uint8_t, uint8_t, uint16_t)
C:\Program Files (x86)\Arduino\libraries\I2Cdev\I2Cdev.cpp:368: error: prototype for 'bool I2Cdev::writeBits(bool, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t)' does not match any in class 'I2Cdev'
C:\Program Files (x86)\Arduino\libraries\I2Cdev/I2Cdev.h:105: error: candidate is: static bool I2Cdev::writeBits(uint8_t, uint8_t, uint8_t, uint8_t, uint8_t)
C:\Program Files (x86)\Arduino\libraries\I2Cdev\I2Cdev.cpp:401: error: prototype for 'bool I2Cdev::writeBitsW(bool, uint8_t, uint8_t, uint8_t, uint8_t, uint16_t)' does not match any in class 'I2Cdev'
C:\Program Files (x86)\Arduino\libraries\I2Cdev/I2Cdev.h:106: error: candidate is: static bool I2Cdev::writeBitsW(uint8_t, uint8_t, uint8_t, uint8_t, uint16_t)
C:\Program Files (x86)\Arduino\libraries\I2Cdev\I2Cdev.cpp:432: error: prototype for 'bool I2Cdev::writeByte(bool, uint8_t, uint8_t, uint8_t)' does not match any in class 'I2Cdev'
C:\Program Files (x86)\Arduino\libraries\I2Cdev/I2Cdev.h:107: error: candidate is: static bool I2Cdev::writeByte(uint8_t, uint8_t, uint8_t)
C:\Program Files (x86)\Arduino\libraries\I2Cdev\I2Cdev.cpp:443: error: prototype for 'bool I2Cdev::writeWord(bool, uint8_t, uint8_t, uint16_t)' does not match any in class 'I2Cdev'
C:\Program Files (x86)\Arduino\libraries\I2Cdev/I2Cdev.h:108: error: candidate is: static bool I2Cdev::writeWord(uint8_t, uint8_t, uint16_t)
C:\Program Files (x86)\Arduino\libraries\I2Cdev\I2Cdev.cpp:455: error: prototype for 'bool I2Cdev::writeBytes(bool, uint8_t, uint8_t, uint8_t, uint8_t_)' does not match any in class 'I2Cdev'
C:\Program Files (x86)\Arduino\libraries\I2Cdev/I2Cdev.h:109: error: candidate is: static bool I2Cdev::writeBytes(uint8_t, uint8_t, uint8_t, uint8_t_)
C:\Program Files (x86)\Arduino\libraries\I2Cdev\I2Cdev.cpp:514: error: prototype for 'bool I2Cdev::writeWords(bool, uint8_t, uint8_t, uint8_t, uint16_t_)' does not match any in class 'I2Cdev'
C:\Program Files (x86)\Arduino\libraries\I2Cdev/I2Cdev.h:110: error: candidate is: static bool I2Cdev::writeWords(uint8_t, uint8_t, uint8_t, uint16_t_)

MPU 9250 Support

Due to stock level, I got given a 9250 the other day instead of a 9150. However I can't work out the main differences yet to get it to work. Has anyone tried to get the 9250 working with this library? Scott

dmpInitialize() @ MPU6050_9Axis_MotionApps41.h

Wanted to test out the 9Axis DMP with my MPU9150 which works fine with MPU6050_6Axis_MotionApps20.h. Can't get it past initialization state. Code gets stuck at line 558 because getFIFOCount() always returns 0.

DEBUG_PRINTLN(F("Waiting for FIRO count >= 46..."));
while ((fifoCount = getFIFOCount()) < 46);

Here is the full debug log:

Initializing I2C devices...
Testing device connections...
MPU6050 connection successful

Send any character to begin DMP programming and demo: 
Initializing DMP...


Resetting MPU6050...
Disabling sleep mode...
Getting product ID...
Product ID = 0Selecting user bank 16...
Selecting memory byte 6...
Checking hardware revision...
Revision @ user[16][6] = A5
Resetting memory bank selection to 0...
Reading OTP bank valid flag...
OTP bank is valid!
Reading gyro offset values...
X gyro offset = 1
Y gyro offset = 2
Z gyro offset = 0
Enabling interrupt latch, clear on any read, AUX bypass enabled
Setting magnetometer mode to power-down...
Setting magnetometer mode to fuse access...
Reading mag magnetometer factory calibration...
Adjustment X/Y/Z = 0 / 0 / 0
Setting magnetometer mode to power-down...
Writing DMP code to MPU memory banks (1962 bytes)
Success! DMP code written and verified.
Configuring DMP and related settings...
Writing DMP configuration to MPU memory banks (232 bytes in config def)
Success! DMP configuration written and verified.
Setting DMP and FIFO_OFLOW interrupts enabled...
Setting sample rate to 200Hz...
Setting clock source to Z Gyro...
Setting DLPF bandwidth to 42Hz...
Setting external frame sync to TEMP_OUT_L[0]...
Setting gyro sensitivity to +/- 2000 deg/sec...
Setting DMP configuration bytes (function unknown)...
Clearing OTP Bank flag...
Setting X/Y/Z gyro offsets to previous values...
Setting X/Y/Z gyro user offsets to zero...
Writing final memory update 1/19 (function unknown)...
Writing final memory update 2/19 (function unknown)...
Resetting FIFO...
Reading FIFO count...
Current FIFO count=0
Writing final memory update 3/19 (function unknown)...
Writing final memory update 4/19 (function unknown)...
Disabling all standby flags...
Setting accelerometer sensitivity to +/- 2g...
Setting motion detection threshold to 2...
Setting zero-motion detection threshold to 156...
Setting motion detection duration to 80...
Setting zero-motion detection duration to 0...
Setting AK8975 to single measurement mode...
Setting up AK8975 read slave 0...
Setting up AK8975 write slave 2...
Setting up slave access delay...
Enabling default interrupt behavior/no bypass...
Enabling I2C master mode...
Resetting FIFO...
Rewriting I2C master mode enabled because...I don't know
Enabling and resetting DMP/FIFO...
Writing final memory update 5/19 (function unknown)...
Writing final memory update 6/19 (function unknown)...
Writing final memory update 7/19 (function unknown)...
Writing final memory update 8/19 (function unknown)...
Writing final memory update 9/19 (function unknown)...
Writing final memory update 10/19 (function unknown)...
Writing final memory update 11/19 (function unknown)...
Reading final memory update 12/19 (function unknown)...
Read bytes: 0 0 0 0 
Writing final memory update 13/19 (function unknown)...
Writing final memory update 14/19 (function unknown)...
Writing final memory update 15/19 (function unknown)...
Writing final memory update 16/19 (function unknown)...
Writing final memory update 17/19 (function unknown)...
Waiting for FIRO count >= 46...

FIFO/DMP output rate

Hello everyone,

In MPU6050_6Axis_MotionApps20.h it is stated that the FIFO output rate configured by the inv_set_fifo_rate byte has a hard-limit of 200Hz.

This is contrary to the MPU 6050 documentation, which says that

The sensor register output, FIFO output, DMP sampling (...) are all based on the Sample Rate. The Sample Rate is
generated by dividing the gyroscope output rate by SMPLRT_DIV.
Sample Rate = Gyroscope Output Rate / (1 + SMPLRT_DIV)

So isn't it true that inv_set_fifo_rate is rather a divider of the Sample Rate (SMPLRT_DIV) and not an absolute value?
And thus by setting SMPLRT_DIV and inv_set_fifo_rate to 0x00, we could indeed get DMP data at 1KhZ?

The MPU 6050 library included in the Arducopter project, implies just that:
https://github.com/diydrones/ardupilot/blob/master/libraries/AP_InertialSensor/AP_InertialSensor_MPU6000.cpp

dmp_register_write(0x02, 0x16, 0x02, regs); //D_0_22 inv_set_fifo_rate

This functions defines the rate at wich attitude data is send to FIFO
Rate: 0 => SAMPLE_RATE (ex:200Hz), 1=> SAMPLE_RATE/2 (ex:100Hz), 2=> SAMPLE_RATE/3 (ex:66Hz)

Secondly, could the FIFO be circumvented, by reading the fused data directly from the DMP register?
The documentation suggests, that this would be possible:
http://invensense.com/mems/gyro/documents/PS-MPU-6000A.pdf, p.25:

The DMP acquires data from accelerometers, gyroscopes, and additional 3rd party sensors
such as magnetometers, and processes the data.
The resulting data can be read from the DMP’s registers, or can be buffered in a FIFO.
The DMP has access to one of the MPU’s external pins, which can be used for generating interrupts.

FreeIMU Measurement Units

@jrowberg

It seems like you have some experience with the FreeIMU from Fabio. I recently purchased one, and I have been working on python scripts to translate and handle the different measurements that it's capable of. The trouble I'm having is knowing what the actual units of the outputs are. The MPU-6050 register map datasheet (link) only says that they are 16-bit 2's complement values, and (because of my lack of experience) I don't inherently know what the units are. Any ideas?

Thank you ahead of time!

MPU6050 quaternion calculation with Madgwick AHRS algorithm

Hi every one. I am new in this forum. I want to use mpu6050 to calculate quaternions and attitude by using Madgwick AHRS algorithm and kalman filter. Currently I am using MotionApps v2.0 and it is working fine for me. I tried to write my code with MotionApps but it is very unstable. I want to know how can i convert accelerometer and gyroscope raw output into real acceleration and angular rate. Thanks in advance

Separate function implementations from header files

Header files, such as "MPU6050_6Axis_MotionApps20.h" should not contain function implementations. Implementations should go to a separate .cpp file.

This is important because of the way Arduino compiles the code. If I have a multi-file sketch, then every header that I include in any file has to be additionally included from the main .ino also, otherwise the headers are not found. This leads to multiple includes of the same file and, as it is now, multiple identical implementations of DMP functions, so the code will not compile.

I have not checked if this problem exists in any other driver besides MPU6050.

MPU6050 data delay

Hello everyone, I have a problem with the mpu6050. All works quite well, but when I am not able to handle a data ready interrupt of the mpu6050 the fifo is growing and i am getting a delay on the data.

To solve this issue i tried to implement a loop that reads fifo packets until the fifocount is smaller than the packetsize. But when i do this i get crazy peaks on my signal (every third value). Do you have a solution for this?

mpu6050_problem

MPU6050_9Axis_MotionApps41.h

I use MPU6050_9Axis_MotionApps41.h but I have a question.Is the magnetometer reading raw data or fused data?Does the DMP do something to the raw data?

MPU6050_6Axis_MotionApps20.h - where is 0x01 on line 261?

Hi!
Coding-wise, I am not there yet, but I've read about "change the output rate of the DMP to something slower than 100Hz, by modifying the last byte on line 261.....The default value is 0x01, but setting it to 0x07 will give you a 25Hz rate". Looking at the file dated 5/20/2013, and fail repeatedly to locate any 0x01 in the vicinity.
Perhaps you could point to the significant byte by specifying bank # (is it in bank 7?) and its ordinal number in said bank. Or let me know what is it that am I totally misunderstanding about this.
Many thanks.
As a side bonus, perhaps you can point to a good place to read about optimizing the output rate of the DMP to my application (yet another home brewed Segway clone, done by sexagenarians).

MPU6050 with Xbee shield problem

Hi,

I am able to get the YPR with the MPU6050_dmp6.ino code on my mpu6050. However when I mount an Xbee shield and try to get the reading from the mpu6050, it doesnt give me any reading. Just wondering if you would know what the issue is ? I am using an arduino Uno.

Thank you.

MPU6050 Undocumented registers

High Jeff and congratulation for this great huge job !!

I have a question regarding MPU 6050 registers. Several registers used in MPU6050 classes are not documented in invensense doc 'MPU-6000 and MPU-6050 Register Map and Descriptions Revision 4.0' : MPU6050_RA_xyzG_OFFS_TC, MPU6050_RA_xyz_FINE_GAIN, MPU6050_RA_xyzA_OFFS_H, MPU6050_RA_xyzA_OFFS_L_TC, MPU6050_RA_xyzG_OFFS_USRH, MPU6050_RA_xyzG_OFFS_USRL, ...
The register map document 4.0 seems to be last version, so where did you get information about all these registers?
Thank you
David

Using two ADXL345's

Looks like the library is hard coded to use 0x53, but documentation says you can use 2 of them..
Can this be passed as a variable during initialization rather than hard coded?

MPU6050 OUTPUT_READABLE_WORLDACCEL

According to code documentation, OUTPUT_READABLE_WORLDACCEL should return "acceleration components with gravity removed". According to http://forum.arduino.cc/index.php?topic=133273 we're constantly seeing ~4000 values around the z-axis which seems to be the gravity value (expected ~0 instead).
Not sure this is a software issue or a misunderstanding what OUTPUT_READABLE_WORLDACCEL is supposed to do?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.