Hamming Code: Error Correction and Detection


The hamming code is an error detection and correction technique. It is a seven bit code. It was introduce by R.W. Hamming. Hamming code is named R. W. Hamming of Bell Labs. When the packet of data transmitted through the channel or over the network, there is possibility that the data may be lost during the transmission of data. In this technique we detect error and correct it.

In hamming code, the source encodes the message by adding redundant bits within the data. These redundant bits are extra binary bit which are use to inserted with specific position in data itself to detection of error and correction. When receiver or destination receives the data it performs the recalculation to find out error and the bit position that has error. In this tutorial we are going to discuss about humming code.

What is an Error?

When data is transmitted in channel, during transmission data can be loses. The region behind loses of data by external noise or other physical failures, and the input data is not same to the output data. This mismatch is known as “Error.”

Types of Errors

There are mainly three types of Error that occur in data transmission from the transmitter to the receiver.

  • Single bit errors
  • Multiple bit errors
  • Burst errors

Now let us discuss these three errors one by one.

  1. Single Bit Errors

In single bit errors, the entire sequence of data has only one bit error is known as “single bit error.” Most of the time single bit error is not common. This is only occurs in parallel communication because this type of communication use bitwise transfer in a single line.

  1. Multiple Bit Errors

In multiple bit error, if two or more than two bit error in data sequence is known as “Multiple bit error.” This type of error occurs in serial and parallel transfer of data communication system.

  1. Burst Errors

In this error the set of bits in data sequence is known as “Burst error”. This can be calculated in from the first-bit change to last bit change.


What is Error Detection and Correction?

In digital communication system, the error in bits will be occurs due to transfer of data from one place to another place. If error data cannot be detected and corrected the data will be lost. For good communication, system data should transfer with high accuracy.

Error detection is method and it detect the error in sequence of binary date bit. For detection of error we use the redundancy code by add inside the data when data is transmitted to source, and it is called “Error detecting codes“.

The error detection is three types, and it is given below:

  • Parity Checking
  • Longitudinal Redundancy Check (LRC)
  • Cyclic Redundancy Check (CRC)

Parity checking:

  • It is a parity check
  • It has a cost-effective mechanism for error detection.
  • The redundant bit is known as a parity bit, and it is appear every unit. The total numbers of 1’s should be even.

Longitudinal Redundancy Check (LRC)

This is an error detection technique in which a block of bits is organized in the tabular format. This method use to calculate the parity bit for every column

Cyclic Redundancy Check

Cyclic Redundancy Check is an error check technique in which the sequence of redundant that must be appeared to the end of the unit.

Hamming Code: Error Detection

Let us understand the hamming code with example, we have to identify the bit position of the data and all the bit positions are the powers of 2 are marked as parity bits (e.g. 1, 2, 4, 8, etc.). Below the image you can easily visualizing the hamming code.


Step 1: Check the parity bit P1 by technique check one and skip one. We started from P1 and skip P2 and show on. This way we will have the following bits,


Here the total number of bits is odd. Hence the parity bit as P1 = 1. This means error is there.

Step 2: Check for P2 but while checking for P2, we will use check two and skip two methods. Now start counting from P2, consider P2, D3, D6 and D7.


Here the number of 1’s is event the value of P2 = 0. This means there is no error.

Step 3: Check for P4 but while checking for P4, we will use check four and skip four method, count from P4, D5, D6, D7 and P1 to P2 should not be considered.


Here the number of 1’s is event the value of P4 = 1. This means there is no error.

The above analysis of parity P1 and P4 is not equal to zero, so we can clearly say there is an error in hamming code.

Hamming Code: Error Correction

We revived a hamming code which has error in data. So, must correct them. We use these steps to correct hamming code.
Now the error word E will be:


Now we have to determine the decimal value of 101 is 5.
We get E = 5, it means the error is in the fifth data bit. To correct it by invert the fifth data bit.
So the correct data will be:


Application of hamming code

Hamming code is use in various type of application. Here some applications are given below.

  • Satellites communications
  • Modems
  • Plasma CAM
  • Shielding wire
  • Embedded Processor
  • Computer Memory

Advantages of hamming code

  • It is effective on networks where the data streams are given for the single-bit errors.
  • It is not only provides the detection of a bit error but also helps you to indent bit containing error so that it can be corrected.
  • It is best for use in computer memory and single-error correction.

Disadvantages of hamming code

  • Single-bit error detection and correction code
  • Its algorithm can only correct single bits issues.


  • The data can be corrupted during transfer.
  • Three types of Bit error are Single Bit Errors, Multiple Bit Error and Burst Bit errors
  • The one bit mismatch in the entire data sequence is known as “Single bit error.”
  • In data sequence, if two or more bits of a data sequence are mismatch, are known as “Multiple bit errors.”
  • The mismatch of the set of bits in data sequence is known as “Burst error”.
  • Error detection is a method of detecting the errors which are present in the data transmitted from a transmitter to receiver in a data communication system
  • Three types of error detection codes are Parity Checking, Longitudinal Redundancy Check (LRC) and Cyclic Redundancy Check (CRC).
  • Hamming code is a technique and it is introduce by R.W. Hamming.
  • Hemming code is use in Satellites communication, Computer Memory, Modems, Embedded Processor, etc.
  • Hamming code method can solve only single bits issues.

Also read:- Binary Numbers, Shift register.

Click to comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Most Popular

knowelectronic Website | The Best Blog to Learn Basic Electronics Tutorial for Beginners. Here you can learn Basic Electronics in simple and easy steps - from basic to advanced electronics. All the free online course include – Examples, Video, PDF and Electronics Books Study Materials, Analog Electronics, Digital Electronics, Printed Circuit Board (PCB), Soldering, Electricity, ESD, Electronic Components like Semiconductor, Resistor, Capacitor, Inductor, Transformers, Diodes, Junction, Transistors, JFET, MOSFET, Circuit Diagram etc. This Best and Free Online Basic Electronics Tutorial, Guide, Course is useful for anyone interested in Electrical and Electronics, Engineering Students and Teachers, Electronics Manufacturing Companies. | © | All Rights Reserved
To Top