Explanation of BCD code, Excess-3 code, and gray code

Hi,
Friends as I said in the previous post I'll explain about BCD code, Excess-3 code, and gray code and now I'm going to discuss them.


BCD code

Here you will see the BCD Code for each single-digit

Decimal
BCD Code
Digit
8
4
2
1
0
0
0
0
0
1
0
0
0
1
2
0
0
1
0
3
0
0
1
1
4
0
1
0
0
5
0
1
0
1
6
0
1
1
0
7
0
1
1
1
8
1
0
0
0
9
1
0
0
1



For example, let us take a number:- 28
split the number as '2' and '8' and for number 2 what is the BCD code from the table it is 0010 and for number 8 is 1000.
and finally, the BCD Code for 28 is 0010 1000.
This is how the BCD Code is encoded when you were given a decimal number.


Excess-3 code


Now let us know about Excess-3 code

It is an unweighted binary code.
Excess-3 code is modified or upgraded from the BCD number. It's a natural BCD Code by adding '3' to each coded number.

Decimal No.
8421 BCD Code
Excess-3 code
0
0000
0011
1
0001
0100
2
0010
0101
3
0011
0110
4
0100
0111
5
0101
1000
6
0110
1001
7
0111
1010
8
1000
1011
9
1001
1100
So, let us take the above example 28
The BCD code for 28 is 0010 1000. To know the excess-3 code add '3' to each decimal digit i.e. 2+3=5  ------>  0101 and
8+3=11 ------> 1011
Hence this is known as Excess-3 code.


Gray code

The Gray code was designed by Frank Gray at Bell labs. It is also an unweighted binary code in which two successive values differs only by a single bit is known as 'Gray code'.

Decimal
Binary
Gray
Decimal
Binary
Gray
0
0000
0000
8
1000
1100
1
0001
0001
9
1001
1101
2
0010
0011
10
1010
1111
3
0011
0010
11
1011
1110
4
0100
0110
12
1100
1010
5
0101
0111
13
1101
1011
6
0110
0101
14
1110
1001
7
0111
1000
15
1111
1000
To convert the binary number into the gray code, follow the below process
  1. Write the MSB bit of the binary as it is.  (I'll tell about MSB and LSB below)
  2. Add the MSB to the next lower significant bit of the binary number and note down the sum ignore the carry bit if you get any.
  3. Next, add the next lower significant of MSB to next bit i.e., add the next adjacent pair.
  4. Continue the same process till all the binary digits are added.  
For Example
Binary number          1          0          0          1
                                       ⤻         ⤻         ⤻   
                                 ↓       (1+0)    (0+0)    (0+1)
                                              ↓           ↓          ↓
 Gray code is            1          1          0          1

To convert the gray code into a binary number, follow the below process



  1. Write down the MSB as it is.
  2. Add the MSB bit of the binary to the next lower significant bit of the gray code and consider the sum bit for the next lower significant bit of the binary number after ignoring the carry bit if any.
  3. Add this sum to the next lower significant bit of the gray code and continue the process till the LSB is reached.
Here the Terms MSB - Most Significant Bit 
For a binary number let us take 1 0 1 0 here the first bit i.e. 1 is MSB. 

LSB - Least Significant Bit
And from the above example, 0 is the LSB.

Comments

Popular Posts