0% found this document useful (0 votes)
10 views3 pages

Understanding Gray Code Basics

Gray Code is a binary sequence where only one bit changes at each step, minimizing errors in applications like rotating machines and sensors. The document explains the conversion rules between binary and Gray Code, providing examples for clarity. It also includes practice questions for further understanding of the concepts.

Uploaded by

bilalhassan08455
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)
10 views3 pages

Understanding Gray Code Basics

Gray Code is a binary sequence where only one bit changes at each step, minimizing errors in applications like rotating machines and sensors. The document explains the conversion rules between binary and Gray Code, providing examples for clarity. It also includes practice questions for further understanding of the concepts.

Uploaded by

bilalhassan08455
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 – Introduction

Gray Code (also called Reflected Binary Code) is a binary sequence in which only one bit
changes at each step.

✔ Why do we study Gray Code?

• Used in rotating machines, encoders, sensors where small signal noise can change
multiple bits.

• Gray code avoids errors by changing only one bit at a time.

• Important in Digital Logic, K-maps, ADC, and position encoders.

How Gray Code Works

Gray code for 0–7 (3-bit) looks like this:

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: each next value changes only ONE bit.


Binary → Gray Code Conversion Rule

For 4-bit (B3 B2 B1 B0):

• G3 = B3

• G2 = B3 XOR B2

• G1 = B2 XOR B1

• G0 = B1 XOR B0

Example 1: Convert 1011 → Gray

B3 B2 B1 B0 = 1 0 1 1

• G3 = 1

• G2 = 1 XOR 0 = 1

• G1 = 0 XOR 1 = 1

• G0 = 1 XOR 1 = 0

✔ Gray Code = 1110

Example 2: Convert 0101 → Gray

• G3 = 0

• G2 = 0 XOR 1 = 1

• G1 = 1 XOR 0 = 1

• G0 = 0 XOR 1 = 1

✔ Gray Code = 0111


Gray Code → Binary Conversion Rule

(Binary reconstructed from Gray)

• B3 = G3

• B2 = B3 XOR G2

• B1 = B2 XOR G1

• B0 = B1 XOR G0

Example: Convert Gray 1110 → Binary

• B3 = 1

• B2 = 1 XOR 1 = 0

• B1 = 0 XOR 1 = 1

• B0 = 1 XOR 0 = 1

✔ Binary = 1011

Practice Questions

Convert the following Binary → Gray:

1. 1101

2. 0011

3. 1110

4. 1001

5. 0100

Convert the following Gray → Binary:

1. 1011

2. 1100

3. 0110

4. 1000 5.1111

You might also like