On Sat, 21 Dec 1996, Louis A. Mamakos wrote: > > Hmm... I've looked at your web page and I must say that encoder sure does > > have a wierd coding sequence, doesn't it.... :-) Methinks I'll have to > > brainparse that one a little bit... Just take a walk on the wild sides of the 8-cube. No need to see all of the sides, just turn once on every corner. Voila, the turning of the shaft is in a roundtrip of the cube. No, I am not on drugs and yes, I have had a good night's sleep. The hallucinatory stuff is also known as mathematics. A Gray code can be found by tracing a Hamiltonian cycles on the graph of the n-cube. For you folks exclamating "now he's doing it again!": an n-cube is the n-dimensional brother of 2-d square and 3-d cube, a graph is a network consisting of points and lines (just like a schematic, but without the parts), and a Hamiltonian cycle is a path over the lines of a graph, traversing every point exactly once. Not every graph has such a cycle, but every n-cube graph does. In practice, you label all the points of an n-cube graph with their respective "coordinates", like in: 100 101 *-------------* |\ /| | \110 111/ | | *-------* | | | | | | | | | | | | | | *-------* | | /010 011\ | |/ \| *-------------* 000 001 Now, if you go point to point, only one coordinate changes at a time, making for very unambiguous state transitions, as opposed to a straight binary scheme. A Hamiltonian cycle would be: 000 -> 100 -> 110 -> 010 -> 011 -> 111 -> 101 -> 001 (-> 000 ) Note that this method is very easyly extended to higher values of n (if you can't figure it, notice how this one is already an extension of n=2.) > There's a simple algorithm using XOR operations which can be used to > translate between gray code and "normal" binary encoded values. Actually, > it's a pretty simple circuit as well using XOR gates. I'd refer you to > "The Art of Electronics" by Horowitz and Hill. ISBN 0-521-23151-5, but > I know there's a new edition subsequent to this one. Well, why not post the algorithm, it's an interesting thing to put in a pic. BTW, I got mine from "Graphs, an introductory approach" by Wilson and Watkins, ISBN 0-471-51340-7. For all you engineers thinking math is only integration and differential equations, this is a definite gem. If you hate math, get a copy of "Alice in wonderland". Also makes a great Christmas gift to newborns :-) Joost