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 @_JonMyer: 🚨Attention DeepRacer's including #UndergroundDeepRacer🚨 Check our our LIVE stream that including @IAM_dbro Take a few moments…
yesterday
DIY Drones via Twitter
RT @MarvelmindMaxim: Extreme precision for 60 swarming robots. #marvelmind #autonomousrobotics #robotics #swarmrobotics #rtls #ips #indoor…
Monday
DIY Drones via Twitter
RT @MarvelmindMaxim: Precise (±2cm) tracking for racing boats and autonomous boats. Works outdoor and indoor. #autonomous #AutonomousVehic…
Monday
DIY Drones via Twitter
RT @MarvelmindMaxim: Helping PixHawk folks to fly autonomous quadcopters using PX4 and ArduPilot. https://marvelmind.com/drones/ Equally suitab…
Monday
DIY Robocars via Twitter
RT @chr1sa: The @DIYRobocars @donkey_car virtual AI car race is starting in 15 minutes! Watch it live on Twitch https://www.twitch.tv/mossmann3333 htt…
Saturday
DIY Robocars via Twitter
RT @chr1sa: Don't miss our monthly @DIYRobocars @donkey_car virtual AI car race tomorrow at 10:00am PT live on Twitch. Head-to-head racing…
Jul 31
DIY Robocars via Twitter
RT @sparkfun: Our completed tutorial on building an @NVIDIA Jetson Nano-powered @Sphero RVR gets your bot up and running via teleoperation…
Jul 30
DIY Robocars via Twitter
RT @SmallpixelCar: Freeway test https://t.co/4V5tV9lhIP
Jul 29
DIY Robocars via Twitter
Very small autonomous cars racing, thanks to an overhead camera: https://control.ee.ethz.ch/research/team-projects/autonomous-rc-car-racing.html
Jul 29
DIY Robocars via Twitter
Jul 29
DIY Robocars via Twitter
Jul 29
DIY Robocars via Twitter
RT @chr1sa: Don't miss our virtual AI car race this Saturday! Real developers + virtual cars =🏎️🏎️🏎️ Head-to-head battles with thrills, sp…
Jul 28
DIY Robocars via Twitter
Jul 27
DIY Robocars via Twitter
RT @usashirou1: Jetson nano by Isaac Kaya #jetson https://t.co/Mu1N0CyQkN
Jul 23
DIY Robocars via Twitter
RT @GPUsolution: JetRacer mady by Iflytek company #JetsonNANO #Nvidia https://t.co/MimTymIwge
Jul 23
DIY Robocars via Twitter
RT @openmvcam: I love this: Mega or Mini? Image Classification on the 1MB OpenMV Cam H7 by Ish Ot Jr. in OpenMV, Edge Impulse, Internet of…
Jul 23
More…