Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

What are the users of gray code?

  1. Sep 21, 2009 #1
    what are the users of gray code? (prctical aplications)
     
  2. jcsd
  3. Sep 21, 2009 #2

    mgb_phys

    User Avatar
    Science Advisor
    Homework Helper

    For testing wether students listened in the lecture or have read the text book?
     
  4. Sep 21, 2009 #3
    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.
     
  5. Sep 21, 2009 #4

    berkeman

    User Avatar

    Staff: Mentor

    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.
     
  6. Sep 21, 2009 #5

    chroot

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    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
     
  7. Sep 21, 2009 #6

    mgb_phys

    User Avatar
    Science Advisor
    Homework Helper

    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.
     
  8. Oct 1, 2009 #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.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: What are the users of gray code?
  1. Help with code (Replies: 1)

Loading...