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

      • 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

    • Psam, I had to change mpuinterrupt to true to get mine to work. I got the same errors until I changed that.

       

      while ((mpuInterrupt == true) && (fifoCount < packetSize))

      and then a few lines down from there, it is like this:


      mpuInterrupt = false;
      • Hi Harry and Psam, I am running an ArduIMU+ V3 on an Arduino Uno and seem to be getting the same thing as Psam. I've changed the code you have pointed out above but it unfortunately has not fixed the problem. Any help or pointers would be greatly appreciated, thank you.

        • Hello Paven,
          I don't understand: you say you are running an ArduIMU+ V3 on an Arduino Uno. But these are both hardware boards, and also completely different. You can't run hardware on hardware...
          Do you mean to say you are trying to run my code on an Arduino Uno board? If so, how did you connect the MPU-6000 to it? I suppose the MPU-6000 is on a separate break-out board then.
          Please provide more information, so that I will be able to help you if I can.
          Best regards,
          Martin

  • Hi Martin,

    First of all thanks for your code it waa a good start point for me. I have the APM 2.6 and I would like to plot  row, pitch and yaw values. I have commented in #define OUTPUT_READABLE_ROLLPITCHYAW. However when i run the sketch and use the serial monitor to view my results it give me the message shown in the word document i have attached. Any suggestions as to why this is? Thank you

    Mpu error message.docx

    • Hello Psam,

      You have the same issue as Jon-Paul, and I have described the probable solution a few replies above ^^.

      Best regards,

      Martin

  • Hi Martin,

    Came across your post whilst researching ways of integrating the onboard MPU6000 of the APM2.6 into my custom rover firmware.

    You have documented the code extremely well, thanks so much for posting.  What's your thoughts on possibilities of getting this up and running on the APM 2.6.  After changing ChipSelPin1 to 40 (having checked the example MPU6000 sketch in the AP_InitialSensor library) I spun up the example, but get so far as:

    ############# MPU-6000 Data Acquisition #############
    Initializing SPI Protocol...
    ...SPI Protocol initializing done.
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    Initializing Digital Motion Processor (DMP)...
    Resetting MPU6000...
    SPI (/CS40) reading 1 byte from register 0x6B... 0xFF (done)
    SPI (/CS40) writing 1 byte to register 0x6B... 0xFF (done)
    bit_7 set to 1
    Disabling sleep mode...
    SPI (/CS40) reading 1 byte from register 0x6B... 0xFF (done)
    SPI (/CS40) writing 1 byte to register 0x6B... 0xBF (done)
    bit_6 set to 0
    Selecting user bank 16...
    SPI (/CS40) writing 1 byte to register 0x6D... 0x70 (done)
    Selecting memory byte 6...
    SPI (/CS40) writing 1 byte to register 0x6E... 0x06 (done)
    Checking hardware revision...
    Revision @ user[16][6] = FF
    Resetting memory bank selection to 0...
    SPI (/CS40) writing 1 byte to register 0x6D... 0x00 (done)
    Reading OTP bank valid flag...
    SPI (/CS40) reading 1 byte from register 0x00... 0xFF (done)
    bit_0 = 1
    OTP bank is valid!
    Reading gyro offset TC values...
    SPI (/CS40) reading 1 byte from register 0x01... 0xFF (done)
    SPI (/CS40) reading 1 byte from register 0x02... 0xFF (done)
    SPI (/CS40) reading 1 byte from register 0x03... 0xFF (done)
    X gyro offset = 63
    Y gyro offset = 63
    Z gyro offset = 63
    ########################### Writing DMP code to MPU memory banks (1929 bytes)
    Writing DMP memory.......... @@@ write bank 0
    SPI (/CS40) writing 1 byte to register 0x6D... 0x00 (done)
    SPI (/CS40) writing 1 byte to register 0x6E... 0x00 (done)

    ...

    ...

    @@@ write bank 1
    SPI (/CS40) writing 1 byte to register 0x6D... 0x01 (done)
    SPI (/CS40) writing 1 byte to register 0x6E... 0x00 (done)

    ...

    ...

    >> read bank 6
    SPI (/CS40) writing 1 byte to register 0x6D... 0x06 (done)
    SPI (/CS40) writing 1 byte to register 0x6E... 0x00 (done)
    $$$ dmpMemory: byte verification error
    FF
    $$$ dmpMemory: byte verification error
    FF
    $$$ dmpMemory: byte verification error
    FF

    and so on, with a huge list of verification errors.

    Any thoughts on this would be most appreciated, many thanks.

    • Hello Jon-Paul,

      As you might have figured out by now (sorry for the large delay in answering your question), this is most likely because there is no, or no correct, SPI communication between your Arduino processor and the MPU-6000. The code first writes a lot of values over SPI to the MPU-6000 ("writing byte to register (done)" - lines), then starts reading the values back from the MPU and verifies them. The "$$$ dmpMemory: byte verification error" point to a verification failure, so something went wrong in either writing or reading the values to/from the MPU, or both.

      In the EAGLE files (schematic and board layout) for the APM 2.6 ( http://3drobotics.com/learn/#APM_26_Autopilot ) I can see that the /CS pin of the MPU-6000 is connected through a voltage level shifter to hardware pin 19 (PB0) of the Atmega2560 Arduino processor. Looking at the pin mapping ( http://arduino.cc/en/Hacking/PinMapping2560 ) you should use ChipSelPin1 = 53 instead of 40.

      Best regards,

      Martin

  • Hi Martin,

     

    I have a project with an arduIMU V3 and the aim is the following:

    Detect a Full Rotation around Yaw, Yaw45, Pitch, Roll Axis, and standing Flat,
    The software should set on the corresponding LED:
    No Moves (standing flat) = Yellow
    Yaw 360° = Blue
    Pitch 360° = Orange
    Roll 45 or 315° && Full Yaw Rotation = Green
    Roll 360° = Red
    Keep any of the detected movement leds ON during 10s

    I am very stuck with this project for the following reasons:

    -I have tried lots of solutions without finding any that would give me stable results(FreeIMU, DCM, I am now trying to use yours which actually give more stable results)

    -The problem is that I cannot find any software that gives me independant results for each axis, If I do a roll or a pitch, yaw always have glitches ( which would be normal for pitch since you invert the board, but it is never predictible) I can send you a copy of the traces I have got for each algorithm if you'd like.

    -I don't have much time to dedicate to this project anymore

     

    Would you be interested to finish this project?


    I am ready to pay.

     

    Thanks a lot,

     

    Best Regards.

    CrownQRPYV1.0.xlsx

  • Evan could help me, because the values ​​of my valore with angular velocity are too high for small angles. What do I do?

This reply was deleted.

Activity

DIY Robocars via Twitter
RT @TinkerGen_: "The Tinkergen MARK ($199) is my new favorite starter robocar. It’s got everything — computer vision, deep learning, sensor…
Monday
DIY Robocars via Twitter
Monday
DIY Robocars via Twitter
RT @roboton_io: Join our FREE Sumo Competition 🤖🏆 👉 https://roboton.io/ranking/vsc2020 #sumo #robot #edtech #competition #games4ed https://t.co/WOx…
Nov 16
DIY Drones via Twitter
First impressions of Tinkergen MARK robocar https://ift.tt/36IeZHc
Nov 16
DIY Robocars via Twitter
Our review of the @TinkerGen_ MARK robocar, which is the best on the market right now https://diyrobocars.com/2020/11/15/first-impressions-of-tinkergen-mark-robocar/ https://t.co/ENIlU5SfZ2
Nov 15
DIY Robocars via Twitter
RT @Ingmar_Stapel: I have now explained the OpenBot project in great detail on my blog with 12 articles step by step. I hope you enjoy read…
Nov 15
DIY Robocars via Twitter
RT @DAVGtech: This is a must attend. Click the link, follow link to read the story, sign up. #chaos2020 #digitalconnection #digitalworld ht…
Nov 15
DIY Robocars via Twitter
RT @a1k0n: Got a new chassis for outdoor races (hobbyking Quantum Vandal) but I totally didn't expect that it might cause problems for my g…
Nov 11
DIY Drones via Twitter
First impressions of the Intel OpenBot https://ift.tt/36qkVV4
Nov 10
DIY Robocars via Twitter
Nov 9
DIY Robocars via Twitter
Excellent use of cardboard instead of 3D printing! https://twitter.com/Ingmar_Stapel/status/1324960595318333441
Nov 7
DIY Robocars via Twitter
RT @chr1sa: We've got a record 50 teams competing in this month's @DIYRobocars @donkey_car virtual AI car race. Starting today at 10:00am…
Nov 7
DIY Robocars via Twitter
Nov 6
DIY Robocars via Twitter
RT @a1k0n: Car's view, using a fisheye camera. The ceiling light tracking algorithm gave me some ideas to improve ConeSLAM, and having grou…
Nov 5
DIY Robocars via Twitter
RT @a1k0n: To get ground truth I measured the rug, found the pixel coordinates of its corners, calibrated my phone camera with my standard…
Nov 5
DIY Robocars via Twitter
RT @a1k0n: @DIYRobocars is back in December, but outside. Time to reinvestigate ConeSLAM! I rigged up a quick and dirty ground-truth captur…
Nov 5
More…