Accelerometer Experiments

A project log for Yet Another Fidget POV (YAFPOV)

Call me Slow-on-the-Draw if you like, but I think there's a lot to be learned from this project even if it's a me-too.

doctekdoctek 07/30/2017 at 20:450 Comments

The accelerometer I'm experimenting with is the STM LSM330DLC. Although this is an older design, it's convenient since I have an IMU I designed nearly 5 years ago with that part on it. It's similar enough to the part on my new design that I can do useful experiments. Most applications using accelerometers and Arduinos involve implementing IMU functions, and most drivers support simply reading the data back quickly. But that's not how I plan to use the accelerometer in this application. What I want the accelerometer to do is to wake the ATTINY84 when the fidget is spun, then let it go back to sleep when spinning is over. Getting it all to work as desired will take some testing, but I can start now to get a feel for how to control the accelerometer.
With the accelerometer hooked to the Teensy2, I tested it's ability to generate interrupts to wake the Teensy. This was easy. The data sheet was very clear on how to configure the control registers. Next was how to know when to go back to sleep. My first approach was to read the interrupt status register on the accelerometer since that tells which interrupt (X, Y, or Z) was above or below threshold. However, this register is only updated when an interrupt occurs; useless for showing status otherwise. So I read the X and Y values, convert from two's compliment, and do the compare in the ATTINY84. Currently, the limit is arbitrary and will have to be tuned on the POV board. But it works! And it also works when ported to the ATTINY84. The code for the ATTINY84 is one of the files.
Quick battery life calculation: The CR-2032 battery is rated at 210mAh @ 15K load. With 3.0 V and 15K load, the rated current drain is 200uA. The STM LIS2DE12 accelerometer that is on the POV board draws 4uA at 25 samples per second (to watch for a spin) and the ATTINY84 draws 0.1uA in sleep mode. Life is then 210,000/4.1 > 50,000 hours or about 6 years. Conclusion: no power switch is needed.