Monday, August 19, 2013

Hold on to your phone, don't send it to heaven, and why accelerometers don't really measure acceleration.




Here's a little advice.  Hold on to your phone.  There has been some discussion at work recently about an app that encourages you to throw your phone in the air.  When you do, it tells you how high you threw it. That's it.  Of course, it tells you how you did compared to others, thus encouraging you to throw your phone higher and higher until... well... I would image this story rarely ends well.  Eventually I would think either the smartphone isn't caught and it splatters on the concrete, or worse, it hits an unwitting bystander on the head.  The app is called SMTH which stands for "Send Me To Heaven," and it seems to be gaining popularity.  Resist!  I must say that I do love the quote in the marketing of this app, “Probably the last game I´ll ever play on my current phone.”  Someone is having fun.

Still, it is interesting to understand how this application works.  Some of you may assume that the GPS is used to track the altitude of the phone when you throw it, but this is not the case.  GPSes are notoriously bad at calculating altitude, so they cannot be accurate enough to measure a throw of a meter or two.  Most phones have no altimeter.  So how do they measure how high the phone is thrown?  It turns out that they use accelerometers and the same principle that makes astronauts experience weightlessness on the International Space Station, even though they are in orbit and very much under the effects of Earth's gravity (Disclosure: the truth is that I have no information about how they do it, but I know how I did it a few years ago and it is all about accelerometers).   You can learn a little bit about how accelerometers work in the little video I put together for you on part of this subject.





To understand how this is used to calculate height of a thrown smartphone, you'll have to read on...



Some time ago I worked on a cool project building little wireless sensor devices called Sun SPOTs.  Nowadays, smartphones have a least as many sensors built-in to them as our SunSPOTs did, so some of the same applications we built for SunSPOTs would now work on a smartphone.  One of the cool sensors on both SunSPOTs and smartphones is the accelerometer.  Among other things, we used these sensors to teach kids physics.  One of the projects we did was to see how high you could throw your SunSPOT (does this sound familiar? A complete blog entry I made back in 2008 is available here).  Of course, in order to protect the SunSPOTs, we embedded them into a foam football - just a hint for those of you compelled to throw your phone in the air.



We were able to use the accelerometer to record students throwing SunSPOTs up to 50ft in the air.  How this is done is quite cool.  When you throw an object in the air, it experiences a large acceleration, the throw, and then a sort of weightlessness, and then a large acceleration when it is caught or hits the ground.  By calculating the length of time of this weightlessness, one can approximate the height it achieved as we will see below.

In physics terms, acceleration is the change in velocity over time.  The weird thing is that accelerometers don't strictly measure acceleration,  but they do measure something that is useful for calculating the amount of time that a smartphone is in the air and thus how high it is thrown.  If you haven't done so yet, watch the little video I put together on part of this subject.

A graph of the accelerometer readings from a thrown object

First lets talk about this "weightlessness" thing.  If gravity is pulling the smartphone or other device toward the ground, it clearly is being affected by gravity, so why does it experience "weightlessness?"  This is where the astronauts come in.  Imagine an astronaut standing on a hill.  Gravity would be pulling her down, but the ground stops her from falling.  Gravity is determined to suck us toward the center of mass of the Earth.  Thankfully the ground gives us something to help resist that acceleration.  The weight you feel here on Earth is really the force your body needs to exert to oppose gravity, not gravity itself.  You are being accelerated by gravity, but your frame of reference, the ground, is not accelerating (it isn't changing speed the way Gravity would like it to), so you must work to stay stationary relative to your frame of reference.

In the Space Station, the same gravitation force would be working on our astronaut friend, but there is no ground to stop her, so she feels weightless.  You see, the ISS is falling toward the Earth because of gravity just like an apple falls from a tree.  It also happens to be moving sideways very fast relative to the Earth's surface at exactly the right speed to continually miss the Earth (by exactly the right amount to keep it at the same distance from the surface).  By the time it reaches the place where it would hit the ground, it has moved far enough that the ground is now in a different direction.  That is really what an orbit is: continually falling and while moving so fast that you miss the ground.  The upshot of this is that there is no need to fight gravity while in orbit.  You let it accelerate you downward, but you also move out sideways as you fall.  You are in eternal free fall.  Since everything around you is falling too, relative to your frame of reference, the Space Station, any acceleration applies to you and everything around you equally and there is no work required to stay still relative to your frame of reference.  The result is that you feel weightless.

Accelerometers are like astronauts and you and me.  They "feel" weightless when there is no difference between the acceleration affecting two components of the accelerometer.  I call these two components a "bridge" and a "diving board."  The bridge is supported on both sides and becomes a frame of reference, while the diving board is supported on just one side and allowed to wiggle freely on the other side, as I explained in the video.  This allows us to measure a form of acceleration that includes the ability to measure the "weightless" feeling.


OK, so now we know that we can use an accelerometer to measure how long our device is in free fall. When you throw it, at release, it will have a certain upward velocity.  Because it is being constantly pulled down by gravity, we also know that in one second, it will be going 9.8 m/sec slower than when you released it.  So if we know the initial velocity, we can tell what its speed will be in one second.  The problem is that we don't know the initial velocity.  We do know that it will spend some time going up and then an equal amount of time going down.  If you threw it directly up at 9.8 m/sec, it would have a hang time of two seconds (one second going up and one coming back down) and travel 9.8m high.  So, if we know the amount of time it spent in free fall, we know that half of that time was spent falling from its high point back to earth (assuming that it is thrown and caught from approximately the same height).  Not taking wind resistance into consideration, an object accelerating for t seconds at 1 G (9.8 m/sec^2) will cover 9.8 * t^2 meters.  This is the height we are looking for.  So now (with a little algebra) we can determine that the height, h, the object achieved in t seconds of free fall (again assuming it lands at the same height it started from) is

where g is the gravitational constant (~9.8m/sec^2 or ~32ft/sec^2).


Similarly, we can calculate the velocity at which the object must have left the thrower's hand. The equation

where v is the initial velocity, tells us how fast the object would have to go in order to loft itself into the air for the given amount of time.  I don't know why this information is omitted from the smartphone app.


Cool huh?  Now you know how it all works, so there is absolutely no reason to throw your phone in the air.  Do you hear me?

However, it is perfectly fine to use this equation to calculate the height of other things that are thrown into the air... like this fellow who does not have an accelerator attached to him as far as I know, but with the video, you should be able to figure out his free fall time.  


Looks like he was in the air for about 4 seconds.  plugging those numbers in I get about ~20 meters in height with an initial velocity of ~19.8 m/sec.  What height do you get?

For more details see my original post from back in 2008 and a related post on accelerometers on amusement park rides.  You can find a review of SMTH here.