3 to 8 decoder mux’d with uC

The 3 to 8 decoder is one of many ICs that can be used to multiplex one side of the matrix we are scanning. The basic concept is to save microcontroller pins by multiplexing the columns of your matrix. So, rather than just having the microcontroller activate a single column, data is sent out through a decoder to activate the correct column. In this way, a very large number of columns can be addressed with only 3 microcontroller pins. An example of this is shown below.

3 to 8 mux schematic

Figure 1 – Example 3 to 8 decoder mux schematic.

A 3 to 8 decoder is an IC which activates one of its pins based upon a 3 bit code applied at the input. The 74HC138 is the most common variant, but there are many others, including the ’137 which has an output latch, and the ’156 which has open-collector outputs. They also make 4 to 16 decoders, which are sometimes more expensive than buying 2 ’138′s. Examples of these are the ’154 and the CD4514, the latter being relatively inexpensive. Interestingly enough, it also has a latch and output disable.

Of the 3 partially mux’d matrix options (parallel-in, parallel-out, and 3 to 8), the 3 to 8 method comes in second. It can be slightly faster than the parallel-out method, although the difference is minimal. It consumes a similar amount microcontroller lines (3 in comparison to the parallel-out’s 2), but it needs additional microcontroller lines to scale to more than 8 columns. Finally, it does allow for switches to activate external interrupts, but only one column of switches can do this at a time.

The programming of this method is relatively straight forward, and it has the advantage of being independent of its previous state. In the case of the parallel-out method, if the microcontroller gets interrupted and loses state, it could activate the wrong column. For situations where you have 8 or less columns, this method is almost as good as the parallel-out option, and is probably used much more frequently.