A carrier and its phase
A radio sends bits by changing a carrier: a steady cosine, here c(t) = cos(2π·3000·t). A sine wave has three things to change: amplitude, frequency and phase. ASK and FSK change the first two. Phase-shift keying (PSK) changes the phase.
BPSK: one bit per symbol
Binary PSK sends one bit per symbol. Bit 1 sends the carrier as it is: phase 0°. Bit 0 sends it half a cycle later: phase 180°. Each symbol lasts T = 1 ms, which is 3 carrier cycles here.
Shifting a cosine by half a cycle turns it upside down: cos(ωt + π) = −cos(ωt). So BPSK is the carrier times +1 or −1. A mixer is a multiplier; where the bit changes, the wave jumps.
Draw each symbol as a point: how much cosine it holds. BPSK has two points, +1 and −1, on the I axis (I for in-phase, the cosine). This picture is a constellation diagram. Its two points are 2.0 apart.
Getting the bits back
The receiver multiplies what arrives by its own copy of the carrier. For bit 1 that gives cos², never negative; for bit 0, never positive. It then adds up (integrates) over the symbol. Multiply-then-integrate is a correlator.
At the end of each symbol the correlator holds +1 or −1, then resets. Positive means 1, negative means 0. Noise would have to push the result past zero, a whole 1.0 away, to flip a bit.
QPSK: two bits per symbol
Now feed the cosine correlator −sin(ωt), the carrier shifted 90°. Over whole cycles cos·sin adds up to exactly 0. So a second bit stream can ride on the sine without disturbing the first. See the lesson “I and Q: two carriers in one channel”.
Quadrature PSK sends two bits per symbol. The first bit sets the sign of the cosine part (I), the second the sign of the −sin part (Q), each 0.71 V. Added, they make one cosine with one of four phases.
QPSK's constellation has four points, all at radius 1. Going round, 11, 01, 00, 10, neighbours differ in one bit only: Gray coding. A small noise error that lands on a neighbour costs one bit, not two.
A cosine correlator reads I and a −sin correlator reads Q, at once. Eight bits arrive in 4 ms, not four: same symbol rate and bandwidth (range of frequencies used), twice the bit rate. At equal energy per bit, errors are as rare as BPSK.
In code
With numpy, np.outer builds one row of carrier per symbol, already times +1 or −1: that is BPSK. The last line multiplies by the carrier and averages each row, the correlator. Out come +1, −1, +1, +1: bits 1 0 1 1.
The working
# step 1/11 · carrier
carrier c(t) = A·cos(2π·fc·t)
A = 1 V
fc = 3000 Hz (period 0.333 ms)
three knobs:
amplitude -> ASK
frequency -> FSK
phase -> PSK (this lesson)
phase = where in its cycle the wave starts
(a slowed teaching example: real carriers
run at MHz to GHz)
A slowed teaching example: 1000 symbols a second on a 3000 Hz carrier, 3 cycles per symbol, amplitude 1 V. Real radios put many more cycles in each symbol (GPS sends BPSK at 1.023 million chips a second on a 1575.42 MHz carrier). Every curve is computed from the model. The figure shows a perfect channel: no noise, no delay, and the receiver's carrier exactly in phase with the transmitter's. Noise and the nearest-point decision come in the next module; filtered pulse shapes (instead of the square symbols here) keep the bandwidth small.