ADXL345 Conditional Statement Help!

21 Nov 2010

Hello All Again,

I've had a previous post about the installation of the ADXL345, and have gotten it to work, but now need help in the method that I will be able use the conditional statements.

So far:

  • I've inserted the cookbook code for the measurement and output of the accelerometer. I've attached an image of it reading on a flat surface.
  • I've soldered the accelerometer upside down in order to be able to see the input pins.
  • Have seen some replies on Mr. Novak's post but don't have the vocabulary to follow.
The problem:
  • I probably do not need the intricate measuring abilities of the sensor, but just need to know when the accelerometer tilts or moves for an X amount of time. In that event it would send an output to the mbed.
  • This is a senior design project which will use the motion of the accelerometer as a trigger to alarm a speaker.
I would appreciate any help you may give.
Thanks
Henry

21 Nov 2010

work out what a normal variation in the readings would be(sensitivity). as in if you left it untouched, what the range of readings would be.

then simply take that range, if you get a larger change than said range on any of the axies set the alarm off.

so

if (abs(last reading - current reading)>sensitivity)

alarm =1;

 

abs give the value, ignoring the sign so abs(-1) = abs(1);

 

this implementation is crude, and prone to randomly setting itself off. a better implementation would take into account a range of readings streching back in time. of course, most of the fun is in working that out.