Encoders & Decoders

1 of 8 Decoder

Imagine we had 8 devices we wanted to control, but we wanted to keep the number of control switches to a minimum. One solution would be to use just 3 swithces, and interpret them as binary digits. A binary number 3 digits long can give us 8 values, from 0 to 7.

It would be a straight-forward, but tedious, task to design a set of logic circuits to decode our 3 switches into 8 control signals. Luckily, there's a chip already produces that does the job for us. The 74HCT138 is a 1-of-8 decoder, which takes 3 bits of digital input and uses them to activate one of eight possible outputs.

Let's walk through the chip pins. A, B, and C are the input pins. We can think of A as the 1's digit, B as the 2's digit, and C as the 3's digit. Note that these pins are LOW=True -- to encode a 0, send them a HIGH signal; and to encode a 1, send them a LOW signal.

Y0-Y7 are the output pins. Again, these pins are LOW-True. So, when C is HIGH, B is LOW, and A is LOW, we'll be sending the number 011, or 3. That means that Y3 will send out a LOW signal, and all other pins will remain HIGH.

There are also 3 enable pins, G1, G2A', G2B', which can disable the output pins. When G1 is HIGH, G2A' LOW, and G2B' LOW, the chip will operate as a normal decoder. But if we set G1 LOW, or either of G2A' or G2B' HIGH, then all of the outputs will be turned off, and output HIGH regardless of the inputs. These enable pins allow us to control the chip's output within the circuit.


8 to 3 Encoder

Now, it may be that we want to get input from 8 different switches, but only have 3 inputs -- a common situation when working with the RCX, for example. Here, we could use an 8-to-3 Encoder. The 74HC148 encoder is one chip that will do the trick.

Here, inputs 0-7 are the input signals -- again, these are Active-LOW. The chip encodes the input into a 3 digit output, A0 (1's bit), A1 (2's bit), and A3 (4's bit).

EI enables the inputs. When it is LOW, the chip works properly. When it's HIGH, all outputs are set to HIGH regardless of the input. EO and GS are outputs that we can ignore for now.

The encoder and decoder chips allow us to maximize the use of inputs and outputs. Since the RCX has only 3 of each, it's handy to be able to get more than 3 pieces of information back and forth at any one time.


 

Back           Next