kriswiner / MPU9250

Arduino sketches for MPU9250 9DoF with AHRS sensor fusion
1.03k stars 471 forks source link

Initiating DMP for MPU9250 #327

Open dhr999 opened 5 years ago

dhr999 commented 5 years ago

Hey, I'm using the MPU9250 for localization using Rpi as a single board computer. I went through the registry map of the IMU but couldn't figure out a way to initialize the Dmp. Could you please tell me how to do that and also how to interpret the output from it?

Also when i bypassed the int_config register to read the magnetometer, the output is always a constant and doesn't change no matter what I do. Could you throw some light on that part too?

Thanks a lot.

Regards

kriswiner commented 5 years ago

Nope, contact Invensense for this information.

On Tue, Nov 20, 2018 at 5:20 PM Dhruv notifications@github.com wrote:

Hey, I'm using the MPU9250 for localization using Rpi as a single board computer. I went through the registry map of the IMU but couldn't figure out a way to initialize the Dmp. Could you please tell me how to do that and also how to interpret the output from it?

Thanks a lot.

Regards

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/kriswiner/MPU9250/issues/327, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qs98geuAJMF1-gxYd0tt4iS4jfm2ks5uxKp5gaJpZM4YsOPj .

dhr999 commented 5 years ago
hxl = 0x03
hxh = 0x04
hyl = 0x05
hyh = 0x06
hzl = 0x07
hzh = 0x08
ST2 = 0x09
CNTL1 = 0x0A
ASAX = 0x10
ASAY = 0x11
ASAZ = 0x12
int_config=0x37

dev_add = 0x68
bus.write_byte_data(dev_add,int_config,0x02)

def Mag_init():
    bus.write_byte_data(mag_add,CNTL1,31)
    asax = bus.read_byte_data(mag_add,ASAX)
    asay = bus.read_byte_data(mag_add,ASAY)
    asaz = bus.read_byte_data(mag_add,ASAZ)
    bus.write_byte_data(mag_add,CNTL1,6)

mag_add = 0x0C
Mag_init()

def magnetometer(addr):
    low = bus.read_byte_data(dev_add,addr)
    high = bus.read_byte_data(dev_add,addr+1)
    value = ((high <<8) | low)
    if (value & (1 << 13)) != 0:
        value = value - (1 <<14)
    return value 

Could you please take a look at the code and tell me if I missed anything or if I am something wrong? This is the part of the code that deals with the magnetometer. I call the "magnetometer" function to read the output.

Thank you

Regards

kriswiner commented 5 years ago

No, please contact Invensense for this help.

On Tue, Nov 20, 2018 at 5:44 PM Dhruv notifications@github.com wrote:

`wia = 0x00 hxl = 0x03 hxh = 0x04 hyl = 0x05 hyh = 0x06 hzl = 0x07 hzh = 0x08 ST2 = 0x09 CNTL1 = 0x0A ASAX = 0x10 ASAY = 0x11 ASAZ = 0x12 int_config=0x37

dev_add = 0x68 bus.write_byte_data(dev_add,int_config,0x02)

def Mag_init(): bus.write_byte_data(mag_add,CNTL1,31) asax = bus.read_byte_data(mag_add,ASAX) asay = bus.read_byte_data(mag_add,ASAY) asaz = bus.read_byte_data(mag_add,ASAZ) bus.write_byte_data(mag_add,CNTL1,6)

mag_add = 0x0C Mag_init()

def magnetometer(addr): low = bus.read_byte_data(dev_add,addr) high = bus.read_byte_data(dev_add,addr+1)

value = ((high <<8) | low)

if (value & (1 << 13)) != 0: value = value - (1 <<14) return value

`

Could you please take a look at the code and tell me if I missed anything or if I am something wrong?

Thank you

Regards`

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/MPU9250/issues/327#issuecomment-440497421, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qkwuS5PNHnsY1Ay08giBrypU-2DPks5uxK_pgaJpZM4YsOPj .