PLC Archive:Gray Code to Binary Conversion

From ControlWiki

Revision as of 19:50, 18 September 2009 by Cwiki (Talk | contribs)
(diff) ← Older revision | Current revision (diff) | Newer revision → (diff)
Jump to: navigation, search


Gray Code to Binary Conversion

contributed by: Anthony Kerstens

Link to File

Click here to view program file.

Abstract

This file was submitted by Anthony Kerstens for converting grey code to binary. It's generalized to use a full 16 bits, but could be shortened or expanded to suit the application. The MSB is taken directly, and the algorithm for subsequent bits is the same for the remaining bits regardless of the number.

The logic example is programmed with symbols G15 to G00, and B with bits /15 to /0. G15 to G00 are gray code inputs from an encoder or other such device. B is the binary integer file, with individual bit B/15 to B/0. The G15_MSB is taken directly. Subsequent G bits are XOR'd with the previous B bit. ie. B/n = Gn xor B/(n+1).

Disclaimer

For all material in the PLC Archive, our site disclaimer applies. You take full responsibility for the application of any code appearing on this site, as we have made no engineering evaluation of the code nor are we, or the author, familiar with the details and risks inherent in your application.

Personal tools