adafruit / Adafruit_CircuitPython_ADXL34x

A CircuitPython driver for the ADXL34x family of accelerometers
MIT License
37 stars 14 forks source link

Orientation of _STANDARD_GRAVITY #27

Closed cjohnson-phys closed 3 years ago

cjohnson-phys commented 3 years ago

On the surface of the ADXL343 there is a right-handed coordinate description of acceleration. According to this description, the _STANDARD_GRAVITY constant should be negative.

caternuson commented 3 years ago

The _STANDARD_GRAVITY value is a constant to convert from G's as reported by the ADXL343 into units of meters/sec2. The sign of the value is part of the reported G value, not the constant.

caternuson commented 3 years ago

Silk matches datasheet:

adxl343_coord

cjohnson-phys commented 3 years ago

Thanks for the comments. After further research I figured out where my confusion was. Naively, if the device was laying flat on a with the positive z axis pointing up I would expect it to measure a negative acceleration due to the force of gravity but I was seeing a positive value. However it’s more normal for accelerometers to measure proper acceleration such that the z component of acceleration would go to zero if it were in free fall. This explains the choice of a positive gravity constant.

caternuson commented 3 years ago

Yep, that's it. No problem. It's a very confusing thing. Worth having us check in case we got it backwards somewhere/somehow.

There are some senors that provide a "linear acceleration" value. That's essentially acceleration with the affects of gravity removed. So you'd get 0 on all 3 axis for something at rest. But those rely on other inputs and do "sensor fusion" techniques. A simple stand alone accelerometer can not distinguish between gravity and dv/dt.