jrowberg / i2cdevlib

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

? bug 9 Axis Motion Apps 41 #700

Open domenic64 opened 2 years ago

domenic64 commented 2 years ago

I am using the file MPU6050_9Axis_MotionApps41 converted to python on the mpu9250. In the fifo the data of the magnetometer are incorrect. To have the data of the readings in the fifo I changed this:

setup AK8975 (0x0E) as Slave 0 in read mode AK8963 (0x0C)

    if self.debug:print("Setting up AK8975 read slave 0...")
    bus.write_byte_data(self.address, self.MPU6050_RA_I2C_SLV0_ADDR, 0x8C) #8 readmode  C address
    bus.write_byte_data(self.address, self.MPU6050_RA_I2C_SLV0_REG, 0x02)    #origin 01 
    bus.write_byte_data(self.address, self.MPU6050_RA_I2C_SLV0_CTRL, 0xD8)  #origin 1101 1010=10byte origine DA

In this way on the fifo there are the magnetometer data always updated.

ZHomeSlice commented 2 years ago

The magnetometer only updates every 100ms the FIFO never receives the data and updates at 10ms unless changed there is a library that fuses the Magnetometer with the FIFO data but it is not loaded into the MPU6050 it is a separate file The file is libmplmpu.lib it is a binary file not readable and has several .h files to gain access to the functions. Invensense website has a developer section with all the documentation. Hope this helps. Z

domenic64 commented 2 years ago

I checked with this modification you get the correct magnetometer data in the fifo. Otherwise they are passed incorrectly. It is necessary to read from reg 0x02 of the magnetometer not from reg0x01. dmp 4.1 makes the 6x quaternion + magnetometer data available in the fifo. the fusion must be worked out externally.