What is Gray Code and how do we write them?
Gray Code is a binary sequence with the property that an ordering of 2n binary numbers such that only one bit changes from one entry to the next. Gray codes are useful in mechanical encoders since a slight change in location only affects one bit. Using a typical binary code, up to n bits could change, and slight misalignments between reading elements could cause wildly incorrect readings.
It is a number code where consecutive numbers are represented by binary patterns that differ in one bit position only.
Here you can see , for each number, there is a difference of 1 (addition or elimination of 1)
0000 =0
0001 =1
0011 =2 ,1 is added
0010 =3 , again change of 1, elimination of 1
0110 =4 ,addition of 1
0111 =5 ,again addition of 1
0101 =6 ,elimination of 1
0100 =7 ,elimination of 1
1100 =8 ,addition of 1
1101 =9 ,addition of 1
0001 =1
0011 =2 ,1 is added
0010 =3 , again change of 1, elimination of 1
0110 =4 ,addition of 1
0111 =5 ,again addition of 1
0101 =6 ,elimination of 1
0100 =7 ,elimination of 1
1100 =8 ,addition of 1
1101 =9 ,addition of 1
One way to construct a Gray code for n bits is to take a Gray code for n-1 bits with each code prefixed by 0 (for the first half of the code) and append the n-1 Gray code reversed with each code prefixed by 1 (for the second half). This is called a "binary-reflected Gray code". Here is an example of creating a 3-bit Gray code from a 2-bit Gray code. 00 01 11 10
A Gray code for 2 bits
000 001 011 010 the 2-bit code with "0" prefixes
10 11 01 00 the 2-bit code in reverse order
110 111 101 100 the reversed code with "1" prefixes
000 001 011 010 110 111 101 100 A Gray code for 3 bits
000 001 011 010 the 2-bit code with "0" prefixes
10 11 01 00 the 2-bit code in reverse order
110 111 101 100 the reversed code with "1" prefixes
000 001 011 010 110 111 101 100 A Gray code for 3 bits
0 comments
Post a Comment