In this article we will cover Grey Code, binary to grey code conversion and Grey code to binary conversion. Its application, advantages and disadvantages.
Grey Code is named after scientist Frank Grey.
What is a Grey Code ?
A grey code is a binary number system that is ordered in a way that every increasing value gets differed by only one bit. A Grey code is also known as Reflected Binary Code ( RBC ) or cyclic code.
In other words we can say that grey codes differ by only one bit from their upper or lower number.
Although grey codes are the most popular unit distance codes, still it is not suitable in arithmetic operations. Usually grey code is used in error detection of digital communication and analogue to digital converters. Initially students find grey code difficult to understand but it is really easy.
Binary to Grey Code Converter
A digital logical circuit that converts BCD to grey code is known as Binary to grey code converter. Binary ( BCD ) is converted to grey code using XOR gate.
Truth table for XOR gate
A  B  Y 
0  0  0 
0  1  1 
1  0  1 
1  1  0 
When inputs are similar, output is zero and when inputs are different output is logic 1.
Binary to Grey Code Converter Circuit
The table below shows 3 bit BCD numbers and their grey code, side by side.
D 
Binary 
Grey code 


B_{2} 
B_{1} 
B_{0} 
G_{2} 
G_{1} 
G_{0} 
0 
0 
0 
0 
0 
0 
0 
1 
0 
0 
1 
0 
0 
1 
2 
0 
1 
0 
0 
1 
1 
3 
0 
1 
1 
0 
1 
0 
4 
1 
0 
0 
1 
1 
0 
5 
1 
0 
1 
1 
1 
1 
6 
1 
1 
0 
1 
0 
1 
7 
1 
1 
1 
1 
0 
0 
Steps to Convert Binary to Grey Code
Binary to grey code conversion is done by following steps
 Copy the row B_{2 }in row G_{2}. Row B_{2 }and G_{2 }will be similar.
 Now, G_{1 }is obtained by B_{2 }⨁ B_{1}. When B_{2} and B_{1} will be same, the output will be zero and B_{2} and B_{1} are different the output is 1.
 G_{0 }is obtained by B_{1 }⨁ B_{0}. When B_{1} and B_{0} are similar, the output will be zero and B_{1} and B_{0} are different the output is 1.
Example 1
Suppose we need to convert BCD 1001 to Grey Code.
 The most significant bit ( MSB ) is 1. So the first digit will be reflected as it is.
 First and second bit is 1 & 0 then 1 ⨁ 0 will be 1, since it has two different inputs.
 Secondly, second and third bits are 0 & 0. So 0 ⨁ 0 will be 0 because it has same inputs.
 At last, third bit and fourth bit are 0 & 1. So 0 ⨁ 1 will give output 1.
 Finally, The Grey Code will be 1101 for BCD 1001.
Example 2
Q. Convert BCD 0110 to Grey Code
 Again the first digit 0 will be reflected as it is.
 Now the first and second bit is 0 & 1 so 0 ⨁ 1 is 1. Different inputs give output 1.
 In the third step, the second and third input bits are 1 & 1 so 1 ⨁ 1 is 0. Similar inputs give output 0.
 At last, the third and fourth input bits are 1 & 0 so 1 ⨁ 0 will be 1.
 Finally the Grey code for 0110 is 0101.
Example 3
Q. Convert decimal 15 into grey code.
Steps to convert decimal to grey code is –
 First of all convert decimal to BCD.
 BCD for decimal 15 is 1111.
 First digit 1 will be reflected as it is.
 Now first and second bit is 1 & 1. So 1 ⨁ 1 is 0.
 Second and third bit is also 1 & 1. So 1 ⨁ 1 is again 0.
 The third and fourth bits are again 1 & 1. So 1 ⨁ 1 is again 0.
 Finally, the Grey code for decimal 15 ( 1111 ) is 1000.
Grey Code to Binary Conversion
We have successfully converted BCD to Grey Code. Now lets convert Grey Code back to BCD.
A digital logical circuit that converts Grey code to Binary is known as Grey code to binary converter. Grey code is also converted to binary using XOR gate.
Grey Code to Binary Converter Circuit
The table below shows 3 bit grey code and their Binary number, side by side.
D 
Grey Code 
Binary 


G_{2} 
G_{1} 
G_{0} 
B_{2} 
B_{1} 
B_{0} 
0 
0 
0 
0 
0 
0 
0 
1 
0 
0 
1 
0 
0 
1 
2 
0 
1 
1 
0 
1 
0 
3 
0 
1 
0 
0 
1 
1 
4 
1 
1 
0 
1 
0 
0 
5 
1 
1 
1 
1 
0 
1 
6 
1 
0 
1 
1 
1 
0 
7 
1 
0 
0 
1 
1 
1 
Here, D denotes Decimal number. G_{2}, G_{1 }& G_{0} are Grey codes and B_{2}, B_{1 }& B_{0} are Binary Coded Decimal.
Steps to Convert Grey Code to Binary
Grey code is converted into binary in the same way as binary was converted into grey. Only the last step is different.
 G_{2} gets reflected into B_{2} as it is.
 B_{1} is obtained by G_{2} ⨁ G_{1}.
 Now, B_{0} is obtained by G_{2} ⨁ G_{1} ⨁ G_{0}. Only this step is different.
Example
Q. Convert Grey code ( 111 ) to binary.
 The first bit 1 will be reflected as it is.
 B_{1} will be obtained by XOR of first and second bit ( G_{2} ⨁ G_{1} ). So 1 ⨁ 1 = 0 because similar input gives 0 in output.
 Now, B_{0} will be obtained by G_{2} ⨁ G_{1} ⨁ G_{0}. We know from previous step G_{2} ⨁ G_{1} is 0. So now 0 ⨁ G_{0} = 0 ⨁ 1 = 1.
 Finally, binary for Grey code ( 111 ) is 101.
Application of Grey Code
Some applications of Grey Code are –
 Error detection / correction in digital communication.
 Analog to Digital converters.
 Minimize error during analog to digital conversion.
 Puzzles of mathematics.
 Position encoders.
 Circuit minimization of Boolean algebra.
Advantages of Grey Code
The advantages are –
 Best for minimizing errors during analogue to digital conversion.
 Used in clock domain crossing.
 Minimizing a logic circuit.
Disadvantages of Grey Code
The disadvantages are –
 Less practical use other than few common applications.
 Not applicable in arithmetic operations.
Frequently Asked Questions
 Why is Grey code known as reflected code ?
 The reason why Grey Code is also called reflected code is shown in table below. Similar colours represent reflection.
Grey code 

G2 
G1 
G0 
X 
0 
0 
X 
0 
1 
X 
1 
1 
X 
1 
0 
Mirror 

X 
1 
0 
X 
1 
1 
X 
0 
1 
X 
0 
0 
The table shows Grey code for 3 bit BCD ( that was explained above in the article ).
Author
Akash Sharma
In this article we are going to discuss about BCD to access 3 code conversion. Before we start, make sure you have a clear concept of number system and decimal to binary conversion.
NAND NAND realization is a concept under which we draw a logic circuit by using only NAND gates.
Nicely explained all the basis concepts about Grey Code and it’s conversion.
Was able to understand everything and all my doubts are clear .Thank you sir for making this blog😊😊
Thank You.