Strange binary sequence

Discussion in 'Programmer's Corner' started by Markd77, Oct 8, 2010.

  1. Markd77

    Thread Starter Senior Member

    Sep 7, 2009
    Has anyone seen this sequence before? It seems like a gray code in that only one bit changes at a time. It comes from the IR transmitter for a micro helicopter and I've called the long pulses 1 and the short pulses 0. I've put the first pulse first. Either of these things could be reversed from what the designer intended.
    I'm going to use a lookup to convert it to usable numbers so the answer isn't vital, but it would be nice to know what it is and why it would be used.

    Code ( (Unknown Language)):
    1. throttle 0-full
    2. 0100
    3. 0000
    4. 0001
    5. 0101
    6. 0111
    7. 0011
    8. 1011
    9. 1001
    10. 1101
    11. 1100
    12. 1000
    13. 1010
    14. 0010
    15. 1010
    16. 1110
    18. rudder left-right
    19. 011
    20. 001
    21. 101
    22. 100
    23. 110
    24. 010
    25. 000
  2. bertus


    Apr 5, 2008
  3. DonQ

    Active Member

    May 6, 2009
    I did a few steps and it looks like if you invert the bits, and then rearrange the bit order, it may very well be as Gray code is defined.

    Start with the 0000, invert it to 1111 and then work sequentially through the values. I didn't do all the values, but the part I did do seemed right.
  4. Markd77

    Thread Starter Senior Member

    Sep 7, 2009
    I got curious so I opened up the transmitter - it wasn't pretty. It's got a couple of PCBs for the control sticks with copper tracks and wipers for a rotary encoder. There's a mystery unmarked 18 pin DIP chip in there.
    The need for some kind of code that only changes one bit at a time is now obvious. Maybe the order is just to make the PCB simpler.
  5. DonQ

    Active Member

    May 6, 2009
    Maybe it's not the 'official' Gray code, but it does have the same effect. So probably the easiest way to decode it is a lookup table as you say.

    Often 'inventers' re-invent the wheel, so to speak.

    I've seen redefinitions of things as standardized as RS-232 pinouts, usually justified by "Well... It works!" I have even seen rearranging the bit-order in the serial stream so that the bits were no longer even sequential. His receiver worked the same way so it 'worked', on his system, but nowhere else on the planet! I think this version of Gray code may have come from the same guy:D