Error detection and correction codes Objective of the lecture • (i)Undersatnd concept of parity • (ii)Apply parity method of error detection • (iii)Make use of various error detection codes • (iv)Use Hamming code • When digital signals (group of 0’s and 1’s) are transmitted from one circuit or system to another circuit or system,error may occur during transmission. The change of a 1 to 0 or a 0 to 1 during transmission is known as error. It is necessary to detect and correct the error to obtain a correct message. • A number of codes exist for detection and correction of error in digital transmission. • The concept of parity of a group of bits or digital word is the key for error detection and correction. • • Parity method for error detection:-• Many system use a parity bit as a means for bit error detection. • Any group of bits contain either even or an odd no. of 1’s. • A parity bit is attached to a group of bit to make the total no. of 1’s in a group always even or always odd. • An even parity bit makes the total no.of 1’s even, and an odd parity bit makes the total odd. Even parity P BCD 0 0000 1 0001 1 0010 0 0011 1 0100 0 0101 0 0110 1 0111 1 1000 0 1001 Odd P 1 0 0 1 0 1 1 0 0 1 parity BCD 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 • • • • • • The parity bit can be attached to the code at either the beginning or the end,depending on system design. Notice that the total no.of 1’s including the parity bit,is always even for even parity and always odd for odd parity. Detecting an error : A parity bit provides for the detection of a single bit error Let us assume BCD code 0101 (parity can be used with any no.of bits:we are using four for illustration) The total code transmitted including parity bit,is • Let us assume the error occurs in the third • bit from the left • Redundancy bit:To calculate the no. of redundancy bits(r) required to include in data bits(m). • 2r >= m+r+1 • For example for m=1 r= 2 • For m=2 r= 3 • For m=3 r=3 • For m=4 r=3 • For m=5 r=4 Hamming codes • Q-Determine the single error correcting code for the BCD • • • number 1001 using even parity. Sol:- Step-1 Find the no of parity bit required :-that is = 3 Step-2 Construct a bit position table,and enter the information bits.Parity bits are determined in the following steps. Bit P1 Designation P2 MI P3 M2 M3 M4 Bit position 1 2 3 4 5 7 Binary position no 001 010 011 100 101 110 111 0 1 Information bit Parity bit 1 6 0 • • • • Step-3:Determine the parity bit as follows Bit P1 checks bit position 1,3,5 and 7 and put 0 for an even no. of 1s in this group. Bit P2 checks bit position 2,3,6,and 7 and put 0 for even no of 1s in this group Bit P3 checks bit position 4,5,6 and7 and put 1 for even no of 1s in this group Bit Designation P1 P2 MI P3 M2 M3 M4 Bit position 1 2 3 4 5 6 7 Binary position no 001 010 011 100 101 110 111 0 0 1 Information bit Parity bit 1 0 0 1 Q-2 Determine the single error correcting code for the information code 10110 for odd parity. • Sol:---- Step-1 Find the no of parity bit required :-- that is = 5 • Step-2 Construct a bit position table,and enter the information bits.Parity bits are determined in the following steps. Bit Designation P1 P2 MI P3 M2 M3 M4 P4 M5 Bit position 1 2 3 4 5 6 7 8 9 Binary position no 0001 0010 0011 0100 0101 0110 0111 1000 1001 0 1 1 Information bit Parity bit 1 0 • • • • • Step-3:Determine the parity bit as follows Bit P1 checks bit position 1,3,5 ,7and 9 and put 1 for an odd no. of 1s in this group. Bit P2 checks bit position 2,3,6,and 7 and put 0 for odd no of 1s in this group Bit P3 checks bit position 4,5,6 and7 and put 1 for odd no of 1s in this group. Bit P4 checks bit position 8 and 9 and must be 1 for there to be an odd no of 1s in the group Bit Designation P1 P2 MI P3 M2 M3 M4 P4 M5 Bit position 1 2 3 4 5 6 7 8 9 Binary position no 0001 0010 0011 0100 0101 0110 0111 1000 1001 0 1 1 Information bit Parity bit 1 1 0 1 0 1 • Q-3 Assume that the code word in (0011001) is transmitted and 0010001 is received. Receiver does not know what is transmitted and must look for proper parities to determine if the code is correct. Designate any error that has occurred in transmission if even parity is used. Bit Designation P1 P2 MI P3 M2 M3 M4 Bit position 1 2 3 4 5 6 7 Binary position no 001 010 011 100 101 110 111 Received code 0 0 1 0 0 0 1 • • • • • • • • • First parity check P1 for position1,3,5,7 Parity check is good-------------------0(LSB) Second parity check P2 for position2,3,6,7 Parity check is good-------------------0 Third parity check P3 for position4,5,6,7 Parity check is bad-------------------1(MSB) • RESULT: The error position code is 100.This says that bit in position 4 is in error.It is a zero and should be 1.The corrected code is 0011001,which agrees with the transmitted code. • The code 101101010 is received.Correct any errors.There are four parity bits,and odd parity is used. Bit Designation P1 P2 MI P3 M2 M3 M4 P4 M5 Bit position 1 2 3 4 5 6 7 8 9 0 1 0 Information bit Parity bit 1 1 0 1 0 1 • • • • • • • • • • • • • • First parity check P1 for position1,3,5,7 and 9 Parity check is bad-------------------1(LSB) Second parity check P2 for position 2,3,6,7 Parity check is bad-------------------1 Third parity check P3 for position 4,5,6,7 Parity check is bad-------------------1 Fourth parity check: Bit 4 checks positions 8 and 9. Parity check is good-------------------0(MSB) RESULT: The error position code is 0111.This says that the bit in position 7 is in error.The corrected code is therefore 101101110 Bit Designation P1 P2 MI P3 M2 M3 M4 Bit position 1 2 3 4 5 6 7 Binary position no 001 010 011 100 101 110 111 Information bit Parity bit