The GNSS Signal & Code Ranging
How a receiver measures travel time by sliding a code until it clicks
Why it matters
Correlation is the mechanism that turns an invisible, below-the-noise radio signal into a concrete distance. It is how pseudoranges are formed, how many satellites share one frequency (CDMA), and why code ranging is precise to metres — motivating carrier phase for centimetres.
Prerequisites
Hearing a whisper from 20,000 kilometres
The signal from a GPS satellite arrives at your phone at roughly -160 decibel-watts — a hundred-quadrillionth of a watt, spread thin across an antenna the size of a fingernail. Here is the unsettling part: that signal is weaker than the background radio noise it arrives in. If you looked at the raw antenna voltage on an oscilloscope, you would see noise. Just noise. The satellite's transmission is below the floor, apparently drowned.
And yet your phone locks onto it in well under a second, and does it for a dozen satellites at once, all shouting on the same frequency. That should sound impossible. The resolution of the paradox is one of the most elegant ideas in all of engineering — and once you see it, you can never unsee it.
The idea, before any mathematics
The secret is that the satellite isn't sending random noise. It's sending noise you can predict. Each satellite continuously broadcasts a long, specific sequence of +1s and -1s called a PRN code ("pseudorandom noise") — a pattern that looks like static but is completely deterministic. You know it in advance. The receiver knows it in advance. Only one thing about it is unknown: how delayed it is by the time it reaches you — and that delay is exactly the travel time you want to measure.
So the receiver plays a matching game. It generates its own copy — a replica — of the satellite's code, and slides that replica back and forth in time. When the replica is misaligned, the +1s and -1s line up randomly, half agreeing and half disagreeing, and they cancel to nearly nothing. But when the replica slides into perfect alignment, every chip agrees with its partner at once, and the agreement adds up into an unmistakable spike.
That spike is the "aha." The slide required to produce it is the code phase — the travel time — the measurement. And because each satellite uses a different code, the receiver can run this matching game once per satellite, all on the same frequency, and never confuse one for another. This is CDMA: code division, not frequency division.
Finding a GPS signal isn't about hearing it louder. It's about knowing exactly what you're listening for, and recognizing it the instant it lines up.
Seeing it
Imagine two long combs of teeth pointing up (+1) and down (-1). Lay one over the other and slide. At most positions the teeth are a jumbled mismatch — for every pair that agrees, another disagrees, and the total washes out to roughly zero. Slide to the one magic offset where every tooth meets its twin, and suddenly all the agreements pile up together: a towering peak.
That is autocorrelation, and its sharpness is everything. The peak is one chip wide; a single chip of misalignment already knocks it down. Now swap in a different satellite's comb: no offset ever makes the teeth agree in bulk, so the pile-up never happens. That flat, peakless result is cross-correlation, and its near-zero-ness is what lets the sky be full of satellites without them jamming each other.
Try it yourself
The top row is the incoming signal — satellite A's code, delayed by some unknown amount. The middle row is your local replica, which you slide with the shift control. The bottom chart is the correlation at every possible shift.
- Correlation (this shift)
- -1.0
- Peak in profile
- 31.0 / 31
- Recovered code phase
- —
- Implied range offset
- —
Slide the replica until the correlation spikes — that’s the receiver finding the code phase, and the shift where it locks is the travel-time measurement. Now switch to satellite B: no shift produces a peak, because the two codes barely resemble each other. That near-orthogonality is how dozens of satellites broadcast on the same frequency without drowning each other out. Finally, bury the signal in noise: the incoming chips turn to mush, yet the peak still rises — summing many aligned chips is what pulls a GNSS signal up from below the noise floor.
Three things to try. First, slide the replica until the correlation spikes and the panel reads LOCKED — the shift where it locks is the recovered code phase. Second, switch the replica to satellite B: the peak vanishes entirely, no matter how you slide, because a wrong code simply never lines up. Third, bury the signal in noise: the incoming chips dissolve into mush you couldn't read by eye — yet the correlation peak still climbs out, because thirty-one aligned agreements reinforce while random noise averages toward nothing.
Now the mathematics
Let the transmitted code be a sequence of chips . Correlation of the received code against the replica at an integer shift (in chips) is just a running dot product:
For a good code this function has one tall, narrow peak. At perfect alignment every term is , so reaches its maximum of (the code length). One chip off, and the terms scatter between and and sum to nearly zero. The peak is triangular and about two chips wide at its base — so the finer your chips, the finer your ranging.
That connects code timing to distance. The GPS C/A code runs at a chip rate of , so one chip lasts:
A receiver that pins the peak to a hundredth of a chip therefore ranges to a few metres — respectable, but not centimetres. (Hold that thought; it is the entire motivation for the next lesson.)
Two more consequences fall out of the sum. The peak-to-floor ratio scales with the code length, giving processing gain of about decibels — for the 1023-chip C/A code, roughly , which is exactly what hauls the signal up from beneath the noise. And because two different PRN codes satisfy for all , the correlator answers "is this satellite ?" with a confident "no" at every shift — the mathematical statement of CDMA.
How this appears in engineering
A real receiver doesn't know the code phase or the Doppler-shifted frequency in advance, so acquisition is a two-dimensional search: sweep code phase against carrier frequency until a peak appears in that grid. Once found, tracking loops keep the lock — a delay-locked loop (DLL) nudges the replica using "early" and "late" correlators straddling the peak, while a phase-locked loop follows the carrier. Riding slowly on top of the fast code is the 50 bit-per-second navigation message carrying the satellite's orbit and clock; the code repeats every millisecond, so the receiver resolves that 1-ms ambiguity using the data-bit edges and the timescale from time systems.
The same principle scales across the modern signal plan: the encrypted P(Y) and M codes on the military side, and civil L2C, L5, and L1C, all trade code length and structure for better accuracy, jamming resistance, and acquisition — but every one of them is, at heart, the same sliding-comb correlation you just performed by hand.
Check your understanding
- The received signal is below the noise floor, yet the receiver locks on. What does the correlation sum do to the signal that a simple amplifier cannot?
- Dozens of satellites transmit on the same L1 frequency. Why don't they jam one another, and what property of the codes is responsible?
- The C/A chip corresponds to ~293 m, yet receivers range to a few metres. How is that possible, and where does the limit ultimately come from?
- You slide the replica and see a peak, but it is only about a third of the expected height. Name two physical reasons the peak might be suppressed.
Where to go next
You can now form a pseudorange from first principles: correlate, find the peak, read off the code phase. But notice the ceiling we hit — the chip is hundreds of metres long, so code ranging tops out at the metre level. Underneath the code, though, rides the raw carrier wave, whose wavelength is a mere ~19 cm. Measuring its phase promises millimetre precision — at the price of a maddening ambiguity about which whole cycle you're on. That trade is the subject of carrier phase and ambiguity, and it is the gateway to centimetre positioning.
Common misconceptions
- A stronger antenna is what finds the signal. The signal is below the noise floor; correlation with the known code, not raw power, is what pulls it out.
- Each satellite needs its own frequency. GPS satellites share one carrier and are separated by their nearly orthogonal codes (CDMA).
- Code ranging is centimetre-accurate. Code phase resolves to a fraction of a chip — metres for C/A — which is why carrier phase is needed for centimetres.
Key takeaways
- The code-phase shift that maximizes correlation is the travel-time measurement.
- Autocorrelation is a sharp peak; cross-correlation between different PRNs is near zero.
- CDMA uses code orthogonality so satellites share one frequency.
- Chip length sets ranging resolution (~293 m per C/A chip; sub-chip tracking gives metres).
- Correlation gain lifts a signal from below the noise floor (processing gain).