0% found this document useful (0 votes)
0 views

Different Types of Code Lecture-09

The document discusses Gray Code and Error Detecting Codes in digital electronics. Gray Code is a binary system where successive numbers differ by only one bit, aiding in error correction during data transmission. Error detecting codes, such as parity checks, are used to identify errors in transmitted data, ensuring reliable communication over networks.

Uploaded by

mohitburnwal2
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)
0 views

Different Types of Code Lecture-09

The document discusses Gray Code and Error Detecting Codes in digital electronics. Gray Code is a binary system where successive numbers differ by only one bit, aiding in error correction during data transmission. Error detecting codes, such as parity checks, are used to identify errors in transmitted data, ensuring reliable communication over networks.

Uploaded by

mohitburnwal2
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/ 20

Paper Name: Digital Electronics

Paper Code: BCAC-102

Lecture#09
Gray Code n Error Detecting Code

Dr. Dibyendu Kumar Pal ,


M.Sc.(Applied Maths), MCA, Ph.D.
HOD & Assistant Professor
Department of Computer Application
Asansol Engineering College, West Bengal, India.
Lecture Outline

Different Types of Codes

• Weighted Binary Codes (Lecture#08)


• Non weighted codes (Lec#08), Gray Code(Lec#09)
• Error detecting codes (Lecture#09)
• Error correcting codes (Lecture#10)
• Alphanumeric codes (Lecture#10)
Gray Code:

Gray Code system is a binary number system in which every


successive pair of numbers differs in only one bit. ... The Gray
code eliminates this problem since only one bit changes its
value during any transition between two numbers.

Gray codes are widely used to prevent spurious output from


electromechanical switches and to facilitate error correction in
digital communications such as digital terrestrial television and
some cable TV systems.
Conversion of a binary number to Gray Code
A binary number can be converted to its Gray code when

 The first bit(MSB) of the Gray code is the same as the first
bit of the binary number
 The second bit of the Gray code equals the exclusive- OR, of
the first and second bits of the binary number,i.e it will be 1
if these binary code bits are different and 0 if they are the
same
 The third Gray code bit equals the exclusive- OR of the
second and third bits of the binary number, and so on
Binary to Gray code conversion
Binary to Gray code conversion

The final Gray code value of binary number 1101 is 1011


Decimal Binary Code Gray Code
0 0000 0000
1 0001 0001
2 0010 0011
3 0011 0010
4 0100 0110
5 0101 0111
6 0110 0101
7 0111 0100
8 1000 1100
9 1001 1101
Decimal Binary Code Gray Code
10 1010 1111
11 1011 1110
12 1100 1010
13 1101 1011
14 1110 1001
15 1111 1000
Conversion from Gray code to binary

Conversion of a Gray code into its binary form involves the


reverse of the procedure given above.

 The first binary bit (MSB) is the same as that of the first
Gray code bit.
 If the second Gray bit is 0,the second binary bit is the same
as that of the first binary; if the second Gray bit is 1, the
second binary is the inverse of its first binary bit.
 Step 2 is repeated for each successive bit.
Gray to Binary code conversion
Gray to Binary code conversion

=
Error Detecting Codes
Error-detecting codes are a sequence of numbers
generated by specific procedures for detecting errors in
data that has been transmitted over computer networks.
When bits are transmitted over the computer network,
they are subject to get corrupted due to interference and
network problems. The corrupted bits leads to spurious
data being received by the receiver and are called
errors.
Error – detecting codes ensures messages to be
encoded before they are sent over noisy
channels. The encoding is done in a manner so
that the decoder at the receiving end can detect
whether there are errors in the incoming signal
with high probability of success.
Features of Error Detecting Codes
Error detecting codes are adopted when backward error
correction techniques are used for reliable data transmission. In
this method, the receiver sends a feedback message to the sender
to inform whether an error-free message has been received or not.
If there are errors, then the sender retransmits the message.
Error-detecting codes are usually block codes, where the message
is divided into fixed-sized blocks of bits, to which redundant bits
are added for error detection.
Error detection involves checking whether any error has occurred
or not. The number of error bits and the type of error does not
matter.
Error Detection Techniques

There are three main techniques for detecting errors


Parity Check
Parity check is done by adding an extra bit, called parity bit to the data to
make number of 1s either even in case of even parity, or odd in case of odd
parity. While creating a frame, the sender counts the number of 1s in it and
adds the parity bit in following way
In case of even parity: If number of 1s is even then parity bit value is 0. If
number of 1s is odd then parity bit value is 1.
In case of odd parity: If number of 1s is odd then parity bit value is 0. If
number of 1s is even then parity bit value is 1.
On receiving a frame, the receiver counts the number of 1s in it. In case of
even parity check, if the count of 1s is even, the frame is accepted,
otherwise it is rejected. Similar rule is adopted for odd parity check.
Parity check is suitable for single bit error detection only.
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.
The following table shows the even parity codes corresponding to each 3-bit binary
code. 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.
•If the other system receives one of these even parity codes, then there is no
error in the received data. The bits other than even parity bit are same as
that of binary code.
•If the other system receives other than even parity codes, then there will be
an errors in the received data. In this case, we can’t predict the original
binary code because we don’t know the bit positions of error.
Therefore, even parity bit is useful only for detection of error in the
received parity code. But, it is not sufficient to correct the error.
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.
The following table shows the odd parity codes corresponding to each 3-bit binary code.
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.
•If the other system receives one of these odd parity codes, then
there is no error in the received data. The bits other than odd parity
bit are same as that of binary code.
•If the other system receives other than odd parity codes, then there
is an errors in the received data. In this case, we can’t predict the
original binary code because we don’t know the bit positions of
error.
Therefore, odd parity bit is useful only for detection of error in the
received parity code. But, it is not sufficient to correct the error.

You might also like