Open In App

What is Gray Code?

Last Updated : 19 Sep, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

A binary numbering system in which two successive values only differ by one bit is called gray code, often referred to as reflected binary code or unit distance code. Frank Gray created it in 1953, and today it is a common tool for error detection and repair in digital communication and data storage systems. The Gray code is a sequencing of the binary numeral system in which two successive values differ in an only binary digits.

What is Gray Code?

The binary numeral system is ordered in the reflected binary code, also known as the Gray code, so that two subsequent values only differ in one bit (binary digit). In the typical sequence of binary numbers produced by the hardware that could provide an error or ambiguity during the change from one number to the next, gray codes are highly helpful.

Because the first (n/2) values compare with the last (n/2) values in reverse order, gray code is also known as reflected binary code.

Characteristics and Properties of Gray Code

  1. Single Bit Change: Gray code only allows for one bit to change when changing from one value to another. Because there is less ambiguity when changing values, this feature lessens the possibility of errors and glitches in digital systems.
  2. Reflection Property: A straightforward way for creating the Gray Code sequence entails reflecting the current sequence before prefixing the new sequence with a new bit. For instance, start with a 2-bit Gray Code sequence and reflect it to make a 3-bit Gray Code sequence. The single-bit change property is upheld by the reflection property, which also makes sure the sequence is cyclic.

Types of Gray Codes

  • Binary Reflected Gray Code: The most typical kind of Gray code utilized in digital systems is the binary reflected Gray code, also referred to as the reflected Gray code. Each succeeding number in this code differs from the one before it by a single bit. The binary code for each number is mirrored before being transformed into the Gray code, which is how the code gets its name.
  • Balanced Gray Code: Transition counts has equal in balanced Gray code. it is a unique variety of gray code in which every potential value appears exactly once in the sequence. A good example of where this kind of Gray coding is important in analog-to-digital converters. 
  • N-ary Gray Code: This Gray code consist non-Boolean values like sequences of 1, 2, 3. 
  • Two dimentional Gray code: This kind of Gray code is helpful in error correction.
  • Sequential Gray Code: Every number in the sequence is either the predecessor or the successor of the one before it. Certain applications, including robotics and manufacturing procedures, use this kind of Gray code.

Conversion of Gray Code

Gray code and binary conversion are essential for understanding and resolving issues in digital systems. The most significant bit (MSB) of a binary integer is converted to gray code by taking the XOR of the bit that is now in use and the bit that is immediate to its left in the binary representation.

what-is-gray-code-1_480

n Bit Gray Code

The below table represents the gray code of decimals from 0 to 10.

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

10

1010

1111

How to Generate Gray Code?

Recursively, the prefix and reflect methods are used to create a number’s Gray code. To create gray code:

  • We determine how many bits are necessary to represent a number.
  • The binary equivalent of 0 is found next, which is the code 0000.
  • The most important portion of the preceding code, 0000, will now be changed.
  • Until all of the codes cannot be uniquely identified, we carry out this process in reclusively.
  • If we change the most significant bit and still get the same code as before, we change the second-most significant bit, and so on.

what-is-gray-code-2

Generating Gray Code

Applications of Gray Code

Encoders, decoders, analog-to-digital and digital-to-analog converters, as well as error detection and correction in communication systems, are just a few of the digital systems where Gray Code is used.

FAQs on What is Gray Code?

Q.1: Why gray code is used in K map?

Answer:

In K Map only one variable is changed between each set of two adjacent cells because of gray code.

Q.2: Why is Gray code useful?

Answer:

In the typical sequence of binary numbers produced by the hardware that could provide an error or ambiguity during the change from one number to the next, gray codes are highly helpful. Since only one bit changes its value during any transition between two values, the Gray code can readily solve this problem.

Q.3: What is the disadvantage of Gray code?

Answer:

The main disadvantage of gray code is that it cannot be easily converted from binary code to Gray Code .

Q.4: What is the 3 bit Gray code sequence?

Answer:

The 3 bit sequence for gray code are 000, 001, 011, 010, 110, 111, 101, 100.



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads