# Mapping BMA180 digital values to g's

Hi all,

For the last couple of days i was trying to decode digital outputs produced by my BMA180 to g’s, but got lost and want to confirm on some issues.

As much as i understand in the BMA180 there sits an analog sensor that captures the movements. Then the ADC converts the data into the range -2^(14-1) … 2^(14-1). (BMA180 is 14bit as i understand). If i set the range to ±2g then i should be able to convert the data back into g’s by

g=BMA180_output/(2^(14-1))

So that is how i think everything should be. BUT everywhere i looked i arrived at different conclusions. For example here:A Guide To using IMU (Accelerometer and Gyroscope Devices) in Embedded Applications. – Starlino Electronics , they say to first revert the data back to analog and then calculate the g’s.

So finally my questions are:

Why revert the data back to analog?
Why in most formulas I see sensitivity as a divisor not the range values i mentioned before?
Might anyone tell what would the specific formula be for 14-bit BMA180 at 2g range?

I feel like i’m missing something in the system, hopefully someone will be able to clear that up. Thanks in advance!

In case anyone is interested i’m putting the code with which i’m getting the data
(I found it on DSS circuits website):

``````byte readAccel()
{
Wire.beginTransmission(BMA180);
Wire.send(0x02);
if(Wire.endTransmission()){return(1);}
if(Wire.requestFrom(BMA180,7) != 7){return(2);}
acc_x >>= 2;
acc_y >>= 2;
acc_z >>= 2;
}

byte initializeBMA180()
{
/*Set EEPROM image to write mode so we can change configuration*/
delay(20);
Wire.beginTransmission(BMA180);
Wire.send(0x0D);
if(Wire.endTransmission()){return(1);}
if(Wire.requestFrom(BMA180,1) != 1){return(2);}
Wire.beginTransmission(BMA180);
Wire.send(0x0D);
Wire.send(ee_w);
if(Wire.endTransmission()){return(1);}
delay(20);
/*Set mode configuration register to Mode 00*/
Wire.beginTransmission(BMA180);
Wire.send(0x30);
if(Wire.endTransmission()){return(1);}
if(Wire.requestFrom(BMA180,1) != 1){return(2);}
Wire.beginTransmission(BMA180);
Wire.send(0x30);
Wire.send(mode_config);
if(Wire.endTransmission()){return(1);}
delay(20);
/*Set bandwidth to 10Hz*/
Wire.beginTransmission(BMA180);
Wire.send(0x20);
if(Wire.endTransmission()){return(1);}
if(Wire.requestFrom(BMA180,1) != 1){return(2);}
bw |= 0x00 << 4;
Wire.beginTransmission(BMA180);
Wire.send(0x20);
Wire.send(bw);
if(Wire.endTransmission()){return(1);}
delay(20);
/*Set acceleration range to 2g*/
Wire.beginTransmission(BMA180);
Wire.send(0x35);
if(Wire.endTransmission()){return(1);}
if(Wire.requestFrom(BMA180,1) != 1){return(2);}
range |= 0x02 << 1 ;
Wire.beginTransmission(BMA180);
Wire.send(0x35);
Wire.send(range);
if(Wire.endTransmission()){return(1);}
delay(20);
/*Set interrupt latch state to non latching*/
Wire.beginTransmission(BMA180);
Wire.send(0x21);
if(Wire.endTransmission()){return(1);}
if(Wire.requestFrom(BMA180,1) != 1){return(2);}
latch_int &= ~(0x01);
Wire.beginTransmission(BMA180);
Wire.send(0x21);
Wire.send(latch_int);
if(Wire.endTransmission()){return(1);}
delay(20);
/*Set interrupt type to new data*/
Wire.beginTransmission(BMA180);
Wire.send(0x21);
if(Wire.endTransmission()){return(1);}
if(Wire.requestFrom(BMA180,1) != 1){return(2);}