Jump to content
I2Cdevlib Forums

I connected to my MPU-9105 and it seems to be responding correctly, but all I get are zeros from the accel/gyro sensor registers and sleep mode is off


Recommended Posts

Hi there,

 

I've been having a lot of issues with the 9150, I attempting to interface between a C8051F411 and the MPU-9150. I have successfully inmplemented the I2C buss communication and can talk to the device, I can comfortably read and write to most registers however if I read and write to the accel/gyro sensor registers all I get back is zeros.

 

Obviously my first thought was the sleep mode, however I check and I am deffinatly setting the PWR_MGMT_1 register to 0x02 in my code, and more importantly if I read the register back to check the value I can confirm it has been set correctly.

 

I set the following registers

    SMB_Write_To_Register (REG_PWR_MGMT_1, PWR_MGMT_1_RESET);	// resets the chip
    for (i=0;i<20000;i++);
    SMB_Write_To_Register (PWR_MGMT_1, 0x02);
    for (i=0;i<20000;i++);   
    SMB_Write_To_Register (SMPRT_DIV, 0x07);
    SMB_Write_To_Register (CONFIG, 0x00);
    SMB_Write_To_Register (GYRO_CONFIG, 0x00);
    SMB_Write_To_Register (ACCEL_CONFIG, 0x00);
    SMB_Write_To_Register (FF_THR, 0x00);
    SMB_Write_To_Register (FF_DUR, 0x00);
    SMB_Write_To_Register (MOT_THR, 0x00);
    SMB_Write_To_Register (MOT_DUR, 0x00);
    SMB_Write_To_Register (ZRMOT_THR, 0x00);
    SMB_Write_To_Register (ZRMOT_DUR, 0x00);
    SMB_Write_To_Register (FIFO_EN, 0x00);
    SMB_Write_To_Register (I2C_MST_CTRL, 0x00);
    SMB_Write_To_Register (I2C_SLV0_ADDR, 0x00);
    SMB_Write_To_Register (I2C_SLV0_REG, 0x00);
    SMB_Write_To_Register (I2C_SLV0_CTRL, 0x00);
    SMB_Write_To_Register (I2C_SLV1_ADDR, 0x00);
    SMB_Write_To_Register (I2C_SLV1_REG, 0x00);
    SMB_Write_To_Register (I2C_SLV1_CTRL, 0x00);
    SMB_Write_To_Register (I2C_SLV2_ADDR, 0x00);
    SMB_Write_To_Register (I2C_SLV2_REG, 0x00);
    SMB_Write_To_Register (I2C_SLV2_CTRL, 0x00);
    SMB_Write_To_Register (I2C_SLV3_ADDR, 0x00);
    SMB_Write_To_Register (I2C_SLV3_REG, 0x00);
    SMB_Write_To_Register (I2C_SLV3_CTRL, 0x00);
    SMB_Write_To_Register (I2C_SLV4_ADDR, 0x00);
    SMB_Write_To_Register (I2C_SLV4_REG, 0x00);
    SMB_Write_To_Register (I2C_SLV4_DO, 0x00);
    SMB_Write_To_Register (I2C_SLV4_CTRL, 0x00);
    SMB_Write_To_Register (INT_PIN_CFG, 0x00);
    SMB_Write_To_Register (INT_ENABLE, 0x00);
    SMB_Write_To_Register (I2C_SLV0_DO, 0x00);
    SMB_Write_To_Register (I2C_SLV1_DO, 0x00);
    SMB_Write_To_Register (I2C_SLV2_DO, 0x00);
    SMB_Write_To_Register (I2C_SLV3_DO, 0x00);
    SMB_Write_To_Register (I2C_MST_DELAY_CTRL, 0x00);
    SMB_Write_To_Register (SIGNAL_PATH_RESET, 0x00);
    SMB_Write_To_Register (MOT_DETECT_CTRL, 0x00);
    SMB_Write_To_Register (USER_CTRL, 0x00);
    SMB_Write_To_Register (PWR_MGMT_2, 0x00);
    SMB_Write_To_Register (FIFO_R_W, 0x00);

