3 Axis Digital Accelerometer
http://gadgetgangster.com/find-a-projec ... ectnum=322
Code: Select all
#if defined(MMA7455)
static uint8_t rawADC_MMA7455[6];
void i2c_ACC_init () {
delay(10);
i2c_rep_start(0x3A); // I2C write direction
i2c_write(0x16); // Mode Control
i2c_write(0x25); // Set Sensitity Value @ 2g
//i2c_write(0x21); // Set Sensitity Value @ 8g
acc_1G = 63;
acc_25deg = 26; // = acc_1G * sin(25 deg)
accPresent = 1;
}
void i2c_ACC_getADC () {
static uint8_t counter;
TWBR = ((16000000L / 400000L) - 16) / 2;
i2c_rep_start(0x3A); // I2C write direction
i2c_write(0x06); //Registry to start reading from.
i2c_rep_start(0x3B); // I2C read direction => 1
for(uint8_t i = 0; i < 2; i++) {
rawADC_MMA7455[i]= i2c_readAck();}
rawADC_MMA7455[2]= i2c_readNak();
//accADC[ROLL] = (int(rawADC_MMA7455[1]<<8) | rawADC_MMA7455[0]);
//accADC[PITCH]= (int(rawADC_MMA7455[3]<<8) | rawADC_MMA7455[2]);
//accADC[YAW] = (int(rawADC_MMA7455[5]<<8) | rawADC_MMA7455[4]);
accADC[ROLL] = int(rawADC_MMA7455[0]);
accADC[PITCH]= int(rawADC_MMA7455[1]);
accADC[YAW] = int(rawADC_MMA7455[2]);
//accADC[ROLL] = (i2c_readAck() && 0x7F);
//accADC[PITCH]= (i2c_readAck() && 0x7F);
//accADC[YAW] = (i2c_readNak() && 0x7F);
}
#endif
Code: Select all
// Developmental code for the MMA7455
#if defined(MMA7455)
static int8_t rawADC_MMA7455[6];
void i2c_ACC_init () {
delay(10);
i2c_rep_start(0x3A); // I2C write direction
i2c_write(0x16); // Mode Control
i2c_write(0x25); // Set Sensitity Value @ 2g
//i2c_write(0x21); // Set Sensitity Value @ 8g
acc_1G = 64;
acc_25deg = 27; // = acc_1G * sin(25 deg)
accPresent = 1;
}
void i2c_ACC_getADC () {
//TWBR = ((16000000L / 400000L) - 16) / 2; // change the I2C clock rate to 400kHz, ADXL435 is ok with this speed
//i2c_rep_start(0x3A);
//i2c_write(0x09);
//i2c_rep_start(0x3B);
i2c_rep_start(0x3A); // I2C write direction
i2c_write(0x00); //Registry to start reading from.
i2c_rep_start(0x3B); // I2C read direction => 1
for(uint8_t i = 0; i < 5; i++) {
rawADC_MMA7455[i]= i2c_readAck();}
rawADC_MMA7455[5]= i2c_readNak();
accADC[ROLL] = ((char(rawADC_MMA7455[1])<<8) | (rawADC_MMA7455[0]>>1)<<1);
accADC[PITCH]= ((char(rawADC_MMA7455[3]<<8)) | (rawADC_MMA7455[2]>>1)<<1);
accADC[YAW] = ((char(rawADC_MMA7455[5]<<8)) | (rawADC_MMA7455[4]>>1)<<1);
}
#endif
msev wrote:Rich have you tried the bma020 acc - which is also a "poor man" acc choice...Can you give a comparison between the two acc's?
MacArell wrote:Hi, I'm a newbie and want make a Quadcopter with this Accelerometer Sensor, my sensor is KIT3468MMA7455L (From an old project) i will use an Arduino UNO (From an old project too) and i don't know for the gyro but certainly a WMP...
I'll let you know.
Sylvain
Code: Select all
void ACC_getADC () {
TWBR = ((16000000L / 400000L) - 16) / 2; // change the I2C clock rate to 400kHz speed
i2c_getSixRawADC(MMA7455_ADDRESS,0x00);
ACC_ORIENTATION( ((rawADC[3]<<8) | (rawADC[2]>>1)<<1) ,
((rawADC[1]<<8) | (rawADC[0]>>1)<<1) ,
((rawADC[5]<<8) | (rawADC[4]>>1)<<1) );
ACC_Common();
}
misslins2011 wrote:GY-29 is a small, thin, low power, 3-axis accelerometer with high resolution (13-bit) measurement at up to ±16 g. Digital output data is formatted as 16-bit twos complement and is accessible through the I2C digital interface. http://module.blog.com/gy-29-3-axis-acc ... r-arduino/
copterrichie wrote:Note: When using version 1.8 or higher, make sure to fully check the movements in the Gui, there is a very weird bug that I thought was due to the 2's compliment but I now believe it is related to the Calibration procedure. This bug only shows up when the Calibration Offset value is at a partial value and I don't believe this problem is isolated to just the MMA7455. The Calibration procedures for the MMA7455 is somewhat difference then the other Accelerometers, actually much simpler but I have not made the modifications yet. With version 1.7, the MMA7455 is rock solid.
Peck wrote:Hi, any progress on this? I mean, is there really problem with the MMA7455 calibration?
copterrichie wrote:I have not worked on it, been busy with another project. As stated however, just make sure to check using the GUI all sensing directions and make sure there are no abnormal jumps in the readings.
Code: Select all
static int8_t rawADC_MMA7455[6];
i2c_rep_start(MMA7455_ADDRESS); // I2C write direction
i2c_write(0x00); //Registry to start reading from.
i2c_rep_start(MMA7455_ADDRESS+1); // I2C read direction => 1
for(uint8_t i = 0; i < 5; i++) {
rawADC_MMA7455[i]= i2c_readAck();}
rawADC_MMA7455[5]= i2c_readNak();
accADC[ROLL] = -((rawADC_MMA7455[1]<<8) | (rawADC_MMA7455[0]>>1)<<1);
accADC[PITCH]= -((rawADC_MMA7455[3]<<8) | (rawADC_MMA7455[2]>>1)<<1);
accADC[YAW] = ((rawADC_MMA7455[5]<<8) | (rawADC_MMA7455[4]>>1)<<1);
ACC_Common();
Peck wrote:copterrichie wrote:I have not worked on it, been busy with another project. As stated however, just make sure to check using the GUI all sensing directions and make sure there are no abnormal jumps in the readings.
Thanks! I just asked, because I think I have the same problem, but I don't know where's the calibration offset. I had issues only on one axis.
I played today a lot with it, and I think I figured it out... I don't know much about microcontrollers, but I had the MMA7445 code from the 1.7 version, which was stable for me too.
This works for me:Code: Select all
static int8_t rawADC_MMA7455[6];
i2c_rep_start(MMA7455_ADDRESS); // I2C write direction
i2c_write(0x00); //Registry to start reading from.
i2c_rep_start(MMA7455_ADDRESS+1); // I2C read direction => 1
for(uint8_t i = 0; i < 5; i++) {
rawADC_MMA7455[i]= i2c_readAck();}
rawADC_MMA7455[5]= i2c_readNak();
accADC[ROLL] = -((rawADC_MMA7455[1]<<8) | (rawADC_MMA7455[0]>>1)<<1);
accADC[PITCH]= -((rawADC_MMA7455[3]<<8) | (rawADC_MMA7455[2]>>1)<<1);
accADC[YAW] = ((rawADC_MMA7455[5]<<8) | (rawADC_MMA7455[4]>>1)<<1);
ACC_Common();
I know it's not using the i2c_getSixRawADC, but does basically the same, but I figured out, that the "big" difference in 1.7 and 1.8 code is,
that rawADC is uint8_t, but rawADC_MMA7455 is int8_t type, which I used.
I also tried it with the original code (using i2c_getSixRawADC), and only changed the type of rawADC, and the problem disappeared too, but it's not a good idea to change it, my servo gone nuts on my tricopterHowever the gyro values seemed to be good too on the GUI.