Comments: 9DoF Razor IMU M0 Hookup Guide

Pages

Looking for answers to technical questions?

We welcome your comments and suggestions below. However, if you are looking for solutions to technical questions please see our Technical Assistance page.

  • leforban / about 7 years ago / 4

    There's an important drift on euler angles. Does the fusion algorithm is embedded in the DMP? is there's a EKF algorithm perfomed? How to enhance accuracy? the gyr calibration seems not to have any effect on accuracy... may anyone confirm this?

    • Member #931442 / about 7 years ago / 2

      The drift also occurs in quaternions. I am working on an important project and the gyro drift is killing me. I wish I could adjust the fusion algorithm so that the gyroscope had little or no effect, but I can't control that. I also tried the gyro calibration and saw no difference in the data. I would love if there was code for a fusion algorithm that was customizable. Any help would be appreciated.

      • Member #1105908 / about 7 years ago / 1

        I have found the drift is a significant problem, too. Besides, the roll angle measurement is not correct (the value seems to be doubled, i.e., if it rolls 45 degrees, it would show the roll angle is 90 deg). But anyway, have you found a solution to get accurate Euler angles or quaternions? I used to use another 9dof razor imu (SEN-10736), which is retired but gave very good orientation measures.

        • Member #914468 / about 7 years ago / 1

          I'm seeing the same thing! Would love to see a fix to this problem.

  • stevenblake / about 7 years ago / 2

    I find that the pitch and roll angles don’t seem to be independent. I’m using the firmware from the hookup guide that lets you turn the Euler angles on and off with the ‘e’ command and while the yaw seems right, the others are confounded. If you rotate the board about the x axis, the y axis changes significantly as well and vice versa. But rotating about z (laying board on table and twisting) only affects the z axis. Any idea why this is? It’s not very useful if you can’t separate the axes…

    • Member #592982 / about 7 years ago / 2

      I have the same issue.

    • Member #469780 / about 6 years ago / 1

      I ran into the same problem. For me it turned out the pitch roll and yaw angles were relative to 'world' space, not the board itself.

      For example if you face the board 'east' then what seems like it should be pitch is now roll if that makes sense.

      There is code that converts Quaternions to body-Euler angles on Wikipedia here: https://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles

      A user farther down linked to the forum post here: https://forum.sparkfun.com/viewtopic.php?f=14&t=45516&hilit=9dof+razor+M0

    • I have the same issue

  • -------------------- Tech Support Tips/Troubleshooting/Common Issues --------------------

    Serial Output Through Hardware UART pins

    The default test code does not output serial data automatically to the hardware Tx and Rx pins. It currently outputs to the SerialUSB port (i.e. the Arduino Serial Monitor). To adjust for the Hardware Serial UART pins, adjust the config.h file on line 25 to print to the Serial1 port (i.e. pin 0 for Rx and pin 1 for Tx):

    #define LOG_PORT SERIAL_PORT_USBVIRTUAL
    

    to

    #define LOG_PORT SERIAL_PORT_HARDWARE
    

    Additionally, the default firmware is currently waiting for a "$" under our QC test procedures so you would need to comment out line 131 in the _9DoF_Razor_M0_Firmware.ino by changing:

    Serial1.begin(9600);
    

    to

    //Serial1.begin(9600);
    

    Additionally, you need to comment out line 163 in the _9DoF_Razor_M0_Firmware.ino. We recommend commenting out this section of code by adding a //'s where it says:

    if ( Serial1.available() )
    {
    if ( Serial1.read() == '$' ) production_testing();
    }
    

    After commenting out the lines, it should look like like the following:

    //if ( Serial1.available() )
    //{
    //  if ( Serial1.read() == '$' ) production_testing();
    //}
    

    Be sure to change the baud rate when you initialize the serial port to match the receiving serial device. The default is 115200 baud. By changing a few lines and printing the string to one of the hardware UARTs, the other serial UART that is connected can read the serial data. At a minimum, make sure to connect GND-GND, Tx-RX, and Rx-Tx. This is assuming that you are connecting the 9DoF Razor to a 3.3V device. If the other serial device can be powered at 3.3V, you can connect it to the 9DoF Razor's 3.3V pin.

    If you have not used a serial UART before, try looking at this tutorial for more information about serial communication and UARTs.

    Problems Uploading

    If you are having problems uploading to the SAMD21, you can try to set the board into bootloader mode. With any AVR device that has a built in CDC (i.e. the Atmega32U4 bootloaded with Arduino on the Pro Micro, FioV3, LilyPad Arduino USB, etc), there should be an option to place the board into bootloader mode if you brick the board. Try following the " Troubleshooting " note listed in the tutorial:

    If your 9DoF Razor IMU won’t enter the bootloader, or take new code, you can force it into the bootloader by holding the SCL pin LOW on start up. Flip the IMU’s switch off, use a jumper wire to connect SCL to GND, and turn the switch back on. While in the bootloader, the blue pin 13 LED should remain illuminated.
    

    You can also ground the tiny plated through hole on the SWD programming pins. Just look at the 9DOF Razor IMU M0 Eagle files to determine the "RESET" pin using the eyeball tool. You can place the SAMD21 in bootloader mode by grounding the RESET pin 2x.

    Arduino Compile Error

    If you are having problems uploading to the 9DOF Razor and you receive this error:

    Arduino: 1.8.2 (Windows 8.1), Board: "SparkFun 9DoF Razor IMU M0"
    
    In file included from sketch_feb14b.ino:33:0:
    
    C:\Users\...\AppData\Roaming\Arduino15\packages\SparkFun\hardware\samd\1.3.0\cores\arduino/Arduino.h:48:17: fatal error: sam.h: No such file or directory
    
    #include "sam.h"
    
    ^
    
    compilation terminated.
    
    exit status 1
    Error compiling for board SparkFun 9DoF Razor IMU M0.
    

    Make sure that you have also installed the SAMD21 Arduino board definitions as stated in the tutorial => https://learn.sparkfun.com/tutorials/9dof-razor-imu-m0-hookup-guide/installing-the-9dof-razor-arduino-core . It's also possible that there is something incompatible with the Arduino IDE that you are using. The error above used Arduino.cc's IDE v1.8.2 and the SAMD21 board definitions and It was resolved by ensuring that the board versions were up to date.

    If there are other compile issues, try checking out the SAMD21 compile errors listed for the other development boards here => https://learn.sparkfun.com/tutorials/samd21-minidev-breakout-hookup-guide/discuss#comment-56a7c3ccce395f451b8b4574 .

    • Member #1295547 / about 6 years ago / 1

      I´m facing a Compile Error: C:\Users\oabdelha\Desktop_9DoF_Razor_M0_Firmware_9DoF_Razor_M0_Firmware.ino:30:33: fatal error: SparkFunMPU9250-DMP.h: No such file or directory

      #include <SparkFunMPU9250-DMP.h>

                                   ^
      

      compilation terminated.

      exit status 1 Error compiling for board SparkFun 9DoF Razor IMU M0.


      Things I have tried:

      1. I deleted the folder "Arduino15"
      2. I uninstalled the the SparkFun Board Definition and install it again.
      3. Everything has the latest update IDE 1.8.5, Sparkfun SAMD board version 1.4.

      Please give me any advise to solve this problem.

    • Member #1094814 / about 7 years ago / 1

      "Serial Output through Hardware UART pins

      The default test code does not output serial data automatically to the hardware Tx and Rx pins. ...."

      All I'm after is the identical data I get from the USB serial interface to be sent via the TX RX- so I can tap this from Bluetooth serial using a Bluetooth Mate Gold. Has anybody made a mode of the default test code for this? or can you suggest what I need to add? I'm not a proficient Arduino programmer- just hoping to get the raw sensor data into Max/MSP via serial (bluetooth). I can do all the max bit if I can get the IMU M0 to output the sensor data via the Tx and Rx pins...

      Any help most appreciated!

      Cheers

      ~Fold

      • Member #1094814 / about 7 years ago * / 1

        Can I just change the log port below?: (from config.h) //////////////////////// // Serial Port Config // ////////////////////////

        define ENABLE_UART_LOGGING true

        // Select the Serial port to log to. Either SERIAL_PORT_USBVIRTUAL // or LOG_PORT SERIAL_PORT_HARDWARE (SerialUSB or Serial1)

        define LOG_PORT SERIAL_PORT_USBVIRTUAL

        define SERIAL_BAUD_RATE 115200 // Serial port baud

        EDIT: Ive tried LOG_PORT SERIAL_PORT_HARDWARE and LOG_PORT Serial1 - but still nothing from tx/rx via bluetooth (although this did stop the data coming in over direct serial comms, so on the right track?). Cheers

        • Sorry for the delay in reply. I just noticed your comment. I updated my comment to clarify. You need to change:

          #define LOG_PORT SERIAL_PORT_USBVIRTUAL
          

          to

          #define LOG_PORT SERIAL_PORT_HARDWARE
          

          It's defined somewhere as Serial1 so that the code where it says LOG_PORT.println() would be essentially using Serial1.print(). Then you need to comment out a few lines where it uses the production test code and ensure that you are connecting at a minimum GND-GND, Tx-RX, and Rx-Tx for serial. Make sure that the baud rate is 115200. I tested this out with a 3.3V FTDI connected to the hardware UART of the 9DoF Razor and it worked as expected.

  • Member #1652376 / about 3 years ago / 1

    Please someone help me, what is the simple code for the arduino to read the serial data from the imu sensor? I'm still a beginer and I've tried so many code to read the data with UART connection but still nothing happened. It would be helpful if someone give me a simple code for my problem, i'm using arduino mega. Thanks a lot.

  • Dom10329 / about 4 years ago / 1

    Hi. I tried to connect the Razor M0 to an RV-8803 (BOB-16281) board. The connections are correct and so far, I combined the setup code from Example2-Print_Time (from SparkFun_RV8803 library) to the MPU9250_Basic code (from SparkFunMPU9250-DMP library). My program seems to get stuck at the initialization code of the RTC. They have different I2C addresses right? What code should I change to get it started? Thanks.

    • santaimpersonator / about 4 years ago / 1

      Hi there, it sounds like you are looking for technical assistance. Please use the link in the banner above, to get started with posting a topic in our forums. Our technical support team will do their best to assist you.

      That being said, keep in mind that we don't offer consultation services for custom code.

  • Member #879280 / about 5 years ago / 1

    Is it possible to just poll the accelerometer? I don't want the DMP. I don't want quaternions. I JUST want the accel data as close to 1Khz sampling rate as possible.

    Please let me know if this can happen.

    • santaimpersonator / about 5 years ago / 1

      Hi there, it sounds like you are looking for technical assistance. Please use the link in the banner above, to get started with posting a topic in our forums. Our technical support team will do their best to assist you.

      Yes, that is specified in the example firmware section. Unfortunately, the log rate is specified at:

      "Adjust log rate in 10Hz increments between 1-100Hz (1, 10, 20, ..., 100)"

  • Member #1524102 / about 5 years ago / 1

    Followed the set up tutorial for pushing the firmware to the 9DOF Razor IMU MO. When attempting to compile and upload I get the following:

    C:\Users...\AppData\Roaming\Arduino15\packages\SparkFun\hardware\samd\1.3.0\cores\arduino/Arduino.h:48:17: fatal error: sam.h: No such file or directory

    include "sam.h"

    It seems like the AMTEL tools for the CMSIS path isn't added when trying to use the Sparkfun board. If I switch to the board to a Arduino M0, the code compiles, but hits an error when uploading (as expected). This means that the Arduino SAMD package is installed and running, but the Sparkfun SAMD Board package cant find its dependancies.

    I'm currently using Windows 10. I have tried rolling back the Arduino IDE and Packages to the versions specified in the guide, but that didn't help. How do I go about solving this issue?

    JV

    • santaimpersonator / about 5 years ago / 1

      Hi there, it sounds like you are looking for technical assistance. Please use the link in the banner above, to get started with posting a topic in our forums. Once you have posted a new topic, our technical support team will do what they can to help.

      That being said, if you installed the latest SAMD board definitions (version 1.6.0 or 1.6.1... after 1.5.4) someone goofed in the update the other day. It is fixed now, you should be able to roll back the version and re-update the board definitions. If you continue to have issues, please post a new topic in our forums and our technical support team will look into the issue further.

  • Member #1468246 / about 5 years ago / 1

    hello, what is the reference of the Vbat connector? thanks

  • Member #1396792 / about 6 years ago / 1

    Dear all, I bought the Sparkfun Razor imu m0 to compare its results with an industrial optical motion tracking system ( double integration to extract trajectory plus euler angles). The IMU will be used on a model falling in the air from about 3m height and then impacting on the water. I would like to add to my logs an analog input: a voltage signal ranging from 0 to 5v, sampled @100hz like the rest of the imu data. As I am totally new to arduino I kindly ask you a suggestion of how and where to modify the code to add the voltage read to the log file data output and to the serial monitor. Thank you!

  • Member #504401 / about 6 years ago * / 1

    After adding this line

    dmpFeatureMask |= DMP_FEATURE_GYRO_CAL;
    

    to the below code segment in 9DoF_Razor_M0_Firmware.ino, the drifting issue is solved

    // Configure digital motion processor. Use the FIFO to get
    // data from the DMP.
    unsigned short dmpFeatureMask = 0;
    if (ENABLE_GYRO_CALIBRATION)
    {
      // Gyro calibration re-calibrates the gyro after a set amount
      // of no motion detected
      dmpFeatureMask |= DMP_FEATURE_SEND_CAL_GYRO;
      dmpFeatureMask |= DMP_FEATURE_GYRO_CAL; // IMPORTANT Note: Need to add this to enable gyro calibration
    }
    

  • Roach / about 6 years ago * / 1

    The board isn't showing up in the Arduino IDE when I plug it into my mac (running High Sierra 10.13.4). It also isn't showing up in /dev/tty.usb*. Although it IS showing up in the USB 3.0 Device tree, in System Information. Do I need to install any additional drivers in order to be able to see this board as a serial device?

    EDIT: Nevermind, figured it out The board was being "captured" by a VM, running in the background.

  • Member #471024 / about 6 years ago / 1

    I'm trying to get DMP library examples (Specifically DMP_Quaternion) to work on FioV3. Changed output to Serial1, got it to compile and upload, which turned Fio into a brick. I can reset it back and download a different code, the one from MPU9250 hookup guide works well, but not DMP. Any help is greatly appreciated.

  • Member #1295547 / about 6 years ago / 1

    I´m facing a Compile Error:

    C:\Users\oabdelha\Desktop_9DoF_Razor_M0_Firmware_9DoF_Razor_M0_Firmware.ino:30:33: fatal error: SparkFunMPU9250-DMP.h: No such file or directory

    #include <SparkFunMPU9250-DMP.h>

                                 ^
    

    compilation terminated.

    exit status 1 Error compiling for board SparkFun 9DoF Razor IMU M0.


    Thing I have tried:

    1. I deleted the folder "Arduino15"
    2. I uninstalled the the SparkFun Board Definition and install it again.
    3. Everything has the latest update IDE 1.8.5, Sparkfun SAMD board version 1.4.

    Please give me any advise to solve this problem.

    • It looks like you have commented the same issue two times. Try looking at my response above.

  • Member #1276029 / about 6 years ago / 1

    I have the same problem as everyone. the euler angle are not independent. Is someone make the MPU-9250 working correctly with the SAMD21 ? It is a shame to buy something that don't works correctly... Thanks you

    • Member #469780 / about 6 years ago / 1

      I ran into the same problem. For me it turned out the pitch roll and yaw angles were relative to 'world' space, not the board itself.

      For example if you face the board 'east' then what seems like it should be pitch is now roll if that makes sense.

      There is code that converts Quaternions to body-Euler angles on Wikipedia here: https://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles

      A user farther down linked to the forum post here: https://forum.sparkfun.com/viewtopic.php?f=14&t=45516&hilit=9dof+razor+M0

  • Does 'raw accelerometer data' imply that it is not calibrated ?

  • Tecwyn Twmffat / about 6 years ago / 1

    I'm struggling getting this device to communicate with my Arduino Due through I2C. Monitoring the Razor on the serial port, as soon as I connect the Due to SDA/SCL the Razor seems to crash. The Due is not even turned on. Same happens when powered up. Any ideas?

    • Member #978968 / about 6 years ago / 1

      I'm facing the same problem, have you solved it ?

  • Member #1033314 / about 7 years ago / 1

    Hi Everyone, I was having the same drift errors on the Euler angles. This forum post helped a bunch. https://forum.sparkfun.com/viewtopic.php?f=14&t=45516&hilit=9dof+razor+M0

  • Member #1187415 / about 7 years ago * / 1

    I cannot make any sense of the data from the demo code. I can see drift from the gyros, but the heading can rotate a full 360 degrees over time. Investigation makes me suspect the magnetics. As a basic test (running the demo code) I should be able to point each of the X/Y/Z axis in the direction of North and get the other 2 axis at near zero (North is in the direction of Mag north and at an angle equal to the 'dip' or inclination - about -60 degrees here in Aus). Should be able to then flip the direction and get -ve the same value. (Much like one can do with the acceleration by putting it in various up/down orientations (Which by the way looks fine)

    Numbers dont behave in the slightest like this.

    Another test is to just output 'Heading', which by the code is just "heading = atan2(mx, my);" For any orientation - I am only able to get numbers between about 355 degrees through to 15 degrees ( only a 20 degree range)

    Given the detail of the code I have to conclude that probably the chip is faulty. Wondering if anyone else with problems can check this in the interests of seeing if there is maybe a common faulty batch or similar.

  • Does the dmp use calibrated accelerometer and gyroscope data to calculate the quarternions, is calibrated data required for reliable quarternions ?

  • Member #1172903 / about 7 years ago / 1

    When flashing the IMU, it never succeeds the first time. It goes into a weird mode where the blue light slowly lights up and then slowly turn off, like a breathing mode. And after 5 minutes of sitting like this, if I try to flash it successfully flashes. Anyone encounter a problem similar to this?

  • Member #1172903 / about 7 years ago / 1

    Hey guys there is a serious issue with playing around with the sampling rate and Digital Low Pass Filter (DLPF) frequencies: First, read this: https://github.com/bolderflight/MPU9250

    in the section where the DLPF bandwidth is discussed, you'll notice that you need to have an update rate 2x higher than the DLPF frequency.

    Second, as long as you're using the DMP, your maximum accelerometer and gyro sampling frequency is tied to 200Hz since that is the maximum frequency for the DMP. If you try any frequency above that, you will encounter significant drift because the DMP cannot keep up with the sensors, and thus cannot correct any drift.

    Hence, you need to keep your accelerometer and gyro sampling frequency at or below the DMP sampling rate, and the DLPF needs to be less than half of the accelerometer and gyro sampling rate. Hope this helps people around.

  • Member #1093408 / about 7 years ago * / 1

    I'd like to configure pins 10-13 as an SPI interface as mentioned briefly in this guide. As a mechanical engineer, I don't have the best insight as far as programming. Can anyone offer some insight as to how I can accomplish this? Specifically, I've been trying to interface the IMU with a SparkFun Transceiver Breakout - nRF24L01+.

    Any suggestions would be appreciated. Thank you.

  • Member #881562 / about 7 years ago / 1

    Thanks for the awesome work on this library! I'm attempting to use this on an Arduino MKR1000 with a SparkFun MPU-9250 Breakout Board, the issue I'm having is that after running for a given amount of time, the sketch stops running for the MPU9250_DMP_quaternion example.I am assuming that it has stoped running based on adding a Serial print within the loop outside of any conditional statements which doesn't print. The time that it runs correctly, outputting data to the serial port. is inversely related to the DMP FIFO rate, i.e the higher the rate the less time it runs. I was wondering whether this could be an issue relating to porting the library on the Arduino MKR100?


If you've found an issue with this tutorial content, please send us your feedback!