Balanced 8-bit Gray code

Oct 30, 2007 09:09

I've always been interested in Gray codes. More recently, I became aware of the concept of a "balanced Gray code", i.e. one in which each bit in the code will "toggle" (transition from 0 to 1 or vice-versa) an equal number of times. I once wrote a program to find a 4-bit balanced Gray code almost instantaneously, but searching for an 8-bit version ( Read more... )

Leave a comment

Comments 7

arcanusvitae October 30 2007, 20:47:53 UTC
I have no idea what you are talking about.
But hey, if it's useful, bully for you.

-2trick

Reply


anonymous December 26 2012, 19:39:13 UTC
i know this is a super old post. none the less this is very interesting.

could you go in to detail how you constructed this and how one might construct even n-bit versions.

this would be very useful for storing large counter values in an eeprom.

thanks.

Reply

gary_williams December 27 2012, 01:06:54 UTC
I'm not sure how to extend this encoding beyond 8 bits. Also, a gray encoding of an integer requires just as many bits as the binary encoding of the same value, so you won't be saving any bits by using a gray encoding.

Reply


anonymous December 27 2012, 02:10:33 UTC
thanks for the reply.

i am not so much interested in saving bits more in the balanced toggling of the bits.
i need to count up to 290 000 000 but can only toggle each bit 100 000 times.

do you have a formula for the 8-bit version?

thx.

Reply

gary_williams December 27 2012, 05:19:32 UTC
Ah, that makes sense. You want to minimize the number of writes to each bit, so the least-significant bits don't burn out first. I believe there exist balanced gray codes for 16 and 32 bits, but I have yet to find a generating function or an inverse function. The math is a bit beyond me, I'm afraid. The 8-bit code above came straight from the appendix of the journal article I mentioned.

I would be very interested if you happen to find more information on this topic!

Reply

gary_williams December 27 2012, 05:47:45 UTC
This page has a diagram showing how a larger balanced gray code can be constructed, but it unfortunately doesn't provide any functions like we'd like to have.

http://sciyoshi.com/2010/12/gray-codes/

Reply


anonymous January 3 2013, 23:10:10 UTC
what i learned so far is. finding an easy formula to converts any number in to an n-bit balanced gray code is not easy ( ... )

Reply


Leave a comment

Up