What are the users of gray code?

  • Thread starter Thread starter aspsrilanka
  • Start date Start date
  • Tags Tags
    Code
AI Thread Summary
Gray code is primarily used in digital design to prevent glitches in asynchronous circuits, such as asynchronous FIFOs, by ensuring that only one bit changes at a time during transitions. It is particularly valuable in applications like shaft encoders, where accurate position detection is critical; Gray code minimizes the risk of misinterpretation during bit transitions. While many resources focus on generating Gray codes, there is a noted lack of detailed information on their practical applications in hardware. The discussion highlights the importance of Gray code in improving the reliability of systems that rely on precise binary signaling. Understanding these applications is essential for those studying digital design and its implementations.
aspsrilanka
Messages
22
Reaction score
0
what are the users of gray code? (prctical aplications)
 
Engineering news on Phys.org
aspsrilanka said:
what are the users of gray code? (prctical aplications)

For testing wether students listened in the lecture or have read the textbook?
 
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.
 
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.
 
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
 
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.
 
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.
 

Similar threads

Replies
22
Views
2K
Replies
1
Views
1K
Replies
25
Views
2K
Replies
2
Views
1K
Replies
0
Views
2K
Replies
39
Views
317
Back
Top