CDMA & Autocorrelation

Imagine four ultrasonic beacons in the same room, all transmitting on the same frequency band at the same time. A microphone hears one tangled signal — yet a receiver who knows each beacon’s spreading code can pull them apart cleanly. The trick is the autocorrelation of a pseudo-noise (PN) sequence: it has a single sharp peak at zero lag and stays near zero everywhere else. Different codes are nearly orthogonal, so each beacon’s message survives despreading while the others wash out as noise.

Controls

127 chips
1.00
0 chips

Codes are Gold codes built from a preferred pair of maximum-length LFSR sequences — the same construction used for GPS C/A. With chip rate fc = 20 kHz in air, one chip is c/fc ≈ 1.7 cm, and the spreading sequence repeats every N chips.

The spreading codes

Code A
Code B

Each chip is ±1. The sequences look random, but they are deterministic — the receiver knows the exact pattern, which is what makes despreading possible.

Autocorrelation of code A

RAA(τ) · circular
RAA(0) peak at zero lag = N
RAA at current lag drag the lag slider above
Off-peak |RAA| max for any τ ≠ 0

Yellow line is the current lag. The cyan curve is the full circular autocorrelation. A clean PN code has one tall spike at τ = 0 and a thin baseline elsewhere — that lone spike is what lets a correlator recover the code from noise and find its arrival time.

Cross-correlation between code A and code B

RAB(τ)
max |RAB| over all lags
peak ratio RAA(0) / max |RAB| how cleanly users separate
processing gain 10·log10(N) dB

For Gold codes of length N = 2n−1, cross-correlation peaks are bounded by ~√(2N), much smaller than the autocorrelation peak of N. That gap is what keeps users separable.

Multi-user CDMA · four beacons in the same band

Each beacon sends a single ±1 bit by transmitting (bit) × (its code). Click to flip bits. The acoustic channel sums them and adds noise. The receiver despreads with each code in parallel.

received signal r[n] = Σ bk·ck[n] + noise
running correlator output (one trace per user)

Each trace is the running dot product r·ck as it sweeps across the buffer. At the end of one code period it lands far above zero (bit = +1), far below (bit = −1), or near zero (beacon off). Crank σ up: at some point the noise overwhelms the processing gain and decisions start flipping.

Why a single peak does all the work
Step 1 · spreading

The transmitter modulates a slow data symbol b ∈ {±1} onto a fast pseudo-noise chip sequence c[n] ∈ {±1}. The transmitted signal is s[n] = b·c[n]. The bit lasts N chips, so the bandwidth widens by a factor of N — energy is "spread" across the whole band.

Step 2 · despreading is correlation

The receiver multiplies what it heard by the same code and sums:

y = Σₙ r[n]·c[n] = Σₙ (b·c[n] + noise)·c[n] = b·N + Σₙ noise·c[n]

Because c[n]2 = 1, the signal term collapses to bN — coherent addition. The noise term is incoherent: positive and negative chips of c[n] randomize the noise samples, so they add like a random walk and grow only as √N. Signal grows as N, noise as √N, so SNR improves by a factor of N. That is the processing gain, 10·log10(N) dB.

Step 3 · multi-user separation needs low cross-correlation

If two beacons share the band, the receiver computes Σₙ (b₁c₁[n] + b₂c₂[n])·c₁[n] = b₁·N + b₂·R12. The first term is the wanted bit. The second is interference proportional to the cross-correlation between the two codes. Pick codes whose cross-correlation is small for all relative shifts (Gold and Kasami codes are designed for exactly this) and the interference stays buried below the wanted signal.

Step 4 · the same mechanism gives ranging

The autocorrelation peak is also a clock. Whatever delay the channel adds, it shows up as a shift in the location of the correlation peak. Each chip of delay corresponds to c/fc meters of path length — that is how GPS measures pseudo-ranges from satellites, and the same trick works for in-air or underwater acoustic positioning. Wider chip rate → sharper peak → finer range resolution.

Implication

One sequence design buys three things at once: multiple access (low cross-correlation between users), noise rejection (processing gain), and timing (sharp autocorrelation peak). The whole magic trick is hidden in the shape of a single function, RAA(τ).