HDB3 Code
High-Density Bipolar 3-zero code, an enhancement of AMI that avoids long zero sequences.
The Problem: The Silence of Zeros in AMI
The is excellent at eliminating the DC component in a signal. However, it has a critical weakness: a long, uninterrupted sequence of zeros () results in a flat, unchanging zero-volt signal.
This "silence" is problematic because the receiver relies on signal transitions (changes in voltage) to synchronize its internal clock with the sender's. Without transitions, the receiver's clock can drift, leading to timing errors and misinterpretation of the data. HDB3 was invented to solve exactly this problem.
HDB3: High-Density Bipolar 3-Zero Code
HDB3 is a "smart" modification of the AMI code, widely used in European telecommunication systems. Its name perfectly describes its function:
- High-Density Bipolar: It's a bipolar code (using +V, 0, -V) that can handle "high densities" of zeros without losing synchronization.
- 3-Zero: It guarantees that there will never be more than three consecutive zeros in the output signal, regardless of the input data.
For most of the data, HDB3 behaves exactly like AMI. The clever part lies in how it handles a sequence of four or more zeros.
The Core of HDB3: Substitution Rules
Whenever the encoder encounters a sequence of four consecutive zeros (), it replaces this sequence with a special four-symbol pattern. There are two substitution patterns available: 000V and B00V.
Understanding the Special Pulses
- V (Violation) Pulse: This is a non-zero pulse (+V or -V) that intentionally breaks the alternating polarity rule of AMI. A 'V' pulse always has the same polarity as the immediately preceding non-zero pulse. This intentional error is a special signal that the decoder recognizes.
- B (Bipolar) Pulse: This is also a non-zero pulse (+V or -V) that substitutes for the first zero in the sequence. Unlike a 'V' pulse, the 'B' pulse conforms to the alternating polarity rule of AMI, maintaining the signal's overall DC balance.
The Balancing Act: Choosing the Right Substitution
The choice between using 000V or B00V is governed by a rule designed to keep the signal DC-balanced. The goal is to ensure that consecutive Violation ('V') pulses have alternating polarities.
The Rule: The encoder counts the number of non-zero pulses (regular '1's and any 'B' pulses) that have occurred since the last substitution.
If the count is ODD...
The sequence is replaced with 000V. The 'V' pulse violates the AMI rule (it has the same polarity as the last pulse).
If the count is EVEN...
The sequence is replaced with B00V. The 'B' pulse follows the AMI rule, and the 'V' pulse has the same polarity as the 'B' pulse.
HDB3 in Action: A Step-by-Step Example
Let's encode the following binary stream:
- Input : Last pulse was none. Start with .
Encoded:+ - Input : No substitution needed.
Encoded:+ 0 - Input : Last pulse was . Alternate to .
Encoded:+ 0 - - Input : Time for a substitution.
- Count non-zero pulses since last substitution: 1 pulse (). This is an ODD number.
- Rule for ODD: Use .
- Polarity of : Must be the same as the last pulse ().
Encoded:+ 0 - 0 0 0 - - Input : Last pulse was , which had polarity. Alternate to .
Encoded:+ 0 - 0 0 0 - + - Input : Last pulse was . Alternate to .
Encoded:+ 0 - 0 0 0 - + - - Input : Another substitution.
- Count non-zero pulses since last substitution (): 2 pulses ( and ). This is an EVEN number.
- Rule for EVEN: Use .
- Polarity of : Must alternate from the last pulse (), so is .
- Polarity of : Must be the same as , so is also .
Encoded:+ 0 - 0 0 0 - + - + 0 0 +
Final Encoded Signal: + 0 - 0 0 0 - + - + 0 0 +
Interactive HDB3 Encoding
Enter binary sequence (0s and 1s only)