I changed the 9DoF Razor IMU M0’s sampling rate with the following line of the code given in the hook-up guide: imu.setSampleRate(100); // Set sample rate to 100Hz. However, when the sampling rate is set to 100 Hz will not exceed 25 Hz and for lower sampling rates the actual sampling rate is lower.
Here are the results for a 10 Hz sampling rate:
Average sampling time: 91.583 ms
Standard deviation: 6.015 ms
Do other adjustments need to be made to get closer/constant sampling rates that are desired?
Hi Drew,
Are you adjusting the stock firmware or are you uploading your own code to the 9DoF Razor? If you are editing the stock firmware, the problem may be due to the stock parameters set by the [config file. Although that does set the sample rate to 100Hz so I’m not sure why you are seeing lower speeds if you are using the stock firmware.
Another idea is the slow rate may also be related to the I2C bus speed. You could try adjusting that in the library and then re-upload the firmware. The Wire.begin() function is called at [this line in the C++ File for the MPU-9250 DMP Library so you will need to edit that and add Wire.setClock(400000 ); after Wire.begin(); to set the bus to fast mode.
I hope this helps you troubleshoot this issue. Let us know if you continue to have issues with the sample rate or if you have any other questions or issues with the 9DoF Razor and we would be happy to help as much as we can.](SparkFun_MPU-9250-DMP_Arduino_Library/src/SparkFunMPU9250-DMP.cpp at master · sparkfun/SparkFun_MPU-9250-DMP_Arduino_Library · GitHub)](9DOF_Razor_IMU/Firmware/_9DoF_Razor_M0_Firmware/config.h at master · sparkfun/9DOF_Razor_IMU · GitHub)