Bits to a point
16-QAM has 16 different symbols, and 2⁴ = 16, so each symbol carries 4 bits. The bit buffer hands the mapper its first four bits: 1011. Our message is 16 bits, so it needs 4 symbols.
The mapper splits the bits: the first pair picks a level called I, the second a level called Q, each from −3, −1, +1, +3. The table is a Gray code: neighbouring levels differ in one bit. 1011 gives I = +3, Q = +1.
Draw I across and Q up. Each symbol is one dot, so 16-QAM is a 4 × 4 grid of 16 dots, each labelled with its bits. This map is a constellation diagram. Our symbol 1011 is the dot at (+3, +1).
A point becomes a wave
The oscillator makes a carrier cos(2π·fc·t) and, shifted a quarter cycle (90°), −sin(2π·fc·t). Over one symbol their product averages to zero: they are orthogonal, so each can carry its own number without disturbing the other.
The I level goes to one mixer, the Q level to the other. A mixer multiplies: the top branch makes I·cos(2π·fc·t), the bottom one Q·(−sin(2π·fc·t)). For 1011: 3·cos and 1·(−sin).
The adder sums both branches: s(t) = I·cos − Q·sin. That is one cosine with amplitude √(3² + 1²) = 3.16 and phase 18.4°. On the diagram: the dot's distance from the centre and its angle.
Every 1 ms the mapper takes four new bits and the dot jumps to a new point. The wave jumps with it, in amplitude and phase. 1000 symbols a second × 4 bits = 4000 bits a second.
Back to bits
The receiver multiplies s(t) by the same two carriers and averages over one symbol. Orthogonality kills the other branch, so out come I and Q again: (+3, +1), then (−3, −1), (+1, −1), (−1, +3).
Noise in the channel nudges every received point, so each lands in a small cloud. The receiver picks the nearest dot: the dashed lines split the plane into 16 squares. Here 3 of 128 noisy points crossed a line: errors.
More bits per symbol
64-QAM packs 64 dots (6 bits each) into the same average power, so neighbours sit about half as far apart: 0.98 instead of 2.00. More bits per symbol, but it needs a cleaner channel. Wi-Fi 6 goes to 1024-QAM.
With numpy the whole mapper is a few lines. reshape groups the bits in fours (−1 means: work out how many rows). Each level line is the Gray table as a formula. The result is one complex number per symbol.
The working
# step 1/11 · bits message 1011 0001 1101 0110 (16 bits) 16-QAM: M = 16 symbols bits per symbol = log2(16) = 4 symbols needed = 16 / 4 = 4 symbol 0 = 1011
The carrier is a teaching value: 2000 Hz with 1 ms symbols puts just two carrier cycles in each symbol so you can see them. Real radios use carriers of megahertz or gigahertz and many cycles per symbol; the maths is the same. Every curve and number in the figure is computed from this model. The noise is pseudo-random with a fixed seed, so the figure shows the same points every time. Noise, SNR and error rates get their own lessons in the next module.