# How does my phone get an accurate reference time for calculating distance from GPS satellites?

So if I understand this correctly, my phone uses trilateration to figure out a position in 3D space using the distance from various satellites.

In order to figure out the distance from those satellites, you need to figure out the time difference between when the signal was sent and when it was received.

But how does my phone have an accurate enough time for that? Or battery powered GPS? Do those get the correct time from cell phone towers or something!

The trick is that your local clock does not not need to be accurate, it just needs to be consistently in error (i.e. short term change isn't much). That is OK for a typical quartz oscillator.

So lets go with four satellites. Assume that you are trying to solve for three position values (X, Y, Z - say from the centre of the earth, Earth Centered Earth Fixed). However your position measurements are in actually time measurements (time from transmission at each satellite to reception at your receiver), so they are all in error by your local clock error. However since you have a fourth measurement, you can resolve that error (which is common across your four time / distance measurements).

So if you know when each signal was "sent" (timestamped by the satellite, which has a highly accurate clock set), and you know your local reception time (with a constant bias error), you can calculate the four unknowns (X, Y, Z and dt).

• I'm sorry, I'm still getting confused by this. How exactly does the fourth one resolve that error if there is still a time delay in the transmission of the signal to the receiver? – geekman Aug 28 '16 at 9:34
• Updated the answer - you have delay from four satellites, but you have all of the time-of-transfer info which you can turn into a distance. – BradHards Aug 28 '16 at 10:28

The frequency of the clock in your mobile is stabil enough, the time offset from the GPS time is considered as unknown. That is why four satellites are necessary for 3D position, there are three position unknowns (latitude, longitude, altitude) and a time offset.

• This doesn't make sense still - one, don't you require 4 distances from a point to figure out its position in 3D space? 3 distances is the minimum for a 2D plane - Is it not finding a 3D point but rather a 2D point on the earth? Also, how does a satellite figure out the time offset? Wouldn't that signal also take time to reach the receiver and be just the same as the rest of the signals? – geekman Aug 28 '16 at 8:31
• If you know you are on the surface of the Earth or near to it (on a plane), three distances enough. Not the satellite figure out the time offset but the onboard GNSS receiver. Yes, it takes time to get the signal from the satellite, but the signal is carries modulated information, for example the when the signal has started. The calculation is really complex... – Zoltan Aug 28 '16 at 8:41