Gray Code Generation Method and Its Relationship with binary code

Source: Internet
Author: User

Gray code is also an encoding method that can be used for counting. It only changes one bit when adding 1, which simplifies hardware implementation. Therefore, many speed sensors, absolute position sensors and so on will use Gray code count. In addition, due to the characteristics of Ray codes, a change process only changes one bit. Compared with the normal binary count, the increase of 1 May change Multiple Digits, which is more secure. Therefore, it is safer and easier to implement the State count of the state machine in the digital circuit.

Gray code can be generated as follows

0: Image 0 + symbol 00: Image 00 + symbol 000 .....

1 1 01 01 001

---------

1 11 11 011

0 10 10 010

-----------------

10 110

11 111

01 101

00 100


Relationship between Gray code and binary code

A binary number is BnBn-1Bn-2... b1b0

A gray code is GnGn-1Gn-2... g1g0

Binary to Gray code:

Highest bit:

GN = Bn

Other BITs gi = (Bi + 1) ^ (BI );

Gray code to binary:

Highest bit:

BN = Gn

Other BITs Bi = (Bi + 1) ^ (GI );



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.