You are on page 1of 5

WHAT IS ERROR IN ERROR DETECTION CODE?

In the context of error detection codes, an "error" refers to an alteration or corruption of data
during transmission or storage. These errors can occur for various reasons, including
electromagnetic interference, signal attenuation, electrical noise, or physical defects in storage
media. The primary purpose of error detection codes is to identify the presence of these errors so
that corrective action can be taken, if necessary.

When data is transmitted or stored digitally, it is represented as a sequence of bits (0s and 1s). An
error in this context typically means that one or more bits in the data have been changed or
flipped due to some external influence. These bit-flips can result in the misinterpretation of the
data and potentially lead to incorrect information being received or read.

Error detection codes work by adding redundancy to the data being transmitted or stored. This
redundancy allows the receiver or reader to perform certain calculations or checks on the
received data. If the received data is free from errors, these calculations will produce the
expected results. However, if errors have occurred, the calculations will indicate a mismatch,
signaling that an error is present.

Common error detection techniques, such as parity bits, checksums, and CRC (Cyclic
Redundancy Check), are designed to identify the presence of errors but do not correct the errors
themselves. Instead, they provide a way for the recipient to request the retransmission of data or
take other appropriate actions to mitigate the impact of errors.

In summary, errors in error detection codes refer to unintended changes or corruptions in digital
data during transmission or storage, and error detection codes are mechanisms to detect these
errors and trigger error-handling processes.

ERROR CORRECTION

Error correction goes beyond error detection by not only identifying errors but also correcting
them. Error correction codes add additional redundant bits to the data, allowing the receiver to
not only detect errors but also reconstruct the original data when errors are detected. Common
error correction codes include Hamming codes, Reed-Solomon codes, Turbo codes, and LDPC
codes.

Hamming Code: Hamming codes are capable of correcting single-bit errors and detecting
double-bit errors. They add redundant bits to the data to create a code that allows for error
correction.

Reed-Solomon Code: Reed-Solomon codes are widely used for error correction in data storage
and transmission, such as CDs and DVDs. They can correct multiple errors and detect many
more errors than they can correct.
Turbo Codes and LDPC (Low-Density Parity-Check) Codes: These are advanced error
correction codes used in high-speed communication systems. They provide excellent error
correction capabilities, making them suitable for 4G and 5G wireless communication.

Parity Code

It is easy to include append one parity bit either to the left of MSB or to the right of LSB of
original bit stream. There are two types of parity codes, namely even parity code and odd parity
code based on the type of parity being chosen.

Even Parity Code

The value of even parity bit should be zero, if even number of ones present in the binary code.
Otherwise, it should be one. So that, even number of ones present in even parity code. Even
parity code contains the data bits and even parity bit. Here, the even parity bit is included to the
right of LSB of binary code.

Binary Code Even Parity bit Even Parity Code


000 0 0000
001 1 0011
010 1 0101
011 0 0110
100 1 1001
101 0 1010
110 0 1100
111 1 1111
Here, the number of bits present in the even parity codes is 4. So, the possible even number of
ones in these even parity codes are 0, 2 & 4.
Odd Parity Code

The value of odd parity bit should be zero, if odd number of ones present in the binary code.
Otherwise, it should be one. So that, odd number of ones present in odd parity code. Odd parity
code contains the data bits and odd parity bit. Here, the odd parity bit is included to the right of
LSB of binary code.

Binary Code Odd Parity bit Odd Parity Code


000 1 0001
001 0 0010
010 0 0100
011 1 0111
100 0 1000
101 1 1011
110 1 1101
111 0 1110
Here, the number of bits present in the odd parity codes is 4. So, the possible odd number of ones
in these odd parity codes are 1 & 3.
HAMMING CODES

Hamming codes are a type of error-correcting code used to correct single-bit errors in data
transmission. They add redundancy to the original data by including parity bits in specific
positions. Here's a step-by-step example of how to encode and decode a Hamming code.

