Why does the accelerometer not stabilize the measurement after the device is still?

Why does the accelerometer not stabilize the measurement after the device is still?

If one takes the values in degrees, minutes and seconds … these never cease to vary. This should not happen. If the device is still, at the angle it has reached, the value should be stable.

I built the accelerometer sample app and laid it still and there is some flickering of data at the 3rd decimal place that we round off to, It’s oscillating only between a couple of values. But why? There are two layers to that question.

Our documentation says “This value is “smoothed” based on the previous accelerometer readings in order to reduce a jittering effect when used to manipulate graphics on screen.”

So we are trying to smooth out the values to cut down on “jitter”. I can’t 100% confirm what resolution we are doing it at, but it’s likely a double. In other words, the jitter could be worse!

Where is the “jitter” coming from? Well accelerometers are very sensitive analog devices. That analog signal has to be converted to a digital signal. On iPhones, that’s a “Double”, so there will be variation in that AtoD conversion from something with lots of precision to something that has less precision. In the sampling process precision errors will be introduced and that’s your jitter.

Rob

You say: accelerometers are very sensitive analog devices. Explain something to me: are you telling me that although I see that the device is still, from the physical point of view, do you say it is moving? It could be floor vibration … or vibration that reaches the desk where I do the test. Does the accelerometer think it is moving? or something worse … I think the device is still when it really isn’t?

Accelerometers *can* depending on their quality be very sensitive. I don’t know how sensitive ones in mobile devices are. 

That said, nothing sits perfectly still, so it’s possible it could be picking up floor vibrations. But more likely it’s in the Analog to Digital conversion process. Electricity is a wave form and the amplitude of the wave is how much movement is going on and it’s continuous. The AtoD converter samples the signal at a frequency set in the device. Maybe it’s 60 times per second, perhaps faster, perhaps slower. It captures the amplitude of the electric wave on its sample period. Let’s say just for sake of discussion, the wave peaks at 100 and -100 on a typical sine wave. Depending on the sample interval, it could return 100, 50, 0, -32 etc. even while the device is sitting still. You’re going to get that value back.

Now the OS may be trying to smooth that out. We are running another level of filtering to try and smooth it out, but it has to be a balance between as much accuracy as possible vs. smoothness.

To your question, it’s hard to answer because it could be picking up micro-vibrations even while sitting still or it could just be jitter. It comes down to what you think the definition of “still” is. Lua numbers have 54 bits of floating point number resolution which can hold very precise numbers. 

Personally if you don’t need high accuracy values, you could do something like:

local moveX = math.floor( event.xGravity \* 1000 ) / 1000

that would whack off a lot of the minor resolution (maybe you need 10,000, 100,000 or even 1,000,000 depending on your needs) to smooth that value out more in particular if you want to know 'isMoving" or “isStill”.

Rob

Thanks Rob for the excellent explanation and that elegant “solution”. I am trying another solution. It resembles the method used by the digital thermometers we use to take the fever. I promise to show you the results, ja, ja, ja … whatever.

I want you to explain something else that is related to this.

The values that the accelerometer throws are between 1 and -1.

If the device is horizontal it returns a 0. If it was rotated 90 degrees clockwise it returns 1 and 90 degrees counterclockwise returns -1. This depends on the POV. I hope you understand my technical licenses, ja, ja, ja.

I wonder, if the broken 45 degrees would not have to return 0.5? or -0.5 in the opposite direction.

This does not happen. Either I’m doing something wrong or I found something strange.

Is the accelerometer response linear?

At this point, you’re really getting past my knowledge of accelerometers. Given we are basically passing the data back from the device, I would suggest that perhaps doing research on the various devices you’re testing.  I know it’s gravity related, so I would think how hard/fast you move the device has to be factored in at some point. Google may be your best source at this point.

Rob