The logic analyzer I have confirms that everything is getting sent correctly and I am getting acknowleges back from the MPU-9150. I've kinda run out of ideas now as to why it isn't working

 

 

Link to comment
Share on other sites

  • 2 weeks later...

Is there a particular reason you are writing to every register as part of the initialization? After a reset, they should all be in the 0x00 state automatically with the exception of PWR_MGMT_1, which defaults to sleep mode. For a simple test, can you power it on and write 0x00 to register 0x6B, and then read ACCEL_XOUT_H/L (sequentially) repeatedly to see what comes out?

 

You do have the AD0 pin tied to either GND or VDD, and (if applicable) the VIO pin also tied to VDD?

Link to comment
Share on other sites

I was writing to every register because my code wasn't working when I was only writing a few settings to it, but I thought that maybe one wan't initialising properly. However it turns out the problem was with the chip and having replaced the chip I can now read from the accelerometer and gyroscope, but the magnometer is still causing me issues.


I've determined that I should be at the address 0x0C, and I sent 0x01 to the register 0x0A before reading anything. however all I am getting back are zeros.

what are the steps that I should be doing to read from the magnometer? I assume I must be missing something.
Link to comment
Share on other sites

I haven't done much with the AK8975 operating inside the MPU-9150, but there is this sketch meant to use the AK8975 through the MPU-6010:

 

https://github.com/jrowberg/i2cdevlib/tree/master/Arduino/AK8975/Examples/AK8975_MPUEVB_heading

 

The register map for the device is here:

 

http://www.i2cdevlib.com/devices/ak8975#registers

 

The same code applies to the 9150, but I think it needs to be modified for the different slave address.

Link to comment
Share on other sites

  • 1 year later...
  • 4 months later...

Hi Jeff,

 

I have been using Mpu9150 and I am able to get the data from registers.

But the problem is I am getting some junk (corrupted) data from one or all of the six data registers of accelerometer.

The log looks like this:

 

 
  MPU9150 Accelerometer Sensor Loaded
 
 
####### mpu9150 probe called ############# 
  ####### mpu9150_probe:558 Read ID:=68
####### mpu9150_probe:578 
input: mpu9150 as /devices/virtual/input/input2
####### mpu9150_probe:603 
####### Mpu9150 probe finished
 
0:0xfffffff4 1:0xffffffbc 2:0x2 3:0xfffffff4 4:0xffffffbd 5:0x2c 
ax:-68 ay:-12 az:-17108
 
0:0xfffffff4 1:0x40 2:0x2 3:0xffffffec 4:0xffffffbd 5:0x1c 
ax:-3008 ay:-20 az:-17124
 
0:0xfffffff4 1:0x48 2:0x2 3:0xffffffc0 4:0xffffffbc 5:0xffffffc8 
ax:-3000 ay:-64 az:-56
 
0:0xfffffff4 1:0x70 2:0x3 3:0x44 4:0xffffffbc 5:0xffffffa0 
ax:-2960 ay:836 az:-96
 
0:0xfffffff4 1:0x64 2:0x3 3:0x1c 4:0xffffffbc 5:0xffffffc0 
ax:-2972 ay:796 az:-64
 
0:0xfffffff4 1:0xffffffa0 2:0x3 3:0x20 4:0xffffffbd 5:0xffffff84 
ax:-96 ay:800 az:-124
 
0:0xfffffff4 1:0x40 2:0x2 3:0xffffffcc 4:0xffffffbc 5:0xffffffac 
ax:-3008 ay:-52 az:-84
 
0:0xfffffff4 1:0x74 2:0x2 3:0xffffffd4 4:0xffffffbc 5:0xffffffc4 
ax:-2956 ay:-44 az:-60
 
0:0xfffffff4 1:0x1c 2:0x2 3:0xffffffb8 4:0xffffffbc 5:0xffffffa8 
ax:-3044 ay:-72 az:-88
 
0:0xfffffff4 1:0x78 2:0x2 3:0xfffffff0 4:0xffffffbd 5:0x10 
ax:-2952 ay:-16 az:-17136
 
