Gray Code

A Brief Intro to Gray Code

Gray Code is not just this website. This website is actually named after the Gray Code system, created by Frank Gray in the 1940’s to represent binary numbers in a sequence of bits, where the current group of bits differs only by one bit from the last. It is sometimes known as Binary Reflected code.


I know, that sounds complex… but it’s really quite simple, lets keep going

Take a look at the table below. ‘State’ indicates the integer value of the ‘Binary’ numbers shown in the 2nd Column, and ‘Gray’ indicates the Gray Code equivalent of the number.
It’s important to note that Gray Code is not weighted as Binary is. Binary numbers are calculated as follows: the least significant bit (LSB) this is the bit furthest to the right is 1 (2^0), the second column is 2 (2^1), the third column would be 4 (2^2) the fourth being 6 (2^3) etc…


Example…

In Binary the number for 1 (001) is the same as (0*4) + (0*2) + (1*1) = 1
In the same manner the Binary number for 5 (101) would be (1*4) + (0*2) + (1*1) = 5


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

Where is it used and why?

Gray Code is often used in angle encoders and Analog to Digital Converters mainly.
The reason it has been adopted for use is because it helps to reduce errors and incorrect codes, when being used in encoders.

How does it reduce these issues?

Unlike Binary, Gray Code will only ever change one bit at a time, in Binary you could change 1 bit and jump from 011 to 111, which would be a change from integer 3 to 7, where as in Gray Code one bit change will translate to one integer change. This simplifies logic operations and reduces errors in practice.

More coming soon!!


Written by Joel Gray

20/03/2020

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x