Content deleted Content added
|
|
(4 intermediate revisions by 3 users not shown) |
#REDIRECT [[Gray code]] {{R from modification}}
A gray code is a special coding system designed to prevent spurious output
from practical electromechanical switches. For example, if we create a
device that indicates position by closing and opening switches, we could use
the binary code to represent position:
<table>
<caption>Binary Code</caption>
<tr>
<td>Input position</td>
<td>Output 3</td>
<td>Output 2</td>
<td>Output 1</td>
</tr>
<tr>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<td>1</td>
<td>0</td>
<td>0</td>
<td>1</td>
</tr>
<tr>
<td>2</td>
<td>0</td>
<td>1</td>
<td>0</td>
</tr>
<tr>
<td>3</td>
<td>0</td>
<td>1</td>
<td>1</td>
</tr>
<tr>
<td>4</td>
<td>1</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<td>5</td>
<td>1</td>
<td>0</td>
<td>1</td>
</tr>
<tr>
<td>6</td>
<td>1</td>
<td>1</td>
<td>0</td>
</tr>
<tr>
<td>7</td>
<td>1</td>
<td>1</td>
<td>1</td>
</tr>
</table>
The problem is that, with real (mechanical) switches, it is very unlikely
that two switches will change states exactly in synchrony. For example, in
the transistion from state 3 to state 4, all three switches change state.
In the brief period while all are changing, the switches will read some spurious position.
A gray code solves this problem by changing only one switch at a time, so
there is never any ambiguity of position:
<table>
<caption>Gray Code</caption>
<tr>
<td>Input position</td>
<td>Output 3</td>
<td>Output 2</td>
<td>Output 1</td>
</tr>
<tr>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<td>1</td>
<td>0</td>
<td>0</td>
<td>1</td>
</tr>
<tr>
<td>2</td>
<td>0</td>
<td>1</td>
<td>1</td>
</tr>
<tr>
<td>3</td>
<td>0</td>
<td>1</td>
<td>0</td>
</tr>
<tr>
<td>4</td>
<td>1</td>
<td>1</td>
<td>0</td>
</tr>
<tr>
<td>5</td>
<td>1</td>
<td>1</td>
<td>1</td>
</tr>
<tr>
<td>6</td>
<td>1</td>
<td>0</td>
<td>1</td>
</tr>
<tr>
<td>7</td>
<td>1</td>
<td>0</td>
<td>0</td>
</tr>
</table>
Notice also that state seven can roll over to state zero with only one
switch change.
|