ozzmaker / BerryIMU

Code related to BerryIMU
http://ozzmaker.com
181 stars 109 forks source link

Units of raw accelerometer #1

Closed ghost closed 8 years ago

ghost commented 8 years ago

Hi,

I've just received the awesome board and I'm playing around with it. Could you tell me what the unit of the return value is for the following function: def readACCx(): acc_l = bus.read_byte_data(ACC_ADDRESS, OUT_X_L_A) acc_h = bus.read_byte_data(ACC_ADDRESS, OUT_X_H_A) acc_combined = (acc_l | acc_h <<8) return acc_combined if acc_combined < 32768 else acc_combined - 65536

is it g or mg or something else ?

mwilliams03 commented 8 years ago

The raw value is mg per LSB. And is based off your sensitivity level. E.g. The code in the git repo uses +/- 16G full scale for the accelerometer Looking at the datasheet, this results in 0.732mg/LSB. or 0.732 mili G per least significant bit.

So..if BerryIMU was up the right way and I looked at the raw Z value. I see a result of 1232.

1382 * 0.732 =1011mg. or 1.01G