Field Guide · term

Also known as: NRZI, non-return-to-zero inverted

NRZI (non-return-to-zero inverted) is a line code in which each bit is conveyed by whether the signal level changes, not by the level itself: conventionally a 0 causes a transition and a 1 causes none (or vice-versa).1 It is a differential line code — the meaning is in the change — used by AX.25 / APRS, AIS, USB, and many other framed serial links.

011001 transition = 0 · no transition = 1
NRZI encodes bits as the presence or absence of a level transition, which guarantees frequent edges for timing.

How it works

Ordinary NRZ (non-return-to-zero) maps a 1 to one level and a 0 to the other and holds it for the bit period — simple, but a long run of identical bits produces a long flat stretch with no edges, and a receiver with no separate clock line has nothing to synchronise to. NRZI breaks that coupling between bit value and signal level. Instead, each bit decides whether to toggle: in the common convention a 0 flips the level and a 1 leaves it unchanged (the “inverted” refers to the toggle-on-zero rule; the opposite mapping, toggle-on-one, is equally valid and used by USB).

Two useful properties fall out:

  • Polarity independence. Because information lives in transitions, not absolute levels, an accidental inversion of the whole signal — a swapped pair, an inverting stage in the radio path — leaves the decoded bits unchanged. This is the same trick as differential decoding applied to a baseband line code.
  • It still needs help with long same-bit runs. NRZI guarantees an edge only for the bit that toggles. A long run of the non-toggling bit (all 1s in the toggle-on-zero convention) still produces a flat stretch, so NRZI alone does not solve the timing problem — it must be paired with a rule that forces transitions.

That rule is bit stuffing. HDLC and its derivatives insert a 0 after every five consecutive 1s in the data before NRZI encoding; since a 0 always toggles the line, no run longer than five bits can pass without an edge, capping the interval the receiver’s clock recovery can drift. The receiver removes the stuffed bits after decoding. The six-consecutive-1 pattern that bit stuffing can never produce in data is reserved as the 01111110 flag that marks frame boundaries.

In practice

NRZI plus bit stuffing is the standard physical-layer coding of the HDLC frame family, which is why it shows up across so many systems: amateur packet radio and APRS (AX.25 is an HDLC variant), marine AIS, the USB serial bus, and a range of industrial and telemetry links. In the RF cases the NRZI bitstream typically modulates an FSK or GFSK carrier, so the demodulated baseband is the NRZI waveform the decoder must slice and un-stuff.

Relevance to SDR

A software decoder for an AX.25/AIS-style signal FM- or FSK-demodulates the channel to recover the NRZI baseband, slices it to a hard bitstream, then reverses the coding: detect transitions to undo NRZI, strip stuffed bits, and find the HDLC flags to frame the packet. Getting the NRZI and bit-stuffing steps right is what makes the framing and CRC check downstream succeed. GopherTrunk’s demodulation pipeline handles the constant-envelope FSK baseband these formats ride on; the NRZI/HDLC layer is the framing that sits on top of that recovered bitstream.

Sources

  1. Non-return-to-zero — NRZI — Wikipedia, for the transition-based line-code definition and conventions. 

See also