Shop OBEX P1 Docs P2 Docs Learn Events
gray code decode — Parallax Forums

gray code decode

ArchiverArchiver Posts: 46,084
edited 2003-05-23 01:21 in General Discussion
firstly, thanks to everyone who replied. I looked, nada.

maybe what I should try to do is just have a look up table in eeprom
and feed the stamp with the decoded binary since there is a finite
number of combinations used.

what do you think of this an which stamp would work best in this case.

thanks

jim

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2003-05-23 01:21
    nada? Here is an 8 bit gray code to binary routine:

    gc var byte ' input gray code 8 bits
    gc0 var gc.bit0 ' alias for lsb of gc
    bn var byte ' output binary 8 bits
    bn0 var bn.bit0 ' alias for lsb of bn
    ii var nib ' index for conversion loop

    gc=10110101 ' pick a gray code to enter here
    ' this number is just for a demo
    ' now start the conversion routine here
    bn.bit7=gc.bit7 ' start with most significant bits
    for ii=6 to 0 ' bit by bit XOR
    bn0(ii)=bn0(ii+1)^gc0(ii)
    next
    debug bin8 gc,tab,bin8 bn,cr
    ' the result printed is the gray code
    ' and the corresponding binary code
    end


    -- Tracy


    >firstly, thanks to everyone who replied. I looked, nada.
    >
    >maybe what I should try to do is just have a look up table in eeprom
    >and feed the stamp with the decoded binary since there is a finite
    >number of combinations used.
    >
    >what do you think of this an which stamp would work best in this case.
    >
    >thanks
    >
    >jim
Sign In or Register to comment.