Graycode http://www.dsplog.com/2008/05/11/binary-to-gray-code-conversion-psk-pam/ Conversion from natural Binary to Gray code Consider a bit binary number with representing the index of the binary number. Let be the equivalent Gray code. 1. For , i.e, the most significant bit (MSB) of the Gray code is same as the MSB of original binary number. 2. For , i.e, bit of the Gray code is the exclusive-OR (XOR) of of the bit of the binary number and of the bit of the binary number. ================================================================================================== http://www.plcdev.com/using_ladder_logic_for_gray_code_conversion This list is by no means complete but if you still need to do it in ladder logic then read on. Fortunately, the conversion is somewhat easy to do. Let me try to explain it first. Copy the most significant bit of the Gray code which becomes the most significant bit of the binary code. Take the next bit down in the Gray code and the most significant bit of the binary and do a logical XOR and this becomes the next bit in the binary code. Take the next bit down in the Gray code and the next bit down in the binary code and do a logical XOR and this becomes the next bit in the binary code. Continue this process until you reach the end of the Gray code.