Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to convert GrayCode to decimal?

Status
Not open for further replies.

ZeleC

Full Member level 5
Full Member level 5
Joined
Dec 18, 2002
Messages
261
Helped
3
Reputation
6
Reaction score
1
Trophy points
1,298
Activity points
2,173
GrayCode

Hello
I need a method to convert graycode to decimal
thank you
 

Re: GrayCode

Gray->Decimal conversion consists of two steps:-
1) Gray -> Binary
2) Binary -> Decimal


FIRST convert a Gray-coded number to binary by follow this method :-

The binary number and the Gray-coded number will have the same number of bits

The binary MSB (left-hand bit) and Gray code MSB will always be the same

To get the binary next-to-MSB (i.e. next digit to the right) add the binary MSB and the gray code next-to-MSB.

Record the sum, ignoring any carry.

Continue in this manner right through to the end.

e.g.

Gray Code 10011011 Binary Digit 1 = 1 (same as Gray code)
Gray Code 10011011 Binary Digit 2 = 0 + 1 = 1
Gray Code 10011011 Binary Digit 3 = 0 + 1 = 1
Gray Code 10011011 Binary Digit 4 = 1 + 1 = 0 (carry 1)
Gray Code 10011011 Binary Digit 5 = 1 + 0 = 1
Gray Code 10011011 Binary Digit 6 = 0 + 1 = 1
Gray Code 10011011 Binary Digit 7 = 1 + 1 = 0 (carry 1)
Gray Code 10011011 Binary Digit 8 = 1 + 0 = 1

and so

10011011gray = 11101101bin


Now Convert this binary to Decimal using the method given below!!!

Let ans start at 0 and suppose
the binary number is 11010111. Then compute new values of ans as shown
below: ans * 2 + 1 =>ans
ans * 2 + 1 =>ans
ans * 2 + 0 =>ans
ans * 2 + 1 =>ans
ans * 2 + 0 =>ans
ans * 2 + 1 =>ans
ans * 2 + 1 =>ans
ans * 2 + 1 =>ans

At this point, ans contains the converted number.
 
How is it possible to implement GreyCode using Shift Register? I saw someone implemented it, but I'm not remember how.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top