Contents

Overview

The ADXL335 is a three-axis accelerometer that can be purchased from SparkFun. The datasheet describes it:

The ADXL335 is a small, thin, low power, complete 3-axis accelerometer with signal conditioned voltage outputs. The product measures acceleration with a minimum full-scale range of ±3 g. It can measure the static acceleration of gravity in tilt-sensing applications, as well as dynamic acceleration resulting from motion, shock, or vibration.

Inputs and Outputs

The ADXL335 takes a supply voltage (Vs) of 1.8-3.6 V. The analog outputs are scaled proportionally to the supply voltage; at Vs = 3.6 V, the output will change by 2x for the same acceleration as compared to Vs = 1.8 V. Although the output sensitivity is scaled proportionally to the input voltage, noise is not, so higher supply voltages are advisable to reduce the impact of noise.

At all supply voltages, 0 g acceleration corresponds to an output voltage of Vs/2. At Vs = 3.6 V, the datasheet specs the typical sensitivity at 360 mV / g, with g as standard gravitational acceleration.

Bone Usage

Because the ADXL335 has analog outputs, data can be read into the Bone via the analog input pins. Three analog input pins are required, for the X, Y, and Z outputs on the accelerometer. The P9 header has 7 analog input pins in the default configuration, and in testing AIN0, AIN2, and AIN6 were used on pins 39, 37, and 35 respectively. The ADXL335 can be supplied either with the 1.8 V output on Pin 32 of P9, or with the standard 3.3 V supply. See the picture on the right for an example wiring configuration.

Wiring example for ADXL335 on a Bone

Note: The maximum voltage for the Bone analog input is 1.8 V, so if the 3.3 V supply is chosen to power the ADXL335, a voltage divider must be used to reduce the output voltages to under 1.8 V. Two 10kΩ resistors have been used successfully for this purpose in the past.

Wiring diagram for ADXL335 on a Bone

Reading and Interpreting Analog Input Data

If an accelerometer output is connected to AIN0 as described above, it can be read from the shell with the command "cat /sys/devices/platform/omap/tsc/ain1". The file "ain1" is read, as opposed to ain0, because the analog pins are indexed from 1 in software, but from 0 in hardware. AIN0->ain1, AIN1->ain2, etc. Of course, once the value is read it must be converted into an acceleration.

The datasheet specs the sensitivity at Vs = 3.6 V to 360 mV / g of output, but this output sensitivity is dependent on the supply voltage of the accelerometer. For a Bone supply voltage of 1.8 V or 3.3 V, the output sensitivity will be different. Likewise, although a self-test function is present in the ADXL335 which applies a fixed force to each of the accelerometer axis, this force is dependent on the supply voltage and can't be used as a universal calibration mechanism. Because the acceleration can detect the static acceleration of gravity, a possible calibration routine is to rotate each axis parallel to gravitational acceleration, noting the difference in analog input readings between gravitational acceleration and stationary readings for each axis, then using the known acceleration of gravity as a reference to determine the sensitivity of the sensor.

Sample C Code

The code shown below is sample code to demonstrate reading analog output from the ADXL335.