This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Using nrf51822 board with adxl335 accelerometer (ADC)

Hi,

I'm trying to use adxl335 accelerometer to detect motion.

I'm having trouble understanding what the output of the accelerometer means. Obviously, it should tell me something about the acceleration but it's in unit mV/g. How do I interpret this output and convert it into data related to acceleration or motion?

Also, I've found a lot of codes on adxl335 with Arduino, but there seems to be less resources on adxl335 with nrf51822 kit. I'm trying to use the GPIOs and program it to do the ADC conversion. Could anyone help me on this?

Thank you a lot.

  • According to the datasheet, www.analog.com/.../ADXL335.pdf, the output is analog, hence the mV/g.

    0 g will output (typically) 1.5V on the z, x and y outputs, and the typical change in voltage is 300mV per g. So lying still on a table you could expect the x and y outputs to be 1.5V and the z axis to be 1.2V (1.5V - 300mV) because of the 1 g (=9.81 m/s^2) downward gravitational force from earth.

    To sample this information in the nrf51 you would need to use the ADC, since the output is analog. See the reference manual section 31. Connect the three outputs to three of the analog input pins on the nRF51. Since the nRF51 only has one ADC you would need to multiplex between the 3 inputs. Change the input pin by changing the PSEL register, and read of the value, then the next pin and so on.

    Now you would need to do some math (and calibration) to convert the sampled value to a g value, knowing that a 300 mV offset equals a 1 g acceleration (or a 9.81 m/s^2 acceleration).

  • Save yourself the pain and use a digital accelerometer with an I2C or SPI interface.

    The nrf51 ADC is fairly slow, is blocked SD events and isn't overly accurate. Most digital accelerometers are factory trimmed and will be significantly more accurate. With the the slow nrf51 ADC and software overhead the on time between measuring one axis and the next will make extracting useful data from the accelerometer somewhat difficult.

    Most digital accelerometers will have 3 ADCs and latch the data so your measurements are taken at the same time. They also tend to have FIFOs and can be configured to automatically sample at a fixed rate and dump the measurements to the FIFO. That way even when the SD takes over the processor you won't loose samples.

    If you are just looking to detect change in motion, many digital accelerometers will provide an interrupt signal and hardware motion thresholds.

Related