kriswiner / LSM9DS1

ST's new smaller, lower-power 9-axis motion sensor
40 stars 28 forks source link

Acc only reading changes #7

Open ReneKaminski opened 7 years ago

ReneKaminski commented 7 years ago

Hi Kris, I´m setting the sensor to those settings after reset. The accel only changes its values when I move the device. There is no recognition of earth´s G, when I let one of the axes pointing to the ground, what I would expect.. Just a bit fluctation around 0. gyro and magnetometer values seem to be reasonable.

Do you have an hint for me, please?

I2C_SetSlaveAddress(Gyro);
    I2C_WriteRegister(CTRL_REG4, 0x38); //enable all axes
    __delay_cycles(10);
    I2C_WriteRegister(CTRL_REG1_G, (uint8_t) (G_ODR_238<< 5 | G_SCALE_245DPS << 3 | GBW_med));
    __delay_cycles(10);
    I2C_WriteRegister(CTRL_REG3_G,HP_enable);
    __delay_cycles(10);
    I2C_WriteRegister(FIFO_CTRL,0x0);//  FIFO off... by default off
    __delay_cycles(10);
    I2C_WriteRegister(CTRL_REG9,DA_timer_enable);
    __delay_cycles(10);
    return 1;
}

uint8_t configAccel()
{
    I2C_SetSlaveAddress(Accel);
    I2C_WriteRegister(CTRL_REG5_XL, 0x38); //enable all axes
    __delay_cycles(10);
    I2C_WriteRegister(CTRL_REG6_XL, (uint8_t) (AODR_238Hz << 5 | AFS_2G << 3 | 0x04 |ABW_50Hz) );
    __delay_cycles(10);
    I2C_WriteRegister(CTRL_REG7_XL,0xA4); //High res Mode on,LP cutofffrequ  ODR/100
    __delay_cycles(10);
    I2C_WriteRegister(CTRL_REG8, 0x44);// enable block data update, allow auto-increment during multiple byte read
    __delay_cycles(10);
    I2C_WriteRegister(CTRL_REG9,DA_timer_enable);
    return 1;
}

uint8_t configMagnet()
{
    I2C_SetSlaveAddress(Magneto);
    I2C_WriteRegister(CTRL_REG1_M,0xF4 );  //xy:temp compensated, ultra performance mode, 10 Hz, def +-4gauss
    __delay_cycles(10);
    I2C_WriteRegister(CTRL_REG2_M, (uint8_t) (MFS_4G << 5) ); // select mag full scal
    __delay_cycles(10);
    I2C_WriteRegister(CTRL_REG3_M,0x0 ); //continous conversion mode, LPM off
    __delay_cycles(10);
    I2C_WriteRegister(CTRL_REG4_M, (uint8_t) MMode_UltraHighPerformance <<2);// z Axis ultra perf
    __delay_cycles(10);
    I2C_WriteRegister(CTRL_REG5_M, 0x40);  //Block Update Mode
    __delay_cycles(10);
    return 1;
kriswiner commented 7 years ago

No idea. Do the individual byte counts seem OK? Maybe you have set a high pass filter or something inadvertently.

On Fri, Jun 30, 2017 at 6:09 AM, ReneKaminski notifications@github.com wrote:

Hi Kris, I´m setting the sensor to those settings after reset. The accel only changes its values when I move the device. There is no recognition of earth´s G, when I let one of the axes pointing to the ground, what I would expect.. Just a bit fluctation around 0. gyro and magnetometer values seem to be reasonable.

Do you have an hint for me, please?

I2C_SetSlaveAddress(Gyro); I2C_WriteRegister(CTRL_REG4, 0x38); //enable all axes delay_cycles(10); I2C_WriteRegister(CTRL_REG1_G, (uint8_t) (G_ODR_238<< 5 | G_SCALE_245DPS << 3 | GBW_med)); delay_cycles(10); I2C_WriteRegister(CTRL_REG3_G,HP_enable); delay_cycles(10); I2C_WriteRegister(FIFO_CTRL,0x0);// FIFO off... by default off __delay_cycles(10); I2C_WriteRegister(CTRL_REG9,DA_timer_enable); delay_cycles(10); return 1; }

uint8_t configAccel() { I2C_SetSlaveAddress(Accel); I2C_WriteRegister(CTRL_REG5_XL, 0x38); //enable all axes delay_cycles(10); I2C_WriteRegister(CTRL_REG6_XL, (uint8_t) (AODR_238Hz << 5 | AFS_2G << 3 | 0x04 |ABW_50Hz) ); delay_cycles(10); I2C_WriteRegister(CTRL_REG7_XL,0xA4); //High res Mode on,LP cutofffrequ ODR/100 __delay_cycles(10); I2C_WriteRegister(CTRL_REG8, 0x44);// enable block data update, allow auto-increment during multiple byte read __delay_cycles(10); I2C_WriteRegister(CTRL_REG9,DA_timer_enable); return 1; }

uint8_t configMagnet() { I2C_SetSlaveAddress(Magneto); I2C_WriteRegister(CTRL_REG1_M,0xF4 ); //xy:temp compensated, ultra performance mode, 10 Hz, def +-4gauss delay_cycles(10); I2C_WriteRegister(CTRL_REG2_M, (uint8_t) (MFS_4G << 5) ); // select mag full scal delay_cycles(10); I2C_WriteRegister(CTRL_REG3_M,0x0 ); //continous conversion mode, LPM off delay_cycles(10); I2C_WriteRegister(CTRL_REG4_M, (uint8_t) MMode_UltraHighPerformance <<2);// z Axis ultra perf delay_cycles(10); I2C_WriteRegister(CTRL_REG5_M, 0x40); //Block Update Mode __delay_cycles(10); return 1;

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