0% found this document useful (0 votes)
9 views2 pages

Gray Code

Gray code is a binary numbering system where two successive values differ by only one bit, reducing transition errors in digital systems. It is used in applications like rotary encoders and ADCs, and can be converted from binary using a specific XOR rule. Key features include its unit-distance property and its unsuitability for direct arithmetic operations.

Uploaded by

hafizurh549
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views2 pages

Gray Code

Gray code is a binary numbering system where two successive values differ by only one bit, reducing transition errors in digital systems. It is used in applications like rotary encoders and ADCs, and can be converted from binary using a specific XOR rule. Key features include its unit-distance property and its unsuitability for direct arithmetic operations.

Uploaded by

hafizurh549
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Gray code (also called Reflected Binary Code) is a special type of binary numbering system

where two successive values differ in only one bit.

Why Gray Code is Used

In normal binary counting, multiple bits can change at the same time.
Example:
0111 (7) → 1000 (8) → 4 bits change

This can cause errors in digital systems (like counters, encoders, ADCs).

Gray code avoids this by ensuring only one-bit changes at a time, reducing transition errors.

Example: 3-bit Binary vs Gray Code

Decimal Binary Gray Code


0 000 000
1 001 001
2 010 011
3 011 010
4 100 110
5 101 111
6 110 101
7 111 100

✔ Notice: Only one-bit changes between consecutive Gray codes

How to Convert Binary → Gray Code

Rule:

 MSB (most significant bit) stays the same


 Each next Gray bit = XOR of current binary bit and previous binary bit

Formula:

G = B ⊕ (B >> 1)

Example:
Binary = 1011

Bit Operation Gray


MSB same 1
Bit Operation Gray
2nd 1⊕0 1
3rd 0⊕1 1
4th 1⊕1 0

Gray = 1110

How to Convert Gray → Binary

Rule:

 MSB stays same


 Each next binary bit = XOR of previous binary bit and current Gray bit

Applications of Gray Code

 Rotary/shaft encoders
 Analog to Digital Converters (ADC)
 Karnaugh maps (K-map)
 Digital counters
 Error-resistant data transmission

Key Points

 Gray code is a unit-distance code


 Only 1-bit changes between adjacent numbers
 Reduces glitches and transition errors
 Not suitable for arithmetic operations directly

You might also like