Search code examples
iosiphoneobjective-csignal-processingaccelerometer

How to getting movement size from 3 axis accelerometer data


I did a lot of experiment using the accelerometer for detecting the movement size(magnitude) just one value from x,y,z acceleration. I am using an iPhone 4 with accelerometer update frequency 1.0 / 50.0 (50HZ), but I've also tried with 100HZ, 150HZ, 200HZ.

Examples:

Acceleration on X axis Acceleration on Y axis Acceleration on Z axis

I assume ( I hope I am correct) that the accelerations are the small peaks on the graph, not the big steps. I think from my experiments that the big steps show the device position. If changed the position the step is changed too.

If my previous assumption is correct I need to cut the peaks from the graph and summarize them. Here comes my question how can I cut those peaks without losing the information, the peak sizes.

I know that the high pass filter does this kind of thinks(passes the high peaks and blocks the noise, the small ones, I've read some paper about the filters. But for me the filter cut a lot of information from my "signal"(accelerometer data).

I think that there should be a better way for getting the information out from the data.

I've tried a simple one which looks nice but it isn't correct.

I did this data data using my function magnitude

for i = 2 : length(x)
    converted(i-1) = x(i-1) - x(i);
end

Where x is my data and converted array is the result.

The following row generated a the image below, which looks like nice.

xyz = magnitude(datay) + magnitude(dataz) + magnitude(datax)

enter image description here

However the problem with that solution is that if I have continuos acceleration the graph just will show the first point and then goes down. I know that I need somehow better filter, but I am bit confused. Could you give some advice how can I do this properly.

Thanks for your time, I really appreciate your help

Edit(answers for Zaph question):

What are you trying to accomplish? I want to measure the movement when the iPhone is placed to desk, chair or bed. The accelerometer is so sensible if I put down a pencil it to a desk it shows me. I want to measure all movement that happens in a specific time.

What are the scale units? I'm not scaling the data.

When you say "device position" what do you mean, an accelerometer provides movement (in iPhones with gyros) I am using only the accelerometer. When I put the device like the picture below I got values around -1 on x coordinate, 0.0 on z and y coordinate. This is what I mean as device position. enter image description here


Solution

  • The measurements that are returned from the accelerometer are acceleration, not position.

    I'm not sure what you mean with "big steps" but the peaks show a change of acceleration. The fact that the values are not 0 when holding the device still is from the fact that the gravitation accelerates the device with 9.81 m/s^2 (the magnitude of the acceleration vector).