[Galaxy S I9000 General] wogfella:
We all know that the GPS unit on our beloved SGS sucks badly. Firstly it takes ages and ages to find a good signal, and secondly it chews up bucketloads of battery to get there.

The other day I was talking to someone about GPS units within some handheld devices at work, and he told me something that completely blew me away - how GPS units ACTUALLY work as opposed to how most people think they work.

Firstly let me preface this by saying that he used (and I will use) the "Lies to Children" method of technical communication. If you are not a Terry Pratchett fan, it basically means that instead of explaining a subject to the Nth degree and getting the full detail across, you sum it up with what is essentially and technically a lie - but one that's a half-truth that will pave the way for future understanding.

Example? "The sun rises in the east and sets in the west". Comparatively speaking against the Earth, the Sun does NOT move. The actual truth is the sun moves within the galaxy and within the galaxy cluster and within the universe. The earth also moves in a similar manner and also rotates on its axis with a slight wobble that technically provide seasons. How does that relate to a 5 year old? "Yeah, uh, kid. The sun, you see, it rises in the east". A "lie" but one that works for everyone, and when their brain absorbs enough other information you can explain it properly (with another "lie", but one that's more truthful than the previous one)

Back to the topic:

I thought, like most of you probably think, that a phone's GPS works by having some kind of 2-way method of communication. When you enable the GPS unit and go into maps, the device starts broadcasting to the satellites to say "I'm here, now where is 'here'?" That's not the case.

It works a bit like this (and pardon the analogies)

Let's say there are 3 satellites are in geosynchronous orbit at fixed locations. For the sake of the description we'll call them FRED, GEORGE, and BILL. A lot of time and money was spent to make sure that they don't vary that location by a factor of a few cm before they re-correct their location. A bunch more time and money went into their internal time-keeping mechanisms so that they are also VERY accurate.

From their location they broadcast a signal outward. Fred says "HI I'M FRED LOCATED AT POSITION X AND THE TIME IS SUNDAY 18TH MARCH 2012 7:15PM AND 38.123456789 SECONDS"..."HI I'M FRED LOCATED AT POSITION X AND THE TIME IS SUNDAY 18TH MARCH 2012 7:15PM AND 38.123456790 SECONDS" and so on.

George says "HI I'M GEORGE LOCATED AT POSITION Y AND THE TIME IS SUNDAY 18TH MARCH 2012 7:15PM AND 38.123456789 SECONDS"..."HI I'M GEORGE LOCATED AT POSITION Y AND THE TIME IS SUNDAY 18TH MARCH 2012 7:15PM AND 38.123456790 SECONDS" and so on.

And Bill...I can't be stuffed writing it, let's just say Bill screams out his location and the current time, multiple times a second.

Now, while some satellites broadcast in higher or lower timings, the basics are the same: Current position, plus the current (accurate) time. (Some also send information regarding the other satellites it "knows" around it. Eg, "HI I'M BILL AT POSITION Z AND THE TIME IS BLAH AND I CAN SEE GEORGE AND FRED. THEY DON'T SAY MUCH, SO IT SURE IS LONELY UP HERE").

My point here is that the satellite neither knows nor cares who you are or where you are, it just pumps out that racket like a noisy teenager with a new stereo and what they THINK is the coolest music ever.

When the 3 signals are received on the ground by the GPS unit, it works out: "Bill thinks it's THIS TIME....George thinks it's THAT TIME...and Fred thinks it's this OTHER TIME....that means my distance from each one is actually THIS FAR and the real time is NOW". From that you can bang your location in LATITUDE and LONGITUDE on a map.

Sure, there are complications due to altitude and speed and direction, and you really need more than 3 satellites to work out where you are. But the reality is that, based on the lag in the signal from transmission to receiving (able to be calculated due to the speed of light), we can work out how long each signal took to get to the unit and therefore how far from the satellites we are. If you know where the satellite is supposed to be, you can work out where you are on the globe.

It really is that simple.

So when I found all of that out, I asked the question: If the satellite is really all that counts in this case, why does our GPS blow? In fact, why does any GPS work better than others?

Well, there are multiple factors:

Firstly, just like a good barman or psychologist, some "listen" better than others. The PASSIVE radio signal needs to be received by a unit that has a decent antenna and doesn't have other electrical crap affecting it. Anyone look inside their phone and see the antenna (and it's location)? Yup, it's in a pretty bad position and it's a pretty bad antenna.

Even if we were somehow to isolate the GPS unit and bring it out away from the interference, it's a pretty bad receiver. If you've ever listened to a transistor radio and compared it to a $4000 stereo unit, you know what I mean. Noise = bad data = bad location finding.

Secondly, the signal needs to be interpreted. When each broadcast hits the phone, the receiver accepts it and shunts it to the processor to work out. Slower phones can process less signals, especially when the OS may put a limit on how much processor time should be dedicated into working out the signals (there's no point using 100% of your processor when that means you can't display it properly on the map or let the user actually interact with the maps app)

Thirdly, we don't know all the positions of the satellites. When the signals first start getting processed, your phone communicates with the NTP servers it has located in your GPS.CONF. It asks which satellites are where and where that actually may be on the globe. Remember how I said each satellite tells you it's position? That was a "lie to children" moment. The damned thing is in the SKY after all. So, while we technically know where it is, the information means jack and sh*t to the GPS unit unless it has more information available.

What I mean here is: What part of the world can that satellite see/broadcast to? The satellite doesn't know or care, and it's not broadcasting that information at any case. There's more than a couple of satellites up there, so the phone needs to check back the NTP.ORG to work out some basics. As your phone uses the GPS function more and more, it stores up the addresses of the satellites that you know and love in your neck of the woods (including ones that are not geostationary) and will need to rely less on a data connection.

That's why when you use GPS the first time after a fresh flash it is just plain crap, but after a few more tries it works better. And that's why it's important to use FasterFix or a like app to nominate the closest/best NTP server for you - the closer servers respond quicker over the 'net and also have the list of "closest" stationary satellites stored at the front of the file. If you're in Australia you don't care about the 'merican or European sats, but they come afterward "in case you're overseas"

Lastly, when you take it all into account, if you have bad weather or tall buildings around you, then the signals blasted down from on high either get muted, muddled, or bounced around. The error correction in our phones is non-existent - it doesn't actually need to be due to the fact it's a PHONE and not a GPS unit, but some devices can and do filter out the known "dodgy" signals before processing. I'm pretty sure that when the techies run out of toys to add to or fix in our phones, they'll add altimeters and thermometers and they'll fix the GPS post-processing to get the signal down pat.

In case you're wondering, the whiz-bang GPS units that can get extra awesome resolution (down to beyond cm) have the list of every single satellite location up there stored internally, the on-board processor is dedicated to working out what the signals mean, and the GPS chip itself normally has a great big honking antenna on it and is extra receptive. Ours is a 2 dollar job from some bulk offload sale.

There you have it. Thanks for letting me brain dump. Hope this helps some people's understanding!