# Z-direction acceleration with accelerometer/magnetic-field sensor

1. Apr 19, 2012

### ericrijnb

Hi all,

We're working on a project where we try to calculate the distance traveled by a mobile phone which is thrown in the air (only vertical movement, not horizontal).
We use the accelerometer to get the acceleration in the x-, y-, and z-axis. Now we try to fix the error caused by the flipping and spinning of a phone.

I found out that we can get the actual acceleration by taking the azimuth, pitch and roll of the phone, en by using the rotation matrix like this: http://upload.wikimedia.org/wikipedia/en/math/5/2/5/525d9c773a2ed0d6a41c48d9a3ea4291.png, we should get the real acceleration in the three axes.

But, something's going wrong. If I hold my phone still, everything's ok. If I rotate my phone over, say, the x-axis, the value of the z-axis of the 'real' acceleration also changes, which is wrong.

What should I do to get the actual acceleration of the phone in the three axes, using the accelerometer and magnetic-field sensor? I searched the forum, but couldn't find a solution which fits this situation.
Looking forward to any replies.

Greetz,
Eric

2. Apr 20, 2012

### Stephen Tashi

You haven't given enough information to specify a mathematical problem. For example, you didn't say how you used the matrix or what you think it represents.

You might get a quicker answer to your questions in the Classical Physics section of the forum since this is basically a question of kinematics. If you want it moved there, you can use the "report" feature and report your post The interface to the report feature makes it sound like its only to report naughtly things, but I've been told you can also use it to make such simple requests.

3. Apr 20, 2012

### chingkui

Once your phone leave hand, it would be in free fall (ignoring air resistance), and the accelerometer measurements should be close to 0. The vertical distance is pretty much determined by the initial velocity of the phone when it leaves your hand. If I understand what you want to do correctly, then you should estimate the initial upward speed. So, which measurement do you think (ideally) can help you determine the yaw, pitch and roll? You don't have much choice here, but at least in theory, you should have sufficient information to determine that. Think a bit about that, what exactly are the coordinate systems you are using, and what rotation matrix are you trying to find, and what measurement is not going to change (at least in theory) no matter how you move and flip your phone?

4. Apr 20, 2012

### Stephen Tashi

If so, it looks like this question needs comments from engineers as well as physicists. Taking the problem as a physics problem, one would assume that an accelerometer measures acceleration (in some commonly used intertial frame). However, on the web, I see articles that say the purpose of these accelerometers is to determine if the phone is tilted or moving. So perhaps the "accelerometer" in a cell phone doesn't really output an acceleration measurement.

5. Apr 21, 2012

### chingkui

Consider a very simple single axis accelerometer model with a spring-mass inside a box: for simplicity, just consider 2-D space with a square mass and two springs. Connect the upper side of the mass to the inner upper wall of the box with a spring, and do the same thing to the lower side of the mass, now you have a simple single axis accelerometer. If you accelerate this sensor upward in an inertial frame, the mass will compress the lower spring and stretch the upper spring. You can measure the compression and figure out the force and hence the acceleration. So, in an inertial frame, this sensor measure the acceleration. Now, imagine you place this sensor on a table and magically turn gravity on, you no longer are in an inertial frame. But due to gravity, the mass inside the box compress the spring as if it is accelerating in an inertial frame. That's how an accelerometer "measure" gravity and by figuring out the downward direction relative to the sensor coordinate frame of your phone (using three orthogonal accelerometers), it can determine the tilt.
So, in an inertial frame, an accelerometer measure acceleration relative to that frame. But in a non-inertial Earth frame, to determine the acceleration RELATIVE to the Earth frame, the gravity component has to be subtracted from the accelerometer measurement. And you have to somehow know the gravity direction already.

6. Apr 21, 2012

### Stephen Tashi

I understand. So is the magnetic sensor used to determine the direction of gravity?

7. Apr 22, 2012

### chingkui

Usually, this is done by keeping track of its own orientation as it moves. For a mobile vehicle/machine to keep track of its orientation relative to some coordinate frame attached to the Earth (e.g. an East, North, Up, ENU frame), inertial measurement units with gyros and accelerometers (and additional sensors such as magnetometers) are usually used. But since gyro is not available, OP has no choice but to use the magnetometer to track the orientation. Mathematically, if the motion is the most general 6 DOF type, fully tracking the orientation would be impossible as there would be at least some ambiguity. But since OP's application is more or less limited to vertical movement, such heuristic might help to get a better estimation. But I will let OP think a bit more about how to use the sensors and come up with a design, and determine if it is really practically possible with the sensors the phone has.