So I've gotten accurate filtered pitch and roll data, and I understand the base of this function (atan2(-yaccel,zaccel)*180/pi) to calculate roll. My question is this, how would I measure the acceleration on the x y and z planes, as in the lateral accelerations that are not rotational ( NOT tilt accelerations )?
For example: If I were walking with my arduino and ADXL345 hooked up, how would I get the acceleration in the direction I'm walking in?
furthermore....
When accelerating the sensor along a plane (moving it level from one side of my desk to the other) the raw xy data outputs the rotational orientation instead of the acceleration in the direction, the raw z shows the acceleration in the plane (this is what I would like the x and y to do). How could I get the xy accelerations along the planes as done with the z?
The accelerometers measure one acceleration vector. When you are standing still relative to the Earth it is the gravity vector. When you accelerate from there it is the sum of the gravity vector and your acceleration vector. To get just your acceleration vector you have to subtract out the gravity vector. Unfortunately if all you have is an accelerometer you can only measure the gravity vector when you are stationary.
For example, the accelerometer produces the exact same outputs if you are:
A) Upright and stationary on the surface of the Earth.
B) Upside-down and accelerating toward the Earth at 2g.
(At lest until you hit the Earth in case B)
To subtract the gravity vector you need a different way to determine your orientation with respect to the Earth. Rate gyroscopes generally drift too much to be of use. A magnetometer can give you orientation relative to the local magnetic field which should be sufficient for determining the gravity vector:
When stationary (at start-up, for example) measure your magnetic orientation vector and gravity vector. Calculate the difference vector. When in motion take the magnetic orientation vector and add the difference vector to get the gravity vector. Subtract that from your acceleration vector to get your acceleration due to motion.
Of course the acceleration has to be integrated over time so , like a rate gyro, it is likely to drift.
Thank you very much what a helpful response, your step by step breakdown has cleared up a lot of my confusion . I will start messing around with my magnetometer sensor and go from there, I cannot wait to finish up my project!