27-03-2012, 11:06 AM
Encoders and Decoders
_Fundamentals of Digital Electronics.pdf (Size: 536.71 KB / Downloads: 40)
An encoder converts an input device state into a binary representation of
ones or zeros. Consider a rotary switch with 10 positions used to input the
numbers 0 through 9. Each switch position is to be encoded by a unique
binary sequence. For example, switch position 7 might be encoded as 0111.
A decoder performs the opposite conversion, from binary codes into output
codes.
Encoder
For example, each output has three (1) states and three (0) states. One of
these outputs, for example Q3, could signify odd states 1, 3, and 5. Another
output state, for example Q2¢, can then signify the family 4, 5, 6. These two
lines then decode two of the base patterns for “free.” The two remaining
base patterns are decoded with a particular pattern of the three counter
lines. To this end, a three-input AND gate built in the last lab together with
an inverter can be used. Not 1 (Base Pattern B) is decoded with the
combination Q1 & Q2 & Q3, and the final base state “6” is decoded with
Q1¢ & Q2¢ & Q3¢.
Virtual Dice
To roll the virtual die, a high-speed counter will cycle through the six states.
These states are encoded on three output lines. In practice, the counter
cycles until a stop command is issued to the counter. Whatever state the
counter has on its output will be the roll value. A clock with a speed greater
than 1 kHz ensures the randomness of the roll.
An encoder VI converts the three counter lines into the four control lines for
the base patterns. These in turn set the dots on the virtual die to the correct
output code.
Binary Addition
Before proceeding with this lab, it is helpful to review some details of binary
addition. Just as in decimal addition, adding 0 to any value leaves
that number unchanged: 0 + 0 = 0, while 1 + 0 = 1. However, when you add
1 + 1 in binary addition, the result is not “2” (a symbol which does not exist
in the binary number system), but “10”; a “1” in the “twos place” and a zero
in the “ones place.” If you write this addition vertically, you would recite,
“One and one are two; write down the zero, carry the one”:
Binary Coded Decimal (BCD)
Not all digital arithmetic is performed by a direct conversion to the base-2
representation. Binary coded decimal, or BCD, representation is also used.