Runtime Measurement of the Signals
As explained earlier, each satellite transmits a pseudo random code (PRN) which is known to the receiver. The receiver can compare the PRN in its memory with the PRN it just received.
The following graph shows two identical codes. The colored rectangles symbolize binary 1, white gaps symbolize 0. The violet rectangles are the signal from the satellite; the orange rectangles are the signal from the receiver. Now it is determined how “far” the signals have to be shifted until they are aligned. The distance corresponds to a time – the runtime of the signal from the satellite to the receiver. By means of this runtime the distance between the satellite and receiver can be calculated.
But how is the shifting done in practice? The received signals are very weak, all satellites transmit on one frequency and whatever reaches the receiver is a great mess of data. The solution to this problem is provided by a tricky algorithm named cross correlation which is rather insensitive against disturbances.
In the following the procedure shall be explained for a simple and well-defined signal.
The upper row shows a segment of a PRN-code of a satellite, the middle row shows the same segment of the receiver. The green column symbolizes the start of the code. It can be seen that in the first example the code of the receiver is a little behind time. In the cross correlation the signals are multiplied with each other, resulting in the signal in the lowest row. The signals in the lowest row are summed up, giving a value of 9 (9 x 1 plus 39 x 0).
Now the signal of the receiver is shifted step by step and after each shift a cross correlation is done. This results in a figure for each shift. In the second example the signals are congruent. The sum at the end of the cross correlation is bigger than before.
If the signal is shifted further, the cross correlation again leads to smaller correlation values.
The drawing on the left shows correlation values for shifts from -7 to 13. A clear maximum is obtained for a shift of 3. The function is normalized to 1 what means a 100 % correlation of the signals.
In reality, the process of cross correlation is a little more complex. For example, when moving the GPS receiver, the signal is compressed or stretched by the Doppler effect. On the one hand, this fact allows a determination of the speed, on the other hand this complicates correlation, as the signals do not only have to be shifted, but must also be stretched or compressed.
Now we want to use the principle explained above on the GPS signals. We already learned that the C/A code is composed of 1023 chips, being transmitted with 1.023 MHz and therefore being repeated every 1000 microseconds. At the speed of light, 1000 microseconds correspond to a distance of about 300 km. this means the signal is repeated every 300 km. Each column in the graph above corresponds to one chip of the GPS signal. The calculated shift of 3 therefore means 3 chips or a distance of 0.9 km.
Now what does this distance of 0.9 km mean? And: as the signal shift is only known within an accuracy of 1 microsecond, the distance is known with an accuracy of 300 m. How can GPS then be much more precise?
The answer to the second question first: modern GPS receiver are capable of calculating the signal shift as precise as 1 % of one chip. Therefore the distance to the satellite can be calculated with a precision of 3 m.
Concerning the first question:
All data packets of the C/A-Code are numbered (z-count). As soon as a packet is received and decoded, the receiver can calculate the time this packet was under way. From this, a pseudorange is calculated which means the distance to the satellite but containing the clock error. With at least four of the pseudoranges it then can calculate the actual distance and thus the position. Regarding pseudoranges, also see here.