Shop OBEX P1 Docs P2 Docs Learn Events
Gray Code — Parallax Forums

Gray Code

ArchiverArchiver Posts: 46,084
edited 2000-09-19 17:19 in General Discussion
Stampers,

Anyone have a listing or details on GRAY CODE?

I know it is a "sort of" binary code where only one bit changes at a
time, but as for the sequence I have no idea!

Tim Stockman

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2000-09-19 01:53
    At 08:23 AM 9/19/2000 +0930, you wrote:
    >Stampers,
    >
    >Anyone have a listing or details on GRAY CODE?
    >
    >I know it is a "sort of" binary code where only one bit changes at a
    >time, but as for the sequence I have no idea!


    Here ya go:

    http://www.opticalencoder.com/copi_abs_enc.html

    Gray code is an expanding binary sequence, where only a one-bit, bit change
    is permitted during the expansion (iterative count). It's cumbersome on one
    hand, but great for absolute encoders on the other. As the text will show,
    a series of OR statements can be used for decoding.

    I believe Tracy may have a "state machine" (which see) on his website for
    decoding Grey code. It pretty much follows the cite above. Check on his
    website at :

    [noparse][[/noparse] http://ourworld.compuserve.com/homepages/emesys/BS2misc.htm ]


    for the Gray code to binary routine.

    Regards,

    Bruce



    >Tim Stockman
  • ArchiverArchiver Posts: 46,084
    edited 2000-09-19 17:19
    The rule for generating Gray code: Start with all zeros. Then, to progress
    to the next higher value, change only the least significant bit which
    brings you to the new state. Horowitz and Hill cover this on page 477 (2nd
    ed.)
    4-bit Gray code is:


    Value Gray code
    MSb LSb

    0 0000
    1 0001
    2 0011
    3 0010
    4 0110
    5 0111
    6 0101
    7 0100
    8 1100
    9 1101
    A 1111
    B 1110
    C 1010
    D 1011
    E 1001
    F 1000
    Steve Roberts: sroberts@s...
Sign In or Register to comment.