0% found this document useful (0 votes)
185 views12 pages

Hamming Code: G. Bindu Madhavi (Ph. D) Assistant Professor Anurag University

This document discusses Hamming codes, which are error detecting and correcting codes. It defines key terms like redundancy bits and Hamming distance. It explains that Hamming codes use parity bits placed at specific positions in the codeword to detect and correct single bit errors. The number of parity bits needed depends on the number of data bits, and the parity bits are placed at bit positions that are powers of 2. An example shows how to encode the data "1101" by calculating the necessary 3 parity bits and inserting them into the codeword to produce "1100110".

Uploaded by

Ujwala Bhoga
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
185 views12 pages

Hamming Code: G. Bindu Madhavi (Ph. D) Assistant Professor Anurag University

This document discusses Hamming codes, which are error detecting and correcting codes. It defines key terms like redundancy bits and Hamming distance. It explains that Hamming codes use parity bits placed at specific positions in the codeword to detect and correct single bit errors. The number of parity bits needed depends on the number of data bits, and the parity bits are placed at bit positions that are powers of 2. An example shows how to encode the data "1101" by calculating the necessary 3 parity bits and inserting them into the codeword to produce "1100110".

Uploaded by

Ujwala Bhoga
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 12

HAMMING CODE

G. Bindu Madhavi(Ph. D)
Assistant Professor
Anurag University
Hamming Code
• This error detecting and correcting code technique is developed by
R.W.Hamming . This code not only identifies the error bit, in the
whole data sequence and it also corrects it. This code uses a
number of parity bits located at certain positions in the codeword.
The number of parity bits depends upon the number of information
bits. The hamming code uses the relation between redundancy bits
and the data bits and this code can be applied to any number of
data bits.
What  is a Redundancy Bit?

• Redundancy means “The difference between number of bits of the


actual data sequence and the transmitted bits”. These redundancy
bits are used in communication system to detect and correct the
errors, if any.
How the Hamming code actually corrects the errors?

• In Hamming code, the redundancy bits are placed at certain


calculated positions in order to eliminate errors. The distance
between the two redundancy bits is called “Hamming distance”.
• To understand the working and the data error correction and
detection mechanism of the hamming code, let’s see to the
following stages.
Number of parity bits
• As we learned earlier, the number of parity bits to be added to a data string depends upon the
number of information bits of the data string which is to be transmitted. Number of parity bits will be
calculated by using the data bits. This relation is given below.
• 2P >= n + P +1
• Here, n represents the number of bits in the data string.
• P represents number of parity bits.
• For example, if we have 4 bit data string, i.e. n = 4, then the number of parity bits to be added can be
found by using trial and error method. Let’s take P = 2, then
• 2P = 22 = 4 and n + P + 1 = 4 + 2 + 1 = 7
• This violates the actual expression.
• So let’s try P = 3, then
• 2P = 23 = 8 and n + P + 1 = 4 + 3 + 1 = 8
• So we can say that 3 parity bits are required to transfer the 4 bit data with single bit error correction
Where to Place these Parity Bits?
• After calculating the number of parity bits required, we should know the appropriate
positions to place them in the information string, to provide single bit error
correction.
• In the above considered example, we have 4 data bits and 3 parity bits. So the
total codeword to be transmitted is of 7 bits (4 + 3). We generally represent the
data sequence from right to left, as shown below.
• bit 7, bit 6, bit 5, bit 4, bit 3, bit 2, bit 1, bit 0
• The parity bits have to be located at the positions of powers of 2. I.e. at 1, 2, 4, 8
and 16 etc. Therefore the codeword after including the parity bits will be like this
• D7, D6, D5, P4, D3, P2, P1
• Here P1, P2 and P3 are parity bits. D1 —- D7 are data bits.
• In Hamming code, each parity bit checks and helps in finding the errors in
the whole code word. So we must find the value of the parity bits to assign
them a bit value.

• By calculating and inserting the parity bits in to the data bits, we can achieve
error correction through Hamming code.
• Let’s understand this clearly, by looking into an example.
Example:
Encode the data 1101 in even parity, by using Hamming code.

Step 1
• Calculate the required number of parity bits.
• Let P = 2, then
2P = 22 = 4 and n + P + 1 = 4 + 2 + 1 = 7.
• 2 parity bits are not sufficient for 4 bit data.
• So let’s try P = 3, then
• 2P = 23 = 8 and n + P + 1 = 4 + 3 + 1 = 8
• Therefore 3 parity bits are sufficient for 4 bit data.
•  The total bits in the code word are 4 + 3 = 7
Encode the data 1101 in even parity, by using
Hamming code….

Step 2:Constructing bit location table

               
Encode the data 1101 in even parity, by using
Hamming code.

Step 3
• Determine the parity bits.
• For P1 : 3, 5 and 7 bits are having three 1’s so for even parity, P1 = 1.
• For P2 : 3, 6 and 7 bits are having two 1’s so for even parity, P2 = 0.
For P3 : 5, 6 and 7 bits are having two 1’s so for even parity, P3 = 0.
• By entering / inserting the parity bits at their respective positions, codeword can be
formed and is transmitted. It is 1100101.
• NOTE: If the codeword has all zeros (ex: 0000000), then there is no error in
Hamming code.
ASSIGNMENT
• Encode the data 1010 in odd parity, by using Hamming code.
THANK YOU

You might also like