Jump to content

Talk:Gray code/Archive 1

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Cburnett (talk | contribs) at 18:51, 20 April 2005 (Archive creation). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

The following was at Gray_coding, and is moved here in case anyone wants to add some of it to the Gray_code article.


A gray code is a special coding system designed to prevent spurious output from practical electromechanical switches and is specifically relevant to encoding of position information for a rotating object. For example, if we create a device that indicates position by closing and opening switches, we could use the binary code to represent position:

Binary Code
Input position Output 3 Output 2 Output 1
0 0 0 0
1 0 0 1
2 0 1 0
3 0 1 1
4 1 0 0
5 1 0 1
6 1 1 0
7 1 1 1

The problem is that, with real (mechanical) switches, it is very unlikely that two switches will change states exactly in synchrony. For example, in the transistion from state 3 to state 4, all three switches change state. In the brief period while all are changing, the switches will read some spurious position.

A gray code solves this problem by changing only one switch at a time, so there is never any ambiguity of position:

Gray Code
Input position Output 3 Output 2 Output 1
0 0 0 0
1 0 0 1
2 0 1 1
3 0 1 0
4 1 1 0
5 1 1 1
6 1 0 1
7 1 0 0

Notice also that state seven can roll over to state zero with only one switch change.


I liked the less-technical introduction, so I copied it to the article.

I wish this article had a photo of an "encoder disk".

-- DavidCary 14:13, 12 Jun 2004 (UTC)

updates

Hi all, my first contribution to Wikipedia, hopefully it will go over well. I changed the example from a 4-bit BRGC to a 3-bit BRGC because it's a little bit simpler at first glance. I also added a lot of info about special types of Gray codes. Since this came from a paper I wrote, I added many of the references at the bottom that I used for the paper. I have some trivial C++ code to recursively generate an n-bit BRGC but I don't know if that would really be appropriate to attach to this. Thoughts? Rob 05:16, 6 Sep 2004 (UTC)