One of my previous posts was about the GPS and how there are multiple ways for to figure out where you are. This one is about accelerometers. For a detailed description look at http://en.wikipedia.org/wiki/Accelerometer. This one is a short look at it.
I wont go into theory. An accelerometer measures acceleration. There are really three directions that you can measure acceleration, so why not measure in all three. X, Y and Z. But then every acceleration needs a point of reference, which is gravity. Gravity affects our every move and so that is the fundamental force responsible to start figuring out motion.
If you have not played the labyrinth game on the iPhone, or on an android phone, now is a good time to take a break and play it. It is the best kind of primer that you can get on what the objective of an accelerometer is.
In a smart phone an accelerometer is a really good way to figure out the orientation that you are holding the phone at. Based on whether you are holding it in a portrait mode or a landscape mode the user interface can change to show you a different view, or even a different perspective on the data you are looking at.
Now is a good time to read a bit more. Take a look at http://invensense.com/mems/principles.html or just continue reading.
X Y and Z we understand, but how does it translate into physical motion. We like to think that it’s the physical plane, but its based on a point of reference. If you keep the phone flat on the desk, it is acceleration in the X, and Y, and when you lift it, it is the Y direction. But the point of reference is a single point. And X, Y and Z are all considered together.
So a simple accelerometer needs gravity as a fundamental input. The motion of the X, Y and Z axis is in relation to gravity. So lets take this a little further. With the phone flat on the desk, if you have an accelerometer setup in the Z plane, you will now be able to detect when somebody picks up the phone. X…if you slide the phone to the left or right it is the X plane. If you move the phone up or down (flat on the table, don’t cheat…) then that is the Y plane.
Remember that it is detection the acceleration in a certain direction. No more…and no less. So if you pick up the phone, to look at the screen, you are affecting it in the Y and Z plane.If you physically turn to the left or right, holding it in the same position it is the X. I wish I was more graphical but I want to figure out a way to show this in pictures. Till then I will try to give you an exercise to do.
So how does your phone recognize that it has been tilted from portrait to horizontal, it needs to have figured out which position it was in at the start. Have you ever shaken the phone to make it recognize the orientation you want. Then you know.
You really need to use all three axis movements in your program (did I already tell you to go play with labyrinth?). So it does not translate into a physical plane, but something slightly different…pitch, yaw, and roll. Ok that’s not correct. It’s Pitch and Roll that can be detected by a three axis. Yaw is a compass value, where as the accelerometer is measuring acceleration.
Where did that come from…aircraft. If you think about it there are really three motions that the aircraft uses for control. Pitch, where the nose goes up or down, and roll where the wings go up and down. Yaw is when the nose goes left or right, And if you want to fly the airplane you better have a handle on all three.
Now think about flying an airplane in a simulator on your phone, and I think you get it. You hold the phone in a landscape mode, for the phone (I mean plane) to go up or down you tilt it forward or back. To turn left or right you tilt the phone to the left or right, and you physically move the phone up or down to add lift. And if you think about it, that’s all three axis, X, Y, and Z. But it turns out that it was not geometric as you tried to draw it on paper, but more realistic.
I wonder why you can scroll through a document by locking it in “space” and moving the phone around to scroll through it. If you think about it, it needs a lot more…but I’m saving that for a later post…