0
votes

I'm playing with accelerometer now. The main idea is to move cursor using phone. I'm just accumulate values (deltas) that accelerometer gives me every tick to x and y position.

The problem is that accelerometer sends parasite values when I stop moving phone. For example: When i move phone right, i have sequence like:

1, 2, 5, 3, 5,

Then I stop moving. Accelerometer still produces values, but in opposite direction, like:

-3, -2, -2, -1

An than it generates zeroes. How can i avoid values, that moves me to the reverse direction, without any phone motion?

1

1 Answers

0
votes

That's how accelerometers work...

Don't use these values directly. Integrate (=sum) them, you'll get a speed. Integrate the speeds, you'll get positions.

It needs to be heavily filtered, though, because of drift, and because of the constant -9.8m/s^-2 of gravity (the accelerometer reports both "manual" acceleration and "earth" acceleration, and separting them is not easy)

EDIT :

Drift can be corrected by detecting a rest position, and manually stopping the move (low velocity -> force 0 velocity)

Gravity can be removed by detecting the gravity direction at rest, then removing this vector from the next ones. This only works if the phone isn't rotated too much. This can be correct using a gyroscope, but you have to be sure that the gyroscope's values aren't computed from the accelerometer like on some phones.