Tuesday, August 11, 2009

GRAY CODE(BINARY CODES FROM DIGITAL ELECTRONICS)

This is a variable weighted code and is cyclic. This means that it is arranged so that every transition from one value to the next value involves only one bit change. The gray code is sometimes referred to as reflected binary, because the first eight values compare with those of the last 8 values, but in reverse order.

DecimalBinaryGray
000000000
100010001
200100011
300110010
401000110
501010111
601100101
701110100
810001100
910011101
1010101111
1110111110
1211001010
1311011011
1411101001
1511111000

The gray code is often used in mechanical applications such as shaft encoders.
Modulo 2 Arithmetic
This is binary addition with the carry ignored.
Converting Gray Code to Binary
A. write down the number in gray code
B. the most significant bit of the binary number is the most significant bit of the gray code
C. add (using modulo 2) the next significant bit of the binary number to the next significant bit of the gray coded number to obtain the next binary bit
D. repeat step C till all bits of the gray coded number have been added modulo 2
the resultant number is the binary equivalent of the gray number

Example, convert 1101101 in gray code to binary

Gray Binary
1. 1101101
2. 1101101 1 copy down the msb
3. 1101101 10 1 modulo2 1 = 0
4. 1101101 100 0 modulo2 0 = 0
3/4 1101101 1001 0 modulo2 1 = 1
3/4 1101101 10010 1 modulo2 1 = 0
3/4 1101101 100100 0 modulo2 0 = 0
3/4 1101101 1001001 0 modulo2 1 = 1

the answer is 1001001

Converting Binary to Gray
A. write down the number in binary code
B. the most significant bit of the gray number is the most significant bit of the binary code
C. add (using modulo 2) the next significant bit of the binary number to the next significant bit of the binary number to obtain the next gray coded bit
D. repeat step C till all bits of the binary coded number have been added modulo 2
the resultant number is the gray coded equivalent of the binary number

Example, convert 1001001 in binary code to gray code

Binary Gray
1. 1001001
2. 1001001 1 copy down the msb
3. 1001001 11 1 modulo2 0 = 1
4. 1001001 110 0 modulo2 0 = 0
3/4 1001001 1101 0 modulo2 1 = 1
3/4 1001001 11011 1 modulo2 0 = 1
3/4 1001001 110110 0 modulo2 0 = 0
3/4 1001001 1101101 0 modulo2 1 = 1

The answer is 1101101

Excess 3 Gray Code
In many applications, it is desirable to have a code that is BCD as well as unit distance. A unit distance code derives its name from the fact that there is only one bit change between two consecutive numbers. The excess 3 gray code is such a code, the values for zero and nine differ in only 1 bit, and so do all values for successive numbers.
Outputs from linear devices or angular encoders may be coded in excess 3 gray code to obtain multi-digit BCD numbers.

Decimal Excess 3 Gray
0 0010
1 0110
2 0111
3 0101
4 0100
5 1100
6 1101
7 1111
8 1110
9 1010

No comments:

Post a Comment

LinkShare_468x60v2


I am a Seeking a Ages to
Country
Click to FriendSearch.com; Top Singles, Dating and Love Personals
 
http://www.pankaj-nitb.blogspot.com Submit Sitemap Directory 2009 Quality directory Free Link Exchange

Free Links from links room .com Sign up for FREE and start trading links today