Hamming Codes: Error Detection and Correction Mechanics
Classified in Electronics
Written on in
with a size of 2.49 KB
Error Code 2: Detection and Correction of Errors
Error Correcting Codes Functionality
Error correcting codes not only indicate the existence of an error but conveniently provide information about which binary digit or digits are affected. Therefore, their correction involves inverting the values of the affected bits.
These codes are primarily used in situations where:
- Retransmission of the message cannot be requested when an error occurs.
- Transmission systems frequently produce errors in the lines.
They are of little use in systems where the error rate is low and retransmission is feasible, since the amount of redundant digits necessary to correct multiple bit errors becomes very large relative to the length of the word being conveyed.
Hamming Parity Check Implementation
One of the most commonly used error correcting codes is the Hamming parity check. This method introduces more than one parity bit for each word. If the number of parity bits is correctly calculated, the system can detect which digit has an error and subsequently correct it. Each parity bit is generated from a specific group of information digits (not all of them), including the parity bit itself.
Basic Principles of Hamming Code Construction (Single-Bit Error Correction)
Assuming a natural binary code of $N$ bits, the basic construction principles for a Hamming code capable of correcting single-bit errors are:
- Every word of $N$ binary digits has $K$ additional bits appended, generated from the first $N$ digits, to form a codeword of length $N + K$.
- The parity digits are not placed at the end of the information digits but are interspersed among them, occupying positions that are powers of two (e.g., 2, 4, 8, 16, etc.).
- The $K$ added digits are generated such that $K$ conveniently chosen parity tests return a binary word indicating the position of the erroneous bit, or zero if no error occurred. Each parity digit may be included in more than one parity calculation.
- If a word of length $N + K$ is transmitted, and there is a possibility of error in any of the $N + K$ digits plus the "no error" case (total $N + K + 1$ different cases), the following inequality must be satisfied so that the word can represent all possible cases: $2^K \ge N + K + 1$.
Optimality Condition
A Hamming parity check code is considered optimal when it satisfies the equality: $N = 2^{(K-1)}$