Encoding (Adding Parity Bits):

Let's say we have a 4-bit data word that we want to encode using a Hamming code. Our original
data is 1010. We'll add three parity bits to create the encoded word.

1. Determine the number of parity bits needed:

For an n-bit data word, we need to add r parity bits to make a total of n + r bits,
where 2^r >= n + r + 1.
In this case, we have 4 data bits (n), and we need to find r:
2^r >= 4 + r + 1
The smallest value of r that satisfies this inequality is 3.

2. Insert placeholders for the parity bits:

3. Step 1 − First write the bit positions starting from 1 in a binary form (1, 10, 11,100, etc.)
4. Step 2 − Mark all the bit positions that are powers of two as parity bits (1, 2, 4, 8, 16, 32, 64, etc.)
5. Step 3 − All other bit positions are for the data to be encoded using (3, 5, 6, 7, 9, 10 and 11, etc.)

Placeholders for the parity bits are at positions 1, 2, and 4 (positions are 1-based).
Original Data: _ _ 1 _ 0 1 0
Parity Bits: P1 P2 D1 P4 D2 D3 D4

6. The position of the parity determines the sequence of bits that it alternatively checks and
skips.

 Position 1 − Check 1 bit, then skip 1 bit, check 1 bit and then skip 1 bit and so on (Ex −
1,3,5,7,11, etc.)
 Position 2 − Check 2 bit, then skip 2 bit, check 2 bit, then skip 2 bit (Ex −
2,3,6,7,10,11,14,15, etc.)
 Position 4 − Check 4 bit, then skip 4 bit, check 4 bit, then skip 4 bit (Ex − 4, 5, 6, 7, 12,
13, 14, 15, etc.)
 Position 8 − Check 8 bit, then skip 8 bit, check 8 bit, then skip 8 bit (Ex − 8, 9, 10, 11,
12, 13, 14, 15, 24, 25, 26, 27, 28, 29, 30, 31).
7. Calculate the values of the parity bits:

P1 = D3 XOR D5 XOR D7 = 1 0 0 = 1

P2 = D3 XOR D6 XOR D7 = 1 1 0 = 0

P4 = D5 XOR D6 XOR D7 = 0 1 0 = 1

8. Insert the calculated parity bits into the encoded word:


Encoded Data: P1 P2 1 P4 0 1 0
1 0 11 010

Decoding (Correcting Errors):


1. Our original data is 1010.
2. After hamming code encoded word or data is :
Encoded Data: P1 P2 1 P4 0 1 0
1 0 11 010
3. After Change Bit:
Encoded Data: P1 P2 1 P4 0 1 0
1 0 1 1 0 0 0

4. Calculate the values of the parity bits:

P1 XOR D3 XOR D5 XOR D7 = 1 1 0 0 = 0 (Not Error)

P2 XOR D3 XOR D6 XOR D7 = 0 1 0 0 = 1 (Error)

P4 XOR D5 XOR D6 XOR D7 = 1 0 0 0 = 1 (Error)

5. Determine the position of the Error:


 Follow this sequence: P4 P2 P1
 Put values of P4, P2 and P1
 Then P4 P2 P1  1 1 0
 1 1 0 is Equivelent to Decimal No. 6 (6 is error position)

Because Error bit is present in No. 6 Means D3,D3 present in No. 6 in parity Bits.

1 2 3 4 5 6 7
Parity Bits: P1 P2 D1 P4 D2 D3 D4
1 0 1 1 0 0 0

6. Now we change D3 value (Flip the bit at the error position).

01
1 2 3 4 5 6 7
Parity Bits: P1 P2 D1 P4 D2 D3 D4
1 0 1 1 0 1 0
7. Now Encode and Decode data is same. So from decode data we extract our original
data that is 1010.

This is a simplified example of Hamming code encoding and decoding. In practice, Hamming
codes are often used with larger data words and more parity bits for better error detection and
correction capabilities.

You might also like