Maybe you are interested in my Arduino sketch specifically written for the MPU-6000 on the ArduIMU+ V3 board from 3DRobotics Inc. It is attached to this post (v053_MPU6000_DMP6_SPI.ino). Please read the header carefully because it contains a lot of useful information.My sketch is based on Jeff Rowberg's MPU6050_DMP6_I2C sketch which makes use of the Digital Motion Processor to obtain the quaternion values from the MPU, and from there derives roll, pitch and yaw without almost any drift. My sketch is a translation of Jeff's sketch and also uses the DMP, but makes use of the SPI protocol i.s.o. the I2C protocol for transferring data (on ArduIMU+ V3 "MPU-6000 uses SPI for max performance"). My sketch works perfectly with the Teapot demo also from Jeff, I only corrected the axis ((Teapot_ArduIMU_V3.pde - attached). Please let me know if you like it. It took me a little over 100 hours to write and test it.

v053_MPU6000_DMP6_SPI.ino

Teapot_ArduIMU_V3.pde

You need to be a member of diydrones to add comments!

Join diydrones

Replies

  • Just an FYI - https://github.com/tsimon57/I2CdevSPI



    Tom said:

    For the APM with the ATMEGA2560 also be sure the change it to use INT6 in the attach interrupt. It seems to compile just fine that way with the stock Arduino IDE.

    // attachInterrupt(interrupt, function, mode) specifies a function to call when an external interrupt occurs
    // ArduIMU+ V3 has ATMEGA328 INT0 / D2 pin 32 (input) connected to MPU-6000 INT pin 12 (output) - Different for the ATMEGA2560
        attachInterrupt(6, dmpDataReady, RISING); // the 6 points correctly to INT6 / PE3
    // -> if there is an interrupt from MPU-6000 to ATMEGA328, boolean mpuInterrupt will be made true

    tsimon57/I2CdevSPI
    New I2Cdev lib that runs on SPI. Contribute to tsimon57/I2CdevSPI development by creating an account on GitHub.
  • So what's the verdict?

    Is everyone finally convinced that the DMP is a scam?

    • I wouldn't dare to say... Why do you think it is a scam?

  • see my comment below on how to make this work on the APM Mini with an ATMEGA2560

  • Thanks Martin

     I finally got it working what happened is that my voltage regulator for my APM 2.6 had blown and as such The MPU6000 was receiving 5V instead of the 3.3V required operating voltage. I remedied this problem temporarily by using a AT Mega 2560 board and connecting the the compass with the 3.3V and ground on the board therefore the AT Mega 2560 was supplying the 3.3 volts needed for the Mpu6000 in the long run I have ordered voltage regulators

    This was also the reason for the bad gyro health message I keep observing in mission planner. Once again thank you for your help much appreciated. 

    http://flight.farbird.com/2014/02/repair-blown-33v-regulator-on-ard...  helps to understand how to fix voltage regulators

    • Hi Psam,

      Nice to read that you have it all working now!

      Lucky you: MPU-6000 Absolute Maximum Ratings, Supply Voltage VDD: -0.5V to +6V, so the MPU should be undamaged by the 5V supply it accidently got. I'm not sure about the other components - but obviously now you have it working they seem to have all survived.

      Good luck repairing the board with a new 3.3 V regulator. Advise: buy +3.00 dioptry reading glasses (those cheap ones from a drugstore will do fine), this helps tremendously for this kind of miniature soldering, because compared to a normal magnifying glass you still see depth, and are not hampered by holding the magnifying glass or the need to keep the board fixed underneath it.

  • Hey Martin,

    I'm a student trying to get an MPU-6000 working with an M0 processor over SPI. I'm not familiar with arduino or "sketches", but most of this code looks like C, do you have any idea how to port it? I'd be willing to pay for the inconvenience.

    • Hello Tanner,

      Thanks for your interest in my code.

      Unfortunately, I have no coding experience with the ARM Cortex-M0 (or any ARM processor). The Arduino code is indeed C-like, so if you already have experience coding in C or C++, and combined with the comments in my code, you should be able to understand what my code is doing. However, translating it for the M0, I suspect this will be quite a job. I did the translation for Arduino from I2C to SPI (so only the bus interface protocol changed, not the Arduino coding environment), and that took over 100 hours.

      But don't let that stop you from trying!

      Most importantly you should start writing code (or find open source code) which creates the SPI protocol on the M0. I have glanced at the M0 documentation, it provides some kind of serial wire interface, and since SPI is a really simple protocol, it should not be to hard to get a SPI bus working.

      Next step will be a really good understanding of my code, and then translate it piece by piece.Test every small step (so, run the code on the M0 / MPU-6000 board), to see if it works (use a lot of debug statements), and continue building. Give every improved coding file a new number (I always start with _001), to be able to revert to a previously working one if things foul up.

      Given the amount of time that will probably be involved in this, I will not be able to do this port for you, I'm sorry.

      Do you have a specific reason why you want to use the M0 processor over an Arduino? Since for Arduino, all is readily available...

      Best regards, Martin

  • This is what I see in  the serial monitor


    $$$ dmpMemory: byte verification error
    $$$ dmpMemory: byte verification error
    $$$ dmpMemory: byte verification error
    FAILED!
    Writing DMP configuration... done.
    Verifying DMP configuration... FAILED!
    Writing DMP update 1/7 ..... done.
    Verifying DMP update 1/7 ..... success!
    Writing DMP update 2/7 ..... done.
    Verifying DMP update 2/7 ..... FAILED!

    ############# MPU-6000 Data Acquisition #############
    Initializing SPI Protocol...
    ...SPI Protocol initializing done.
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    Initializing Digital Motion Processor (DMP)...
    Writing DMP memory.......... done.
    Verifying DMP memory.......... $$$ dmpMemory: byte verification error
    $$$ dmpMemory: byte verification error
    $$$ dmpMemory: byte verification error
    $$$ dmpMemory: byte verification error
    $$$ dmpMemory: byte verification error
    $$$ dmpMemory: byte verification error
    $$$ dmpMemory: byte verification error
    $$$ dmpMemory: byte verification error
    $$$ dmpMemory: byte verification error
    $$$ dmpMemory: byte verification error
    $$$ dmpMemory: byte verification error
    $$$ dmpMemory: byte verification error
    $$$ dmpMemory: byte verification error
    $$$ dmpMemory: byte verification error
    $$$ dmpMemory: byte verification error
    $$$ dmpMemory: byte verification error
    $$$ dmpMemory: byte verification error
    $$$ dmpMemory: byte veri

    • I had the above problem as well when using the Mini APM 2.6.First be sure to change the select pin to 53 for the ATMEGA2560.

      I found a post with the solution. The barometer uses port 40 as its CS. You have to set it to output and write it high to prevent the barometer from taking control of the SPI.

      Add this right before you initialize the SPI.:

      pinMode(40, OUTPUT);
      digitalWrite(40, HIGH); 

      I also made some other changes to do a cleaner reset as per the data shoot for the MPU6000. So my test vehicle had the following for the MPU init:

      ==================

      byte dmpInitialize()
      {
      // Trigger a full device reset.
      // A small delay of ~50ms may be desirable after triggering a reset.
      DEBUG_PRINTLN(F("Resetting MPU6000..."));
      SPIwrite(0x6B, 0x80, ChipSelPin1); // DEVICE_RESET
      delay(100);
      DEBUG_PRINTLN(F("Disabling sleep mode..."));

      SPIwrite(0x68, 0x7, ChipSelPin1); // reset sensors
      delay(100); //
      SPIwrite(0x6A, 0x10 ,ChipSelPin1); // disable I2C
      // Setting the SLEEP bit in the register puts the device into very low power
      // sleep mode. In this mode, only the serial interface and internal registers
      // remain active, allowing for a very low standby current. Clearing this bit
      // puts the device back into normal mode. To save power, the individual standby
      // selections for each of the gyros should be used if any gyro axis is not used
      // by the application.
      // disable sleep mode
      SPIwrite(0x6B, 0x00, ChipSelPin1); // wake up from SLEEP
      delay(100);

      // get MPU hardware revision


      <original code resumes here>

      =========================

      This took a long time to figure out, as I had checked everything in the code twice. Now I just need a I2Cdev lib that has SPI under the hood.....

      -Tom

This reply was deleted.

Activity