0:0xfffffff4 1:0x38 2:0x2 3:0xffffff90 4:0xffffffbc 5:0xffffffac 
ax:-3016 ay:-112 az:-84
 
0:0xfffffff4 1:0x50 2:0x2 3:0xffffffe8 4:0xffffffbd 5:0x34 
ax:-2992 ay:-24 az:-17100
 
0:0xfffffff4 1:0xffffff9c 2:0x2 3:0xffffff98 4:0xffffffbc 5:0xffffffc8 
ax:-100 ay:-104 az:-56
 
0:0xfffffff4 1:0xffffffdc 2:0x2 3:0xffffffdc 4:0xffffffbc 5:0xfffffffc 
ax:-36 ay:-36 az:-4
 
0:0xfffffff4 1:0x60 2:0x3 3:0x24 4:0xffffffbc 5:0x7c 
ax:-2976 ay:804 az:-17284
 
0:0xfffffff4 1:0x18 2:0x2 3:0xffffff9c 4:0xffffffbd 5:0x0 
ax:-3048 ay:-100 az:-17152
 
0:0xfffffff4 1:0x74 2:0x2 3:0xfffffff0 4:0xffffffbc 5:0xffffffe4 
ax:-2956 ay:-16 az:-28
 
0:0xfffffff4 1:0x58 2:0x2 3:0xffffffcc 4:0xffffffbc 5:0xffffffcc 
ax:-2984 ay:-52 az:-52
 
0:0xfffffff4 1:0xffffffac 2:0x2 3:0xffffffe0 4:0xffffffbc 5:0xffffffa4 
ax:-84 ay:-32 az:-92
 
0:0xfffffff4 1:0x38 2:0x2 3:0xffffff84 4:0xffffffbd 5:0xffffffb4 
ax:-3016 ay:-124 az:-76
 
0:0xfffffff4 1:0x58 2:0x2 3:0xffffffc0 4:0xffffffbc 5:0xffffffb0 
ax:-2984 ay:-64 az:-80
 
0:0xfffffff4 1:0xffffffa4 2:0x2 3:0xffffffcc 4:0xffffffbc 5:0xffffff88 
ax:-92 ay:-52 az:-120
 
0:0xfffffff4 1:0xffffff94 2:0x2 3:0xffffffc0 4:0xffffffbc 5:0xfffffff0 
ax:-108 ay:-64 az:-16
 
0:0xfffffff4 1:0x6c 2:0x2 3:0xffffffe0 4:0xffffffbd 5:0x18 
ax:-2964 ay:-32 az:-17128
 
0:0xfffffff4 1:0xffffffb8 2:0x3 3:0x0 4:0xffffffbc 5:0xffffffd8 
ax:-72 ay:768 az:-40
 
0:0xfffffff4 1:0xffffff90 2:0x3 3:0x2c 4:0xffffffbd 5:0xffffffd0 
ax:-112 ay:812 az:-48
 
0:0xfffffff4 1:0x78 2:0x2 3:0xfffffff8 4:0xffffffb9 5:0xffffffd8 
ax:-2952 ay:-8 az:-40
 
0:0xfffffff4 1:0x40 2:0x3 3:0x48 4:0xffffffba 5:0xffffffd4 
ax:-3008 ay:840 az:-44
 
0:0xfffffff4 1:0x48 2:0x3 3:0x24 4:0xffffffbb 5:0xffffffc4 
ax:-3000 ay:804 az:-60
 
0:0xfffffff4 1:0xffffff8c 2:0x2 3:0xffffffc8 4:0xffffffbd 5:0xffffffac 
ax:-116 ay:-56 az:-84
 
0:0xfffffff4 1:0xffffff90 2:0x2 3:0xffffff8c 4:0xffffffbd 5:0x68 
ax:-112 ay:-116 az:-17048
 
 
Please suggest me in solving this issue.
 
Regards,
Shyam Kumar
Link to comment
Share on other sites

  • 2 months later...

Jeff, I recently got a 10 DOF board with InvenSense new MPU9255. Do you think code and libraries used for MPU9150 could be ported to this new chip without re-coding (for only data acquisition, like read quaternion out from FIFO)?

 

 

If anybody has experience of using MPU9255?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...