Adafruit 10 dof IMU. Please Help!?

Post Reply
Dryteo
Posts: 2
Joined: Sun Jul 19, 2015 8:14 pm

Adafruit 10 dof IMU. Please Help!?

Post by Dryteo »

Hello Friends. I am new to this but i am a little experienced with programming arduino/c++. I decided to build my first quadcopter flight controller, with parts laying around, using an Arduino Uno r3 and an Adafruit 10 dof IMU http://www.adafruit.com/products/1604 with the L3GD20H Gyroscope LSM303 Accelerometer/Magnetometer and the BMP180 barometer. Because the multiwii 2.4 source code does not fully support this new IMU, i read the imu's sensors datasheet and i decided to make the following modifications:

in config.h i defined:

Code: Select all

#define QUADX

    /***************************    independent sensors    ********************************/
      /* leave it commented if you already checked a specific board above */
      /* I2C gyroscope */
      //#define WMP

      #define L3G4200D  //warning sensor address changed in Sensors.ccp

     
      /* I2C accelerometer */

      #define LSM303DLx_ACC  //warning sensor address changed in Sensors.ccp


      /* I2C barometer */
      #define BMP085 //same as BMP180

      /* I2C magnetometer */
      #define HMC5883 //same as LSM303DLx_MAG


in Sensors.ccp i modified:

Code: Select all

// ************************************************************************************************************
// I2C Accelerometer LSM303DLx
// ************************************************************************************************************
#if defined(LSM303DLx_ACC)

//#define LSM303DLx_ADDR  0x18
#define LSM303DLx_ADDR  0x19 //LSM303DLHC Address From Adafruit 10 DOF IMU

void ACC_init () {
  delay(10);
  i2c_writeReg(LSM303DLx_ADDR,0x20,0x27);
  i2c_writeReg(LSM303DLx_ADDR,0x23,0x30);
  i2c_writeReg(LSM303DLx_ADDR,0x21,0x00);
}

  void ACC_getADC () {
  i2c_getSixRawADC(LSM303DLx_ADDR,0xA8); //0x28+0x80 = 0xA8

  ACC_ORIENTATION( ((rawADC[1]<<8) | rawADC[0])>>4 ,
                   ((rawADC[3]<<8) | rawADC[2])>>4 ,
                   ((rawADC[5]<<8) | rawADC[4])>>4 );
  ACC_Common();
}
#endif

// ************************************************************************************************************
// ADC ACC
// ************************************************************************************************************
#if defined(ADCACC)
void ACC_init(){
  pinMode(A1,INPUT);
  pinMode(A2,INPUT);
  pinMode(A3,INPUT);
}

void ACC_getADC() {
  ACC_ORIENTATION(  analogRead(A1) ,
                    analogRead(A2) ,
                    analogRead(A3) );
  ACC_Common();
}
#endif

// ************************************************************************************************************
// I2C Gyroscope L3G4200D OR L3GD20H
// ************************************************************************************************************
#if defined(L3G4200D)

  //#define L3G4200D_ADDRESS 0x69
  #define L3G4200D_ADDRESS 0x6B //L3GD20H Address From Adafruit 10 DOF IMU 

void Gyro_init() {
  delay(100);
  i2c_writeReg(L3G4200D_ADDRESS ,0x20 ,0x8F ); // CTRL_REG1   400Hz ODR, 20hz filter, run!
  delay(5);
  i2c_writeReg(L3G4200D_ADDRESS ,0x24 ,0x02 ); // CTRL_REG5   low pass filter enable
  delay(5);
  i2c_writeReg(L3G4200D_ADDRESS ,0x23 ,0x30); // CTRL_REG4 Select 2000dps
}

void Gyro_getADC () {
  i2c_getSixRawADC(L3G4200D_ADDRESS,0x80|0x28);

  GYRO_ORIENTATION( ((rawADC[1]<<8) | rawADC[0])>>2  ,
                    ((rawADC[3]<<8) | rawADC[2])>>2  ,
                    ((rawADC[5]<<8) | rawADC[4])>>2  );
  GYRO_Common();
}
#endif


The results are not very good... the multiwiiconf application shows that the sensors are working with no i2c errors, but i noticed a strange behaviour comparing it to my friend's multiwii crius se board...When i rotate the imu around all three axis, right after that, i level the sensor on the table but the navigation ball won't be leveled immediately. It gives me the feeling that the Complementary or Kalman filter* gives more gravity to the gyroscope than the accelerometer data over time, So it looks like it drifted but after a while (5-10 seconds) the navigation ball comes to the right position. It feels like the accelerometer isn't working as it should. If i pitch or roll the imu board for about less than +or-45 degrees and leave the imu board at this angle the navigation ball starts to go at the horizon by it self. Did i missed something ? ... Could anyone help me please ???

Please note that the multiwii crius se board is not behaving like this(the Navigation ball is fast responsive and always precise on the pitch and roll of the circuit board orientation)
I attatched two pictures to show you multiwiiconf application results.
I have not tested this setup of flight controller on a quad yet because i still don't have the rest of my quadcopter's parts. Is there anyone brave enough to test it ??? Could it be an application visual error???
Attachments
5-10 seconds after (IMU leveled steady to a posititon)
5-10 seconds after (IMU leveled steady to a posititon)
almost right after rotating around the imu (IMU leveled steady to a posititon)
almost right after rotating around the imu (IMU leveled steady to a posititon)

cottor_pin
Posts: 1
Joined: Fri Feb 05, 2016 8:12 am

Re: Adafruit 10 dof IMU. Please Help!?

Post by cottor_pin »

Hi,

I am too planning to use the 10-DOF board: https://www.adafruit.com/product/1604 . Have you fixed the problem in your setup? Did you get the reading correct?

Dryteo
Posts: 2
Joined: Sun Jul 19, 2015 8:14 pm

Re: Adafruit 10 dof IMU. Please Help!?

Post by Dryteo »

Unfortunately there was very little interest from the forum members about this imu compatibility so i didn't progress much and i almost forgot that i posted here about this problem.... I think i had better result when i was trying to tinker with each sensor's axis orientation. Look in the "config.h" file for these lines (203 to 206) and try to play with them an see if the problem is fixed

Code: Select all

      /* enforce your individual sensor orientation - even overrides board specific defaults */
      #define FORCE_ACC_ORIENTATION(X, Y, Z)  {imu.accADC[ROLL]  = -Y; imu.accADC[PITCH]  = X; imu.accADC[YAW]  = Z;}
      #define FORCE_GYRO_ORIENTATION(X, Y, Z) {imu.gyroADC[ROLL] = -X; imu.gyroADC[PITCH] = Y; imu.gyroADC[YAW] = Z;}
      #define FORCE_MAG_ORIENTATION(X, Y, Z)  {imu.magADC[ROLL]  =  Y; imu.magADC[PITCH]  = X; imu.magADC[YAW]  = Z;}

wastevenson
Posts: 33
Joined: Thu Jan 07, 2016 5:33 am

Re: Adafruit 10 dof IMU. Please Help!?

Post by wastevenson »

I have had that issue before when messing around orientation. My conclusion was that it happens when your your ACC and Gyro contradict one-another.

Post Reply