How does CDMA spreading and de-spreading work mathematically? Walk through a two-user example.
Each user multiplies their data bit (+1 or -1) by their spreading code to create a spread signal. The receiver extracts one user's data by multiplying the combined signal by that user's code and averaging — other users cancel out.
* Worked two-user example: correlating each code recovers x1 and x2. *
Setup — two users with orthogonal codes (SF=4):
- Spreading code 1: c₁ = (+1, -1, +1, -1)
- Spreading code 2: c₂ = (+1, +1, -1, -1)
- Verify orthogonality: c₁ · c₂ = (+1)(+1) + (-1)(+1) + (+1)(-1) + (-1)(-1) = 1 - 1 - 1 + 1 = 0 ✓
Spreading:
- Sender 1 sends bit x₁ = +1: spread signal z₁ = x₁ · c₁ = (+1, -1, +1, -1)
- Sender 2 sends bit x₂ = -1: spread signal z₂ = x₂ · c₂ = (-1, -1, +1, +1)
On the air — signals combine:
Z = z₁ + z₂ = (0, -2, +2, 0)
De-spreading (receiver wants user 1's data):
y₁ = (1/4) × Z · c₁ = (1/4) × [(0)(+1) + (-2)(-1) + (+2)(+1) + (0)(-1)] y₁ = (1/4) × [0 + 2 + 2 + 0] = (1/4) × 4 = +1 ✓ (correctly recovered!)
De-spreading (receiver wants user 2's data):
y₂ = (1/4) × Z · c₂ = (1/4) × [(0)(+1) + (-2)(+1) + (+2)(-1) + (0)(-1)] y₂ = (1/4) × [0 - 2 - 2 + 0] = (1/4) × (-4) = -1 ✓ (correctly recovered!)
The magic: Even though both signals were transmitted simultaneously on the same frequency, each receiver perfectly recovers its intended data. User 2's signal completely cancels out when correlated with user 1's code, and vice versa. This is the power of orthogonality.
Go deeper:
CDMA encoding & decoding — worked chip example (YouTube) — spreads two users with orthogonal codes, sums on the air, and correlates back — the same maths as above, step by step.
Chip (CDMA) (Wikipedia) — a chip-by-chip worked example of spreading and correlation de-spreading, the same maths as above.