What are the users of gray code?

  • Thread starter aspsrilanka
  • Start date
  • Tags
    Code
In summary: Without gray code, the computer would be able to misinterpret the position of the input shaft and may be unable to correct itself.
  • #1
aspsrilanka
22
0
what are the users of gray code? (prctical aplications)
 
Engineering news on Phys.org
  • #2
aspsrilanka said:
what are the users of gray code? (prctical aplications)

For testing wether students listened in the lecture or have read the textbook?
 
  • #3
mgb_phys said:
For testing wether students listened in the lecture or have read the textbook?

what are you saying.

Most books on digital design & lecturers discuss Gray codes. However, most of the
focus is on generating these codes, rather than detailing their uses.

I read the Wikipedia article: http://en.wikipedia.org/wiki/Gray_code,
but it doesn't provide enough in-depth information of the uses of Gray
code in hardware.
 
  • #4
aspsrilanka said:
what are you saying.

Most books on digital design & lecturers discuss Gray codes. However, most of the
focus is on generating these codes, rather than detailing their uses.

I read the Wikipedia article: http://en.wikipedia.org/wiki/Gray_code,
but it doesn't provide enough in-depth information of the uses of Gray
code in hardware.

mgb was kidding a bit, but not too far off the mark. I've only seen one practical application of Gray codes, and that's in Karnaugh mapping logic functions. There are probably applications in communication theory as well.
 
  • #5
It's used everywhere, actually. The most common use is to avoid glitches in fully asynchronous circuits, like async FIFOs. Incrementing a gray-code value involves only a single bit change, so there is no possibility of glitching several bits at once. Multiple-bit glitches in a circuit like an async FIFO can cause the status flags (full, empty, etc.) to be momentarily invalid, and that can lead to all kinds of problems.

- Warren
 
  • #6
Assuming this is a homework question then typing gray code into wiki/google will give some examples.
Posting here then asking 'so why are gray codes used with an angle encoder' is reasonable. Asking 'what are gray codes for' without doing this is not.
 
  • #7
In my job, I use a lot of shaft encoders. There are 2 basic types of shaft encoders: incremental and absolute (there are also resolvers, which differ slightly in their implementation). For the sake of simplicity (and trying to stick to the point of the question), I'll use absolute encoders as my example. So from this point, on, when I mention an "encoder," I'll actually be referring to an "absolute encoder."

An encoder tells a computer the approximate position of it's input shaft. It does this via the use of a glass disc with several concentric bands of "blacked out" and "non-blacked out" areas. Each band has a photo diode pair (sender and receiver) placed so that the blacked out areas block the photo diode pair as they pass, thus producing 1's and 0's. Each band correlates to 1 bit of a binary number that the encoder produces; the more bands, the more bits, and therefore, more accuracy.

Imagine an encoder with only one band in which half of the band is blacked out. This would only be able to tell you if the shaft was in the 1st half of rotation, or the 2nd. An encoder with 2 bands would have one band like the one described above, and the other would have 4 sections: 2 blacked out sections opposite each other. If this second band was positioned so that one blacked out section and one clear section aligned with the single blacked out section of the first band, then the encoder would have the capability of producing the following 4 binary numbers: 00, 01, 10, and 11. This encoder would have twice the accuracy of the first encoder and could thus tell the computer it's position to the nearest 90 degrees (rather than 180 degrees, as before).

The problem with this is that the change from 01 to 10 requires both binary bits to change state at the same time. If the alignment of the photo diodes is not exact, then the possibility exists that the computer could misinterpret the position during this transition. For example, if the encoder is on it's way from 01 to 10, a misaligned photo diode pair may cause the computer to see one bit change before the other. This could cause the computer to "think" that the encoder is at either 11 or 00 (incorrectly) rather than at 10.

Gray code prevents this from happening by rearranging the binary code so that only one bit changes at a time when transitioning from one "position" to the next. In this example (with 2 bits), the blacked out areas could be placed so that the binary sequence instead becomes 00, 01, 11, 10. Now, slight misalignment doesn't affect the interpretation of the signal produced because now we only expect one bit to change at a time (we're never worried that another bit has to "catch up").

The more bands (and therefore more bits) that an encoder has, the more potential for this kind of problem exists, thus the need for a gray code.
 

Related to What are the users of gray code?

What is gray code?

Gray code, also known as reflected binary code, is a type of binary number system where only one bit changes between consecutive numbers. This code is often used in digital communication systems and mathematical applications.

How is gray code different from regular binary code?

In regular binary code, each bit changes between consecutive numbers. This can result in multiple bits changing at once, making it difficult to detect and correct errors. In gray code, only one bit changes between numbers, making it easier to detect and correct errors.

What are the applications of gray code?

Gray code is commonly used in digital communication systems, such as encoders and decoders, to reduce the likelihood of errors. It is also used in mathematical applications, such as solving the Tower of Hanoi puzzle and designing electronic circuits.

How does gray code benefit users?

Gray code's ability to reduce errors is its main benefit for users. This can lead to more accurate and efficient communication and calculations. Additionally, gray code is often easier for humans to read and understand compared to regular binary code.

Are there any disadvantages to using gray code?

One potential disadvantage of gray code is that it requires more bits to represent the same numbers compared to regular binary code. This can be an issue in certain applications with limited storage or processing capabilities. Additionally, converting between gray code and regular binary code can be more complex and time-consuming.

Similar threads

  • Electrical Engineering
Replies
1
Views
1K
  • Atomic and Condensed Matter
Replies
0
Views
760
  • Electrical Engineering
Replies
1
Views
674
  • Electrical Engineering
Replies
1
Views
1K
  • Electrical Engineering
Replies
5
Views
1K
  • Electrical Engineering
Replies
13
Views
2K
Replies
8
Views
5K
  • Programming and Computer Science
Replies
7
Views
618
  • Feedback and Announcements
Replies
2
Views
755
  • Electrical Engineering
Replies
16
Views
4K
Back
Top