b11b20b31b41b51b61b70b80ENCDECC1import numpy as np2b = np.array([1,0,1,1,1,1,0,0])3nrz = 2*b - 14half = np.tile([-1, 1], 8)5man = np.repeat(nrz, 2) * halfb1–b2–b3–b4–b5–b6–b7–b8–1+A
012345678−A0+At / Tb (bit times)levelLINE SIGNAL10111100average = 0.625 Aaverage = 0.25 Ano edge for 4 Tb4 equal bits, flat1: low→high · 0: high→loweach 1 flips sign0R2R3R00.51frequency fS(f) / A²TbSPECTRUM, RANDOM BITSon-offpolarManchesterAMI← DC line at 0 Hz, power A²/4(arrow height not to scale)R2R
Coloured parts: what the current step is about; everything else rests in whiteBlocks: bits to send, encoder, cable with a DC-blocking capacitor, receiver and its clock, bits received, a Python cardPlots: the line signal of the current code, and the power spectra of the codes for random bitsThe token carries one bit at a time as a level (↑ / ↓ = Manchester rising / falling edge); the yellow line marks it on the plotThe bits 1 0 1 1 1 1 0 0 sent in four line codes and read back. Manchester has two opposite conventions. This lesson uses IEEE 802.3 (used by 10BASE-T Ethernet): a 1 is a low-to-high transition, a 0 high-to-low. G. E. Thomas's original rule is the reverse.

Bits become levels

  1. A cable carries voltages, not ones and zeros. A line code is the rule that turns each bit into a voltage pulse lasting one bit time, Tb. Here are 8 bits to send: 1 0 1 1 1 1 0 0.

What goes wrong

Better codes

Back to bits

The working

# step 1/10 · bits

bits to send:  1 0 1 1 1 1 0 0

bit time    Tb  (seconds per bit)
bit rate    R = 1 / Tb  (bits per second)

line code = the rule
  bit  ->  voltage for one Tb

levels are drawn in units of A,
the pulse height in volts

Levels are drawn in units of A, the pulse height. The spectra assume long streams of random, equally likely, independent bits with full-width rectangular pulses, normalised by A²·Tb; every curve is computed from the formulas in the model and checked against a DFT of simulated bits. The motion is slowed down a great deal: at 10 Mbit/s one bit lasts 100 ns.