jrowberg / i2cdevlib

I2C device library collection for AVR/Arduino or other C++-based MCUs
http://www.i2cdevlib.com
3.94k stars 7.51k forks source link

FIFO/DMP output rate #27

Closed janeczku closed 3 years ago

janeczku commented 11 years ago

Hello everyone,

In MPU6050_6Axis_MotionApps20.h it is stated that the FIFO output rate configured by the inv_set_fifo_rate byte has a hard-limit of 200Hz.

This is contrary to the MPU 6050 documentation, which says that

The sensor register output, FIFO output, DMP sampling (...) are all based on the Sample Rate. The Sample Rate is generated by dividing the gyroscope output rate by SMPLRT_DIV. Sample Rate = Gyroscope Output Rate / (1 + SMPLRT_DIV)

So isn't it true that _inv_set_fiforate is rather a divider of the Sample Rate (SMPLRT_DIV) and not an absolute value? And thus by setting SMPLRT_DIV and inv_set_fifo_rate to 0x00, we could indeed get DMP data at 1KhZ?

The MPU 6050 library included in the Arducopter project, implies just that: https://github.com/diydrones/ardupilot/blob/master/libraries/AP_InertialSensor/AP_InertialSensor_MPU6000.cpp

dmp_register_write(0x02, 0x16, 0x02, regs); //D_0_22 inv_set_fifo_rate

This functions defines the rate at wich attitude data is send to FIFO Rate: 0 => SAMPLE_RATE (ex:200Hz), 1=> SAMPLE_RATE/2 (ex:100Hz), 2=> SAMPLE_RATE/3 (ex:66Hz)

Secondly, could the FIFO be circumvented, by reading the fused data directly from the DMP register? The documentation suggests, that this would be possible: http://invensense.com/mems/gyro/documents/PS-MPU-6000A.pdf, p.25:

The DMP acquires data from accelerometers, gyroscopes, and additional 3rd party sensors such as magnetometers, and processes the data. The resulting data can be read from the DMP’s registers, or can be buffered in a FIFO. The DMP has access to one of the MPU’s external pins, which can be used for generating interrupts.

zarthcode commented 11 years ago

Because the DMP is doing an actual calculation, I suspect that the hardware that provides the Quat can only run at at a certain speed. Hence the limitation. (But, given recent history, I wouldn't be surprised if this limit is arbitrary)

OTOH, I'm super-interested in seeing if I could circumvent the FIFO entirely in favor of a register-read operation! It would solve quite a few issues I'm having with the DMP itself.

chandini commented 11 years ago

how to read dmp values and what are DMP register address......pls help me

vcortex91 commented 7 years ago

Not to resurrect and old thread, but configuring the MPU6500 in my MPU9250, I did get DMP FIFO rates that I did not expect based on all library implementations I have seen. Following are DMP sampling frequencies when setting gyro to 1kHz (DLPF_CFG to 0x01) since I read in the datasheet that DMP would not function if there was an 8kHz sampling rate, which is default for gyro. Note that accel sampling rate is 1kHz by default.

div hz_expected hz_actual 0 200 800 1 100 400 3 50 200 4 40 160 7 25 100 15 12.5 50

Therefore, you can see that the rate I got was 4x what I expected. I accounted for this in my code, and things seem to work fine, but it is a bit unsettling why this seems to contradict what I have seen for MPU6050 libraries, as well as what Sparkfun has for their MPU9250 (MPU6500) library.

jrowberg commented 3 years ago

Closing ancient issue for cleanup.