SparkFun Forums 

Where electronics enthusiasts find answers.

Questions &/or issues related to products in the Movement & IMU category should be posted in this forum.
User avatar
By InventorDad
#206107
Hello tech people.

I am new to this forum. I have searched the forum and other places but can't find my answer.
I want to understand how to use the ADXL345 (SEN-09836) with the SparkFun Redboard (DEV-13975) as described in the tutorial (https://learn.sparkfun.com/tutorials/ad ... -guide/all).

I am getting data back as described but what does the data mean? If the scale is set to 2g max, how is it that I get whole numbers ranging from zero to several hundred? Are the units in milli-g's? At the 2 or 4 g scale the resolution should be 10 or 11 bits according to the data sheet (https://www.sparkfun.com/datasheets/Sen ... DXL345.pdf), so I would expect a calibration at 1 g to yield something like 1000, not 1 as in the calibration example.

Please help and forgive me if I am overlooking something simple
- InventorDad
User avatar
By TS-Mark
#206216
Hi InventorDad,

You're definitely not overlooking something simple. From what I understand, the output is actually just the decimal value of the 10-bit buffer for each axis so, for example, with the ADXL345 set to +/-2g the output on the serial terminal should range from +/-512 (with a full range of 1024). This works well for applications that do not need precision measurements of acceleration data and why the ADXL345 works great for motion-detection applications with no calibration needed. If you need precision measurements, that is where the Calibration Procedure comes in handy. The Application Note from Analog Devices has some in-depth information on the calibration techniques and formulae involved.

I hope this helps explain what the example code outputs. Let us know if you have any other questions or concerns about the ADXL345 and we would be happy to help as much as we can.
User avatar
By InventorDad
#206548
Yes, that is what I found but I forgot to go +/- 512 instead of 1024 one direction. Seems to work pretty well. I will optimize those calibration scaling formulas and share them.
But an additional question:
I see the header file that calls up alot of functions but where are the code lines for the functions? I would like to reconstruct the library for use with a pic or other chip but I would like to see how the arduino calls up the SPI communications with the specific 16 bit registers in the ADXL345.

Is there a .c file for the header somewhere?
User avatar
By TS-Mark
#206565
Hi again,

The source files for the library will have the header(.h) and C++(.cpp) files the library uses. Both of those files should have a few notes as well or at least "titles" for each function for you to search and adapt for your customization of the library.