Setting sampling rate fails in mpu6050.h

Hello all,

I have a mpu 9150 IMU sensor and I am using mpu6050.h to get IMU data.

I have used MPU6050::setRate function to set different sampling rate (0~244) and it was verified by using MPU6050::getRate function. However, when I use below codes to check sampling rate of getMotion9 function, the rate always keep around 40Hz:

mytime_pre=micros();
MPU6050.getMotion9(&ax, &ay, &az, &gx, &gy, &gz, &mx, &my, &mz);
mytime=micros();
sample_rate=mytime-mytime_pre

As far as I know, the sampling rate can be far more than 40Hz (I have disabled the low pass filter by using setDLPFMode(0). Did I do anything wrong while setting up sampling rate?

Thanks you in advanced.

The resolution of micros() is not fine enough toe measure ONE call. Record the time, call the function 100 times, and record the time. You should get different results.

PaulS:
The resolution of micros() is not fine enough toe measure ONE call. Record the time, call the function 100 times, and record the time. You should get different results.

Hello Pauls,

Thanks for reply.

Actually everytime I get a sample_rate around 40Hz...