Jump to content
I2Cdevlib Forums

joyxoy

Members
  • Posts

    1
  • Joined

  • Last visited

Everything posted by joyxoy

  1. Hi everyone. I have a very strange behaviour of MPU9150 accelerometer. I have five sensors from the same batch. Every accelerometer sensor from this batch has wrong value on y-axis (say 5000, for example). My first guess was the wrong Y-offset value for accelerometer, but each sensor has reasonable value (within 1000). The wrong value on the axis does not depend on scaling, clock source, or digital filtering (on accelerometer side) - i checked all these things. Due to this, the freefall detection doesn`t work at all, the only one way to make it work - to disable Y-axis of accelerometer (always returns 0). So my assumption is - may be there are something with MPU internals? Just to check - my code of accelerometer initialization and reading data from sensors: // wake up sensor and disable temperature sensor tmp = 0x08; i2c->writeb(MPU6050_DEFAULT_ADDRESS, MPU6050_RA_PWR_MGMT_1, tmp); //put gyroscope into standby mode tmp = 0x07; i2c->writeb(MPU6050_DEFAULT_ADDRESS, MPU6050_RA_PWR_MGMT_2, tmp); //set scale for accelerometer, disable self-test, enable HPF tmp = 0x12; i2c->writeb(MPU6050_DEFAULT_ADDRESS, MPU6050_RA_ACCEL_CONFIG, tmp); //set DLPF, 188 Hz tmp = 0x01; i2c->writeb(MPU6050_DEFAULT_ADDRESS, MPU6050_RA_CONFIG, tmp); //set sensor sampling rate to 50Hz tmp = 0x13; i2c->writeb(MPU6050_DEFAULT_ADDRESS, MPU6050_RA_SMPLRT_DIV, tmp); // set motion and freefall detection i2c->writeb(MPU6050_DEFAULT_ADDRESS, MPU6050_RA_MOT_THR, 0x06); i2c->writeb(MPU6050_DEFAULT_ADDRESS, MPU6050_RA_MOT_DUR, 0x0A); i2c->writeb(MPU6050_DEFAULT_ADDRESS, MPU6050_RA_MOT_DETECT_CTRL, 0x0F); i2c->writeb(MPU6050_DEFAULT_ADDRESS, 0x1d, 0xBF); i2c->writeb(MPU6050_DEFAULT_ADDRESS, 0x1e, 0xFF); // set interrupt config, active high, push-pull, int high until cleared by reading 58 register tmp = 0x20; i2c->writeb(MPU6050_DEFAULT_ADDRESS, MPU6050_RA_INT_PIN_CFG, tmp); // enable FF interrupt and motion detection interrupt tmp = 0xC0; i2c->writeb(MPU6050_DEFAULT_ADDRESS, MPU6050_RA_INT_ENABLE, tmp); And reading from the sensor: i2c->read(MPU6050_DEFAULT_ADDRESS, MPU6050_RA_ACCEL_XOUT_H, &buffer[0], 6); *x = (((int16_t)buffer[0]) << 8) | buffer[1]; *y = (((int16_t)buffer[2]) << 8) | buffer[3]; *z = (((int16_t)buffer[4]) << 8) | buffer[5]; On different sensors i am getting different values on Y-axis, which changes when i set up offset value to ennormous values, for example, reading on y-axis when offset register are factory-defined: x = 806 y = -32768 z = 4112 x = 808 y = -32768 z = 4109 x = 827 y = -32768 z = 4109 /* second sensor */ x = 91 y = 9677 z = 3912 x = 145 y = 9569 z = 3872 x = 214 y = 9562 z = 3910 x = 213 y = 9552 z = 3910 /* third sensor */ x = 516 y = 12547 z = 4098 x = 523 y = 12481 z = 4070 x = 482 y = 12499 z = 4113 x = 503 y = 12525 z = 4087 Does anyone have any thoughts regarding this subject? Thanks a lot! Hope to find a valid solution for this... The same behaviour is observed even if i initialize sensor only by writing 0x00 value to PWR_MGM_1 register.
×
×
  • Create New...