LSM303DLx support

This forum is dedicated to software development related to MultiWii.
It is not the right place to submit a setup problem.
Software download
Post Reply
wektorx
Posts: 8
Joined: Sat Aug 27, 2011 8:08 pm

LSM303DLx support

Post by wektorx »

LSM303DLH
http://www.st.com/internet/com/TECHNICA ... 260288.pdf
LSM303DLM
http://www.st.com/internet/com/TECHNICA ... 026454.pdf

config.h:

Code: Select all

/* I2C accelerometer */
//#define ADXL345
//#define BMA020
//#define BMA180
//#define NUNCHACK  // if you want to use the nunckuk as a standalone I2C ACC without WMP
//#define LIS3LV02
#define LSM303DLx_ACC


Code: Select all

/* I2C magnetometer */
//#define HMC5843
//#define HMC5883
//#define AK8975
#define LSM303DLx_MAG


def.h

Code: Select all

#if defined(ADXL345) || defined(BMA020) || defined(BMA180) || defined(NUNCHACK) || defined(ADCACC)  || defined(LSM303DLx_ACC)
  #define ACC 1
#else
  #define ACC 0
#endif

#if defined(HMC5883) || defined(HMC5843) || defined(AK8975)  || defined(LSM303DLx_MAG)
  #define MAG 1
#else
  #define MAG 0
#endif


sensors:

Code: Select all

// ************************************************************************************************************
// I2C Accelerometer LSM303DLx
// ************************************************************************************************************

// ************************************************************************************************************
#if defined(LSM303DLx_ACC)
void ACC_init () {
 delay(10);
  i2c_rep_start(0x30+0);     
  i2c_write(0x20);           
  i2c_write(0x27);           
  i2c_rep_start(0x30+0);     
  i2c_write(0x23);           
  i2c_write(0x30);           
  i2c_rep_start(0x30+0);     
  i2c_write(0x21);           
  i2c_write(0x00);           

  acc_1G = 256;
}

  void ACC_getADC () {
  TWBR = ((16000000L / 400000L) - 16) / 2;
  i2c_getSixRawADC(0x30,0xA8);



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


Code: Select all

// ************************************************************************************************************
// I2C Compass  LSM303DLx
// ************************************************************************************************************

// ************************************************************************************************************
#if defined(LSM303DLx_MAG)
void Mag_init() {
  delay(100);
  i2c_writeReg(0X3C ,0x02 ,0x00 );
}

void Device_Mag_getADC() {
  i2c_getSixRawADC(0X3C,0X03);
 
    MAG_ORIENTATION( ((rawADC[0]<<8) | rawADC[1]) ,
                     ((rawADC[2]<<8) | rawADC[3]) ,
                    -((rawADC[4]<<8) | rawADC[5]) );

}
#endif

timecop
Posts: 1880
Joined: Fri Sep 02, 2011 4:48 pm

Re: LSM303DLx support

Post by timecop »

I thought LSM303DLx was just HMC5883 chip inside same package with accel.
Wouldn't it be easier to reuse existing 5883 code?

marbalon
Posts: 107
Joined: Thu Aug 18, 2011 10:59 am

Re: LSM303DLx support

Post by marbalon »

dongs wrote:I thought LSM303DLx was just HMC5883 chip inside same package with accel.
Wouldn't it be easier to reuse existing 5883 code?


I can agree with you, and Alex added without MAG code but forgot write any comment about LSM303DLx_MAG. So people need to read this post to understand that this is the same chip inside.
Alex please add some comment like this:

Code: Select all

//to use MAG inside LSM303DLx chip please uncoment HMC5883 mag
#define LSM303DLx_ACC



Regards,
Marcin.

copterrichie
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: LSM303DLx support

Post by copterrichie »

I have the Pololu Min IMU -9 connected to 3.3 volts on a Pro-shield version 1.1 with the latest version of the WiiCopter Firmware 1.9 20111220. I am getting lots of Noise on the Accelerometer and not Mag display. I am not sure as to what is causing this problem, any suggestions?

Thank you.

Screen shot Video: http://www.youtube.com/watch?v=747GAU2x7S0

Image

copterrichie
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: LSM303DLx support

Post by copterrichie »

Note: I have attempted to adjust the Sensitivity from 8g to 2g with the same results.

copterrichie
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: LSM303DLx support

Post by copterrichie »

Picture 5.png



I am just brain storming, Should I be using 5 volts instead of 3.3 volts to power the MinIMU?


Edited: Nope, it is not that. I tried powering it with 5 volts, same results.

Waldmensch
Posts: 31
Joined: Sat Dec 31, 2011 12:10 am

Re: LSM303DLx support

Post by Waldmensch »

@copterrichie:

You are not alone with. I have the MinIMU-9 from Polulo too and see the same noises. The Gyro is stable at zero while ACC flicker between 0 and -20. The flickering on Mag is higher then on ACC. I have removed UBEC and RX to avoid an influence. I see the behavior on 1.8p2 as well as 1.9

I have tested a BMA020 on the same board. It flickers between 0 and 5. Ihave tried 400kHz and 100kHz - no different.

Maybe a kind of deadband around zero could help as it's done for RX in config.h?

Post Reply