9846

Gray Code's Error Reduction with Encoders

Unlike binary, which follows the sequence 000, 001, 010, 011, 100, and so on, a Gray code is one in which only one bit changes between consecutive steps, such as in the sequence 000, 001, 011, 010, 110, and so on. This has many applications, such as reducing the likelihood of reading an incorrect code from encoders. Two types of encoders are shown in this Demonstration, a rotary encoder used to measure rotation, and a linear encoder used to measure absolute distance. The red sensor reads white contacts as zeros and black contacts as ones, so each position of the sensor yields a unique four-digit code. However, if the positions of the contacts on the encoder are anything less than perfect, the sensor might read an incorrect code. Since a Gray code only varies by one bit for consecutive steps, this will never cause the sensor to read a code that is more than one step away from what it should be, which is shown as the "real step" in the Demonstration. Binary has no limit to how many bits can change between steps, so the transition might cause an illogical sequence, such as from steps three to zero to four. The Demonstration shows this by allowing the contacts for one of the bits to become misaligned. If the sensor reads the correct code, the step is displayed in black; if it is one step away, it is displayed in orange; and if it is more than one step away, it is displayed in red.
Because a Gray code can help reduce error, it is often used for error correction in transmissions. Since only one bit changes per step, errors can be more easily identified and corrected. Communication satellites are often programmed with Gray code for this reason.

SNAPSHOTS

  • [Snapshot]
  • [Snapshot]
  • [Snapshot]

DETAILS

Snapshot 1: these linear encoders have no misalignment; they will both read the code perfectly
Snapshot 2: the third digit is incorrect for both encoders; however, the Gray encoder will still follow the sequence of steps three to four, while the binary encoder will go from steps three to zero to four
Snapshot 3: the third digit is incorrect for the binary encoder, but correct for the Gray encoder; errors are both smaller and less frequent with Gray code than binary

RELATED LINKS

    • Share:

Embed Interactive Demonstration New!

Just copy and paste this snippet of JavaScript code into your website or blog to put the live Demonstration on your site. More details »

Files require Wolfram CDF Player or Mathematica.









 
RELATED RESOURCES
Mathematica »
The #1 tool for creating Demonstrations
and anything technical.
Wolfram|Alpha »
Explore anything with the first
computational knowledge engine.
MathWorld »
The web's most extensive
mathematics resource.
Course Assistant Apps »
An app for every course—
right in the palm of your hand.
Wolfram Blog »
Read our views on math,
science, and technology.
Computable Document Format »
The format that makes Demonstrations
(and any information) easy to share and
interact with.
STEM Initiative »
Programs & resources for
educators, schools & students.
Computerbasedmath.org »
Join the initiative for modernizing
math education.
Step-by-step Solutions »
Walk through homework problems one step at a time, with hints to help along the way.
Wolfram Problem Generator »
Unlimited random practice problems and answers with built-in Step-by-step solutions. Practice online or make a printable study sheet.
Wolfram Language »
Knowledge-based programming for everyone.
Powered by Wolfram Mathematica © 2014 Wolfram Demonstrations Project & Contributors  |  Terms of Use  |  Privacy Policy  |  RSS Give us your feedback
Note: To run this Demonstration you need Mathematica 7+ or the free Mathematica Player 7EX
Download or upgrade to Mathematica Player 7EX
I already have Mathematica Player or Mathematica 7+