How Gravity Works on iPhone

Here is the figure from developer.apple.com to explain how Earth’s gravity affects on the device. Let’s look at examples one by one.

First of all, I recommend to turn off “High-Pass Filter” from the settings screen so that you will see raw output from the accelerometer.

If you face the left green arrow (-X) toward the center of the Earth, you will get -1 which is 1 g is equal to 9.81 m/s^2 = 32.2 ft/s^2.

In same way, you will get -1 on Y axis if you face the bottom of the iPhone toward the center of the Earth.

Repeat same thing for Z axis. You will get -1 if you face the bottom of the iPhone toward the center of the Earth.

.

.

.

What’s happen if I apply High-Pass Filter?

I set High-Pass Filter to On as default setting because it’s fun :) . I’m also apply scale (power of 10) after applying the filter to pickup sensitive movement. The purpose of high-pass filter is to extract accelerated motion without gravity.

Here is the pseudo-code:

for i from 1 to n
y[i] := a * (y[i-1] + x[i] – x[i-1])

a is a filtering factor and I picked a value 0.1.

I uploaded the data then I sent email the URL to my self. Try to open .csv files with your Excel or similar spreadsheet program. Sometime it will send data twice, so drop similar files. When you extract data, the exaggeration values are not appeared on your excel sheet. This means, you get raw values right after the high-pass filtering; They are the original values before I multiply value with power of 10.

.

Let’s compare two different styles.

.

First, let’s bring some data from the previous section. Here is the example of High-Pass Filter Off:

If there is no high-pass filter, the values are based on the orientation of device. In this example, I hold device straight and I shake for few seconds. Since -Z axis is facing down, the last graph tends to be negative. X and Y are normal position so they just react plus or minus for motions around zero.

.

Then, let’s change the configuration. Here is the example of High-Pass Filter On:

You might noticed that the high-pass values are much smaller but it’s move around zero. In iSeismometer App itself, I’m applying multiplication but for exporting data, I just dump the raw values. They react for acceleration around axis and the center is always zero. It does not matter the orientation of the device.

Another important thing is that the horizontal axis shows 100 data per second since I set the Target Sampling Rate to 100hz. This means, the iPhone tries to scan motion 100 times per second.

.

.

Here is the sample data and images:

Data Files (Zip File)

Note: I excluded first 20-25 data set since iSeismometer’s initialization time.

.

.

.

Conclusion

If you turn off the High-Pass filter, it’s useful to determine gravity on the device. +1 on a specific axis mean, the Earth force 9.81 m/s^2 on the device in the specific direction. If you shake the device, and if you see +2 g, you are forcing the device to feel 2* 9.81 m/s^2  = 19.62 in certain direction.

On the other hand, if you turn on the High-Pass filter, it will cancel out gravity and extract the motion / acceleration on the device. The values are much smaller but it’s useful to determine how the device has been moved.

This is my first attempt to explain how iSeismoemter extract the data, so please feel free to give me the feedback. I would like to improve more details.