Problem measuring acceleration

I'm having a problem figuring out how to measure my acceleration using the adxl320. It's a 2 axis accelerometer. I've got it working just fine --assuming that it's starting position is lying flat. The problem is that it's going to be mounted on something different each time and the starting position will not necessarily be horizontal or perpendicular to earth, which means my 1G reading wont be the same (512) each time. I'm looking for some ideas or a kicking off point, on how to measure no movement and then to calculate acceleration, if the device is mounted in a different plane (as compared to earth) each time.

My initial thought is to take readings for 10-15 seconds, when I know i'll be stationary, and average those to get what will be assumed as no motion. Place this in a variable and then start calculating deviations from that point. The problem is, what if the device stops and is on an incline. It will assume that there's movement. I dont know......maybe it's right in front of me and I'm looking harder than I need to.



I would probably do something similar to what you suggest as your 'initial thought'. If all you're looking to do is measure acceleration, that is probably your best route as long as you can guarantee that for the start-up time that the device will be still.

The problem is, what if the device stops and is on an incline. It will assume that there's movement.

Is this going to cause a problem? Maybe you're after something like a gyroscope? If the thing stops moving, it doesn't matter what orientation it's in, it's still not going to have any motion... Perhaps what you should do is during your initial setup time, figure out what sort of readings the accelerometer is giving, and set that as 1G (You might have to do this across both axis using a bit of trig). Any time the total reading is out with this amount is your acceleration.

Hope that helps some. :-X

Thanks for the response. What I've decided to do and what will work within the parameters of my project, is to take x and y readings for 5 minutes and catch the lowest and highest values in a variable. If the difference between the low and high is more than 5 (ie.. low=498 and high=504) then I will assume there is movement. Sitting on a device with a vibrating motor and no movement only cased a max diff of 3. Starting and stopping exceeded a value of 5. This way, it doesnt matter what inclination it's on, because it will start with a fresh set of variable values every 5 minutes.